From 2b82bff1033e602f375e84f01fc7213fa73514ea Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 7 Feb 2025 17:24:57 +0200 Subject: Auto formatting/linting --- .config/ags/widget/launcher/Launcher.ts | 143 +++++++++++++++----------------- 1 file changed, 69 insertions(+), 74 deletions(-) (limited to '.config/ags/widget/launcher/Launcher.ts') diff --git a/.config/ags/widget/launcher/Launcher.ts b/.config/ags/widget/launcher/Launcher.ts index 3b73dc5..90b4d58 100644 --- a/.config/ags/widget/launcher/Launcher.ts +++ b/.config/ags/widget/launcher/Launcher.ts @@ -1,22 +1,22 @@ -import { type Binding } from "lib/utils" -import PopupWindow, { Padding } from "widget/PopupWindow" -import icons from "lib/icons" -import options from "options" -import nix from "service/nix" -import * as AppLauncher from "./AppLauncher" -import * as NixRun from "./NixRun" -import * as ShRun from "./ShRun" +import { type Binding } from 'lib/utils'; +import PopupWindow, { Padding } from 'widget/PopupWindow'; +import icons from 'lib/icons'; +import options from 'options'; +import nix from 'service/nix'; +import * as AppLauncher from './AppLauncher'; +import * as NixRun from './NixRun'; +import * as ShRun from './ShRun'; -const { width, margin } = options.launcher -const isnix = nix.available +const { width, margin } = options.launcher; +const isnix = nix.available; function Launcher() { - const favs = AppLauncher.Favorites() - const applauncher = AppLauncher.Launcher() - const sh = ShRun.ShRun() - const shicon = ShRun.Icon() - const nix = NixRun.NixRun() - const nixload = NixRun.Spinner() + const favs = AppLauncher.Favorites(); + const applauncher = AppLauncher.Launcher(); + const sh = ShRun.ShRun(); + const shicon = ShRun.Icon(); + const nix = NixRun.NixRun(); + const nixload = NixRun.Spinner(); function HelpButton(cmd: string, desc: string | Binding) { return Widget.Box( @@ -24,94 +24,88 @@ function Launcher() { Widget.Separator(), Widget.Button( { - class_name: "help", + class_name: 'help', on_clicked: () => { - entry.grab_focus() - entry.text = `:${cmd} ` - entry.set_position(-1) + entry.grab_focus(); + entry.text = `:${cmd} `; + entry.set_position(-1); }, }, Widget.Box([ Widget.Label({ - class_name: "name", + class_name: 'name', label: `:${cmd}`, }), Widget.Label({ hexpand: true, - hpack: "end", - class_name: "description", + hpack: 'end', + class_name: 'description', label: desc, }), ]), ), - ) + ); } const help = Widget.Revealer({ child: Widget.Box( { vertical: true }, - HelpButton("sh", "run a binary"), - isnix ? HelpButton("nx", options.launcher.nix.pkgs.bind().as(pkg => - `run a nix package from ${pkg}`, - )) : Widget.Box(), + HelpButton('sh', 'run a binary'), + isnix + ? HelpButton( + 'nx', + options.launcher.nix.pkgs.bind().as(pkg => `run a nix package from ${pkg}`), + ) + : Widget.Box(), ), - }) + }); const entry = Widget.Entry({ hexpand: true, primary_icon_name: icons.ui.search, on_accept: ({ text }) => { - if (text?.startsWith(":nx")) - nix.run(text.substring(3)) - else if (text?.startsWith(":sh")) - sh.run(text.substring(3)) - else - applauncher.launchFirst() + if (text?.startsWith(':nx')) nix.run(text.substring(3)); + else if (text?.startsWith(':sh')) sh.run(text.substring(3)); + else applauncher.launchFirst(); - App.toggleWindow("launcher") - entry.text = "" + App.toggleWindow('launcher'); + entry.text = ''; }, on_change: ({ text }) => { - text ||= "" - favs.reveal_child = text === "" - help.reveal_child = text.split(" ").length === 1 && text?.startsWith(":") + text ||= ''; + favs.reveal_child = text === ''; + help.reveal_child = text.split(' ').length === 1 && text?.startsWith(':'); - if (text?.startsWith(":nx")) - nix.filter(text.substring(3)) - else - nix.filter("") + if (text?.startsWith(':nx')) nix.filter(text.substring(3)); + else nix.filter(''); - if (text?.startsWith(":sh")) - sh.filter(text.substring(3)) - else - sh.filter("") + if (text?.startsWith(':sh')) sh.filter(text.substring(3)); + else sh.filter(''); - if (!text?.startsWith(":")) - applauncher.filter(text) + if (!text?.startsWith(':')) applauncher.filter(text); }, - }) + }); function focus() { - entry.text = "" - entry.set_position(-1) - entry.select_region(0, -1) - entry.grab_focus() - favs.reveal_child = true + entry.text = ''; + entry.set_position(-1); + entry.select_region(0, -1); + entry.grab_focus(); + favs.reveal_child = true; } const layout = Widget.Box({ css: width.bind().as(v => `min-width: ${v}pt;`), - class_name: "launcher", + class_name: 'launcher', vertical: true, - vpack: "start", - setup: self => self.hook(App, (_, win, visible) => { - if (win !== "launcher") - return + vpack: 'start', + setup: self => + self.hook(App, (_, win, visible) => { + if (win !== 'launcher') return; - entry.text = "" - if (visible) - focus() - }), + entry.text = ''; + if (visible) focus(); + }), children: [ Widget.Box([entry, nixload, shicon]), favs, @@ -120,20 +114,21 @@ function Launcher() { //nix, sh, ], - }) + }); return Widget.Box( - { vertical: true, css: "padding: 1px" }, - Padding("applauncher", { + { vertical: true, css: 'padding: 1px' }, + Padding('applauncher', { css: margin.bind().as(v => `min-height: ${v}pt;`), vexpand: false, }), layout, - ) + ); } -export default () => PopupWindow({ - name: "launcher", - layout: "top", - child: Launcher(), -}) +export default () => + PopupWindow({ + name: 'launcher', + layout: 'top', + child: Launcher(), + }); -- cgit v1.2.3