feat(desktop): add ags touch gestures and don't accept any js
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-11-07 10:39:28 -05:00
parent 52af004829
commit 33b8a9e097
5 changed files with 46 additions and 29 deletions

View file

@ -1,4 +1,3 @@
// TODO: touch gestures
// TODO: persisting data like bluetooth // TODO: persisting data like bluetooth
// TODO: quick-settings // TODO: quick-settings
// TODO: music player stuff // TODO: music player stuff

View file

@ -20,15 +20,35 @@ export default async() => {
const Brightness = (await import('../services/brightness')).default; const Brightness = (await import('../services/brightness')).default;
const MonitorClicks = (await import('../services/monitor-clicks')).default; const MonitorClicks = (await import('../services/monitor-clicks')).default;
globalThis.closeAll = closeAll;
globalThis.Brightness = Brightness;
App.start({ App.start({
css: style, css: style,
requestHandler(js, res) { requestHandler(request, respond) {
App.eval(js).then(res).catch(res); if (request.startsWith('open')) {
App.get_window(request.replace('open ', ''))?.set_visible(true);
respond('window opened');
}
else if (request.startsWith('closeAll')) {
closeAll();
respond('closed all windows');
}
else if (request.startsWith('fetchCapsState')) {
Brightness.fetchCapsState();
respond('fetched caps_lock state');
}
else if (request.startsWith('Brightness.screen')) {
Brightness.screen += parseFloat(request.replace('Brightness.screen ', ''));
respond('screen brightness changed');
}
else if (request.startsWith('popup')) {
popup_osd(request.replace('popup ', ''));
respond('osd popped up');
}
else if (request.startsWith('osk')) {
console.log(`TODO: ${request.replace('osk ', '')}`);
respond('implement this');
}
}, },
main: () => { main: () => {
@ -52,10 +72,6 @@ export default async() => {
caps: 'input1::capslock', caps: 'input1::capslock',
}); });
new MonitorClicks(); new MonitorClicks();
setTimeout(() => {
App.get_window('win-applauncher')?.set_visible(true);
}, 3 * 1000);
}, },
}); });
}; };

View file

@ -1,11 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars, no-var */ /* eslint-disable @typescript-eslint/no-unused-vars */
const SRC: string; const SRC: string;
var Brightness: import('./services/brightness').default;
function closeAll(): void;
declare module 'inline:*' { declare module 'inline:*' {
const content: string; const content: string;

View file

@ -22,7 +22,10 @@
"ignorealpha 0.19, ^(blur-bg.*)" "ignorealpha 0.19, ^(blur-bg.*)"
]; ];
exec-once = ["ags"]; exec-once = [
"ags"
"sleep 3; ags request 'open win-applauncher'"
];
bind = [ bind = [
"$mainMod SHIFT, E , exec, ags toggle win-powermenu" "$mainMod SHIFT, E , exec, ags toggle win-powermenu"
@ -32,15 +35,15 @@
]; ];
binde = [ binde = [
## Brightness control ## Brightness control
", XF86MonBrightnessUp , exec, ags request 'Brightness.screen += 0.05'" ", XF86MonBrightnessUp , exec, ags request 'Brightness.screen +0.05'"
", XF86MonBrightnessDown, exec, ags request 'Brightness.screen -= 0.05'" ", XF86MonBrightnessDown, exec, ags request 'Brightness.screen -0.05'"
## Volume control ## Volume control
", XF86AudioRaiseVolume , exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ & ags request 'popup_osd(\"speaker\")' &" ", XF86AudioRaiseVolume , exec, wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ & ags request 'popup speaker' &"
", XF86AudioLowerVolume , exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- & ags request 'popup_osd(\"speaker\")' &" ", XF86AudioLowerVolume , exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- & ags request 'popup speaker' &"
]; ];
bindn = [" , Escape , exec, ags request 'closeAll()'"]; bindn = [" , Escape , exec, ags request closeAll"];
bindr = ["CAPS, Caps_Lock, exec, ags request 'Brightness.fetchCapsState()'"]; bindr = ["CAPS, Caps_Lock, exec, ags request fetchCapsState"];
}; };
}; };
} }

View file

@ -36,16 +36,19 @@ in {
# windows # windows
resize_on_border_long_press = true; resize_on_border_long_press = true;
hyprgrass-bindm = [", longpress:2, movewindow"];
# in pixels, the distance from the edge that is considered an edge # in pixels, the distance from the edge that is considered an edge
edge_margin = 10; edge_margin = 10;
experimental = { # send proper cancel events to windows instead of hacky touch_up events,
# send proper cancel events to windows instead of hacky touch_up events, # NOT recommended as it crashed a few times, once it's stabilized I'll make it the default
# NOT recommended as it crashed a few times, once it's stabilized I'll make it the default experimental.send_cancel = 0;
send_cancel = 0;
}; hyprgrass-bind = [
", edge:u:d, exec, ags request 'open win-applauncher'"
", edge:d:u, exec, ags request 'osk open'"
", swipe:3:d, exec, hyprctl dispatch hyprexpo:expo on"
];
hyprgrass-bindm = [", longpress:2, movewindow"];
}; };
}; };