Skip to content

Commit 94101b7

Browse files
committed
fix(app-launcher): propagate context to launched apps
1 parent 3893933 commit 94101b7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/components/menus/apps/index.tsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { RevealerTransitionMap } from 'src/lib/constants/options.js';
66
import { App, Gtk } from 'astal/gtk3';
77
import Separator from 'src/components/shared/Separator.js';
88
import AstalApps from 'gi://AstalApps?version=0.1'
9-
import { icon, launchApp } from 'src/lib/utils.js';
9+
import { bash, icon } from 'src/lib/utils.js';
1010
import { Entry, EntryProps, Scrollable } from 'astal/gtk3/widget';
1111

1212
import PopupWindow from '../shared/popup/index.js';
@@ -24,9 +24,19 @@ interface ApplicationItemProps {
2424
onLaunched?: () => void;
2525
}
2626

27+
function launch(app: AstalApps.Application): void {
28+
const exe = app.executable
29+
.split(/\s+/)
30+
.filter((str) => !str.startsWith('%') && !str.startsWith('@'))
31+
.join(' ');
32+
33+
bash(`hyprctl dispatch exec ${exe}`);
34+
app.frequency += 1;
35+
}
36+
2737
const ApplicationItem = ({ app, onLaunched }: ApplicationItemProps): JSX.Element => {
2838
return (
29-
<button className="notification-card" halign={Gtk.Align.FILL} valign={Gtk.Align.START} onClick={() => { launchApp(app); onLaunched?.() }}>
39+
<button className="notification-card" halign={Gtk.Align.FILL} valign={Gtk.Align.START} onClick={() => { launch(app); onLaunched?.() }}>
3040
<box spacing={5}>
3141
<icon className="notification-card-image icon" margin={5} halign={Gtk.Align.CENTER} valign={Gtk.Align.CENTER} vexpand={false} icon={icon(app.iconName)} />
3242
<label halign={Gtk.Align.START} valign={Gtk.Align.CENTER} label={app.name} hexpand vexpand truncate wrap />
@@ -93,7 +103,7 @@ const ApplicationLauncher = ({ visible, onLaunched }: ApplicationLauncherProps):
93103
const onFilterReturn = () => {
94104
const first = list.get()[0]
95105
if (!first) return;
96-
launchApp(first)
106+
launch(first);
97107
onLaunched?.()
98108
}
99109

0 commit comments

Comments
 (0)