nixos-config/pkgs/eyezoom.nix

35 lines
732 B
Nix

{ pkgs, ... }:
pkgs.writeScript "eyezoom" ''
arg="$1"
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"
HFACTOR=10
WFACTOR=4
WIDEDIV=2
case "$arg" in
eye)
${pkgs.wmctrl}/bin/wmctrl -R ':ACTIVE:' -e 0,$offx,$(( offy - (H * HFACTOR / 2) + (H / 2) )),$W,$((H*HFACTOR))
;;
tiktok)
${pkgs.wmctrl}/bin/wmctrl -R ':ACTIVE:' -e 0,$(( offx - ((W/WFACTOR)/2) + (W/2))),$offy,$((W/WFACTOR)),$H
;;
wide)
${pkgs.wmctrl}/bin/wmctrl -R ':ACTIVE:' -e 0,$offx,$(( offy - ((H / WIDEDIV) / 2) + (H / 2) )),$W,$((H/WIDEDIV))
;;
*)
${pkgs.wmctrl}/bin/wmctrl -R ':ACTIVE:' -e 0,$offx,$offy,$W,$H
;;
esac
''