all repos — dotfiles @ c552090ad3a1237e9fbfd329d8b510527c6643af

my *nix dotfiles

bin: invert script for touchscreen and stylus
Anirudh Oppiliappan x@icyphox.sh
Sun, 24 Apr 2022 11:56:12 +0530
commit

c552090ad3a1237e9fbfd329d8b510527c6643af

parent

048c68b8fcf5609225e9c14b8904688b1bcd1412

2 files changed, 28 insertions(+), 0 deletions(-)

jump to
M nix/bin/default.nixnix/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 + ''