nixos-config/pkgs/eyezoom.nix

45 lines
1.0 KiB
Nix
Raw Normal View History

2024-09-15 19:45:05 +02:00
{ pkgs, ... }:
pkgs.writeScript "eyezoom" ''
2024-09-24 14:25:39 +02:00
arg="$1"
2024-09-15 19:45:05 +02:00
2024-09-24 14:25:39 +02:00
set -- $(
${pkgs.xorg.xrandr}/bin/xrandr |
${pkgs.gawk}/bin/awk -F "[x+ ]" '/primary/ { print $4" "$5" "$6" "$7 }'
)
W="$1"
H="$2"
offx="$3"
offy="$4"
2024-09-15 19:45:05 +02:00
2024-10-13 21:04:23 +02:00
ZH=16384
2024-10-23 14:47:52 +02:00
ZW=1920
2024-10-13 21:04:23 +02:00
WDIV=4
2024-09-15 19:45:05 +02:00
2024-09-24 12:40:56 +02:00
WIDEDIV=2
2024-10-13 21:37:11 +02:00
mouse="pointer:pulsar X2H Mini"
normalaccel=0
2024-10-23 14:47:52 +02:00
zoomaccel=-0.9
2024-09-24 17:43:56 +02:00
2024-09-24 14:25:39 +02:00
case "$arg" in
2024-09-15 19:45:05 +02:00
eye)
2024-10-23 14:47:52 +02:00
${pkgs.wmctrl}/bin/wmctrl -R ':ACTIVE:' -e 0,$(( offx - (ZW / 2) + (W / 2) )),$(( offy - (ZH / 2) + (H / 2) )),$ZW,$ZH
2024-10-18 21:00:14 +02:00
xinput set-prop "$mouse" "libinput Accel Speed" $zoomaccel
2024-09-15 19:45:05 +02:00
;;
tiktok)
2024-10-13 21:04:23 +02:00
${pkgs.wmctrl}/bin/wmctrl -R ':ACTIVE:' -e 0,$(( offx - ((W/WDIV)/2) + (W/2))),$offy,$((W/WDIV)),$H
2024-10-18 21:00:14 +02:00
xinput set-prop "$mouse" "libinput Accel Speed" $normalaccel
2024-09-24 12:40:56 +02:00
;;
wide)
${pkgs.wmctrl}/bin/wmctrl -R ':ACTIVE:' -e 0,$offx,$(( offy - ((H / WIDEDIV) / 2) + (H / 2) )),$W,$((H/WIDEDIV))
2024-10-18 21:00:14 +02:00
xinput set-prop "$mouse" "libinput Accel Speed" $normalaccel
2024-09-15 19:45:05 +02:00
;;
*)
2024-09-24 12:40:56 +02:00
${pkgs.wmctrl}/bin/wmctrl -R ':ACTIVE:' -e 0,$offx,$offy,$W,$H
2024-10-18 21:00:14 +02:00
xinput set-prop "$mouse" "libinput Accel Speed" $normalaccel
2024-09-15 19:45:05 +02:00
;;
esac
''