nixos-configs/modules/ags/config/widgets/applauncher/launch.ts
matt1432 179e402504
All checks were successful
Discord / discord commits (push) Has been skipped
refactor(ags): prioritise getters when using astal libs
2024-12-29 17:22:55 -05:00

28 lines
718 B
TypeScript

import { execAsync } from 'astal';
import AstalApps from 'gi://AstalApps';
const bash = async(strings: TemplateStringsArray | string, ...values: unknown[]) => {
const cmd = typeof strings === 'string' ?
strings :
strings.flatMap((str, i) => `${str}${values[i] ?? ''}`)
.join('');
return execAsync(['bash', '-c', cmd]).catch((err) => {
console.error(cmd, err);
return '';
});
};
export const launchApp = (app: AstalApps.Application) => {
const exe = app.executable
.split(/\s+/)
.filter((str) => !str.startsWith('%') && !str.startsWith('@'))
.join(' ');
bash(`${exe} &`);
app.set_frequency(app.get_frequency() + 1);
};