feat(ags): move lisgd config to ags

This commit is contained in:
matt1432 2023-11-05 01:34:13 -05:00
parent fe445a0ccc
commit 2cc121b602
4 changed files with 158 additions and 25 deletions

View file

@ -1,7 +1,8 @@
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
import Tablet from '../services/tablet.js'; import Tablet from '../services/tablet.js';
import Pointers from '../services/pointers.js'; import Pointers from '../services/pointers.js';
import TouchGestures from '../services/touch-gestures.js';
import closeAll from './misc/closer.js'; import closeAll from './misc/closer.js';
@ -11,4 +12,32 @@ export default () => {
globalThis.closeAll = closeAll; globalThis.closeAll = closeAll;
execAsync(['bash', '-c', '$AGS_PATH/startup.sh']).catch(print); execAsync(['bash', '-c', '$AGS_PATH/startup.sh']).catch(print);
TouchGestures.addGesture({
name: 'oskOn',
gesture: 'DU',
edge: 'B',
command: 'busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true',
});
TouchGestures.addGesture({
name: 'oskOff',
gesture: 'UD',
edge: 'B',
command: 'busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false',
});
TouchGestures.addGesture({
name: 'swipeSpotify1',
gesture: 'LR',
edge: 'L',
command: 'hyprctl dispatch togglespecialworkspace spot',
});
TouchGestures.addGesture({
name: 'swipeSpotify2',
gesture: 'RL',
edge: 'L',
command: 'hyprctl dispatch togglespecialworkspace spot',
});
}; };

View file

@ -0,0 +1,127 @@
import Service from 'resource:///com/github/Aylur/ags/service.js';
import { subprocess } from 'resource:///com/github/Aylur/ags/utils.js';
const SCREEN = '/dev/input/by-path/platform-AMDI0010\:00-event';
const GESTURE_VERIF = [
'LR', // Left to Right
'RL', // Right to Left
'DU', // Down to Up
'UD', // Up to Down
'DLUR', // Down to Left to Up to Right (clockwise motion from Down)
'DRUL', // Down to Right to Up to Left (counter-clockwise from Down)
'URDL', // Up to Right to Down to Left (clockwise motion from Up)
'ULDR', // Up to Left to Down to Right (counter-clockwise from Up)
];
const EDGE_VERIF = [
'*', // any
'N', // none
'L', // left
'R', // right
'T', // top
'B', // bottom
'TL', // top left
'TR', // top right
'BL', // bottom left
'BR', // bottom right
];
const DISTANCE_VERIF = [
'*', // any
'S', // short
'M', // medium
'L', // large
];
class TouchGestures extends Service {
static {
Service.register(this, {
'daemon-started': ['boolean'],
'daemon-destroyed': ['boolean'],
});
}
gestures = new Map();
gestureDaemon = undefined;
get gestures() { return this.gestures; }
constructor() {
super();
}
addGesture({
name,
nFingers = '1',
gesture,
edge = '*',
distance = '*',
command,
} = {}) {
gesture = String(gesture).toUpperCase();
if (!GESTURE_VERIF.includes(gesture)) {
logError('Wrong gesture id');
return;
}
edge = String(edge).toUpperCase();
if (!EDGE_VERIF.includes(edge)) {
logError('Wrong edge id');
return;
}
distance = String(distance).toUpperCase();
if (!DISTANCE_VERIF.includes(distance)) {
logError('Wrong distance id');
return;
}
this.gestures.set(name, [
'-g',
`${nFingers},${gesture},${edge},${distance},${command}`,
]);
if (this.gestureDaemon)
this.killDaemon();
this.startDaemon();
}
startDaemon() {
if (this.gestureDaemon)
return;
var command = [
'lisgd', '-d', SCREEN,
// orientation
'-o', '0',
// Threshold of gesture recognized
'-t', '125',
// Leniency of gesture angle
'-r', '25',
// Timeout time
'-m', '3200',
];
this.gestures.forEach(gesture => {
command = command.concat(gesture);
});
this.gestureDaemon = subprocess(
command,
() => {},
err => logError(err),
);
this.emit('daemon-started', true);
}
killDaemon() {
if (this.gestureDaemon) {
this.gestureDaemon.force_exit();
this.gestureDaemon = undefined;
this.emit('daemon-destroyed', true);
}
}
}
const touchGesturesService = new TouchGestures();
export default touchGesturesService;

View file

@ -18,10 +18,6 @@ monitor=desc:Samsung Electric Company C27JG5x HTOM100586, 2560x1440@144, 1920x12
# Desc of monitor has comma, so force its default on everything and specify everything else # Desc of monitor has comma, so force its default on everything and specify everything else
monitor=, 2560x1440@144, 1920x1560, 1 monitor=, 2560x1440@144, 1920x1560, 1
exec-once = $HYPR_PATH/lisgd.sh &
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
# Execute your favorite apps at launch # Execute your favorite apps at launch
exec-once = bash -c "sleep 3; nm-applet" exec-once = bash -c "sleep 3; nm-applet"
exec-once = bash -c "sleep 4; blueberry-tray" exec-once = bash -c "sleep 4; blueberry-tray"

View file

@ -1,19 +0,0 @@
#!/usr/bin/env bash
## https://www.reddit.com/r/swaywm/comments/ocec7k/comment/i93s0ma/
## https://git.sr.ht/~mil/lisgd/tree/0.3.7/item/config.def.h
function gestures {
lisgd -d /dev/input/by-path/platform-AMDI0010\:00-event -o 0 -t 125 -r 25 -m 3200 \
-g "1,UD,B,*,R,bash -c 'busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false'" \
-g "1,DU,B,*,R,bash -c 'busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true'" \
-g "1,RL,R,*,R,bash -c 'hyprctl dispatch togglespecialworkspace spot'" \
-g "1,LR,R,*,R,bash -c 'hyprctl dispatch togglespecialworkspace spot'"
}
if pgrep lisgd ; then
killall -r lisgd
gestures
else
gestures
fi