diff --git a/modules/ags/config/ts/applauncher/app-item.ts b/modules/ags/config/ts/applauncher/app-item.ts index 3db5d14a..99b6336f 100644 --- a/modules/ags/config/ts/applauncher/app-item.ts +++ b/modules/ags/config/ts/applauncher/app-item.ts @@ -2,8 +2,9 @@ const { Box, Icon, Label } = Widget; const { lookUpIcon } = Utils; import CursorBox from '../misc/cursorbox.ts'; +import { launchApp } from './launch.ts'; -// Types +/* Types */ import { Application } from 'types/service/applications.ts'; @@ -55,7 +56,7 @@ export default (app: Application) => { on_primary_click_release: () => { App.closeWindow('win-applauncher'); - app.launch(); + launchApp(app); }, child: Box({ diff --git a/modules/ags/config/ts/applauncher/launch.ts b/modules/ags/config/ts/applauncher/launch.ts new file mode 100644 index 00000000..f6bce099 --- /dev/null +++ b/modules/ags/config/ts/applauncher/launch.ts @@ -0,0 +1,26 @@ +/* Types */ +import { Application } from 'types/service/applications.ts'; + + +const bash = async(strings: TemplateStringsArray | string, ...values: unknown[]) => { + const cmd = typeof strings === 'string' ? + strings : + strings.flatMap((str, i) => `${str }${values[i] ?? ''}`) + .join(''); + + return Utils.execAsync(['bash', '-c', cmd]).catch((err) => { + console.error(cmd, err); + + return ''; + }); +}; + +export const launchApp = (app: Application) => { + const exe = app.executable + .split(/\s+/) + .filter((str) => !str.startsWith('%') && !str.startsWith('@')) + .join(' '); + + bash(`${exe} &`); + app.frequency += 1; +}; diff --git a/modules/ags/config/ts/applauncher/main.ts b/modules/ags/config/ts/applauncher/main.ts index 6ed14b21..0aa68052 100644 --- a/modules/ags/config/ts/applauncher/main.ts +++ b/modules/ags/config/ts/applauncher/main.ts @@ -5,6 +5,7 @@ import { Fzf, FzfResultItem } from 'fzf'; import PopupWindow from '../misc/popup.ts'; import AppItem from './app-item.ts'; +import { launchApp } from './launch.ts'; // Types import { ListBoxRow } from 'types/@girs/gtk-3.0/gtk-3.0.cjs'; @@ -72,7 +73,7 @@ const Applauncher = (window_name = 'applauncher') => { if (appList[0]) { App.closeWindow(`win-${window_name}`); - appList[0].launch(); + launchApp(appList[0]); } }, diff --git a/modules/ags/config/ts/notifications/base.ts b/modules/ags/config/ts/notifications/base.ts index 306590ea..a6339470 100644 --- a/modules/ags/config/ts/notifications/base.ts +++ b/modules/ags/config/ts/notifications/base.ts @@ -9,6 +9,7 @@ const { GLib } = imports.gi; import Gesture from './gesture.ts'; import CursorBox from '../misc/cursorbox.ts'; +import { launchApp } from '../applauncher/launch.ts'; // Types import { Notification as NotifObj } from 'types/service/notifications.ts'; @@ -89,7 +90,7 @@ const NotificationIcon = (notif: NotifObj) => { else { Hyprland.messageAsync('dispatch workspace empty') .then(() => { - app.launch(); + launchApp(app); }); } });