bin: invert script for touchscreen and stylus
Anirudh Oppiliappan x@icyphox.sh
Sun, 24 Apr 2022 11:56:12 +0530
2 files changed,
28 insertions(+),
0 deletions(-)
M
nix/bin/default.nix
→
nix/bin/default.nix
@@ -48,6 +48,9 @@ # uploader = import ./up.nix pkgs;
# battery script battery = import ./battery.nix pkgs; + + # invert screen + invert = import ./invert.nix pkgs; in [ git-new-push-remote@@ -58,4 +61,5 @@ record
battery bar xurls + invert ]
A
nix/bin/invert.nix
@@ -0,0 +1,24 @@
+{ pkgs, ... }: + +let + xrandr = "${pkgs.xorg.xrandr}/bin/xrandr"; + xinput = "${pkgs.xorg.xinput}/bin/xinput"; +in +pkgs.writeShellScriptBin "invert" + '' + orientation="$(${xrandr} --query --verbose | grep eDP | cut -d ' ' -f 6)" + if [[ "$orientation" == "normal" ]]; + then + echo "turning screen upside down..." + ${xrandr} -o inverted + ${xinput} set-prop 'ELAN9008:00 04F3:2C82' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1 + ${xinput} set-prop 'ELAN9008:00 04F3:2C82 Stylus Pen (0)' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1 + ${xinput} set-prop 'ELAN9008:00 04F3:2C82 Stylus Eraser (0)' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1 + else + echo "reverting back to normal..." + ${xrandr} -o normal + ${xinput} set-prop 'ELAN9008:00 04F3:2C82' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1 + ${xinput} set-prop 'ELAN9008:00 04F3:2C82 Stylus Pen (0)' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1 + ${xinput} set-prop 'ELAN9008:00 04F3:2C82 Stylus Eraser (0)' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1 + fi + ''