parent
1ce40f2c1a
commit
6ca0d7248b
329 changed files with 178 additions and 139 deletions
modules/ags/config/widgets/applauncher
27
modules/ags/config/widgets/applauncher/launch.ts
Normal file
27
modules/ags/config/widgets/applauncher/launch.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
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.frequency += 1;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue