From 7fb7a4e980e358bbba7ab0dc33a2fc0b6ffb5489 Mon Sep 17 00:00:00 2001 From: Luca Leon Happel Date: Mon, 29 Aug 2022 22:26:14 +0200 Subject: [PATCH] fixed input disableing --- autoscreenrotation.sh | 58 ++++++++----------------------------------- disableInput.sh | 21 ++++++++++++++++ enableInput.sh | 18 ++++++++++++++ flake.nix | 5 ++++ 4 files changed, 55 insertions(+), 47 deletions(-) create mode 100644 disableInput.sh create mode 100644 enableInput.sh diff --git a/autoscreenrotation.sh b/autoscreenrotation.sh index d137eec..cf2c763 100755 --- a/autoscreenrotation.sh +++ b/autoscreenrotation.sh @@ -4,42 +4,6 @@ # @DATE : 2021-11-07 So 19:12 32 # -####################################### -# Enable keyboard and touchpad -####################################### -function enableInput() { - for id in $(xinput --list | sed -n '/.*Touchpad/s/.*=\([0-9]\+\).*/\1/p') - do - xinput --enable $id - done - for id in $(xinput --list | sed -n '/.*Mouse/s/.*=\([0-9]\+\).*/\1/p') - do - xinput --enable $id - done - for id in $(xinput --list | sed -n '/.*Keyboard/s/.*=\([0-9]\+\).*/\1/p') - do - xinput --enable $id - done -} - -####################################### -# Disable keyboard and touchpad -####################################### -function disableInput() { - for id in $(xinput --list | sed -n '/.*Touchpad/s/.*=\([0-9]\+\).*/\1/p') - do - xinput --disable $id - done - for id in $(xinput --list | sed -n '/.*Mouse/s/.*=\([0-9]\+\).*/\1/p') - do - xinput --disable $id - done - for id in $(xinput --list | sed -n '/.*Keyboard/s/.*=\([0-9]\+\).*/\1/p') - do - xinput --disable $id - done -} - ####################################### # This function is called each time `motion-sensor` writes to stdout. # Also, some config files affect this function. @@ -58,35 +22,35 @@ function processnewcommand { case $1 in "Accelerometer orientation changed: normal") echo "screen rotated to normal" + screenrotation.sh "normal" if ( ( $( cat ~/.config/disableinput ) = "true" ) ) then - enableInput + enableInput.sh fi - screenrotation.sh "normal" ;; "Accelerometer orientation changed: bottom-up") echo "screen rotated to inverted" - if ( ( $( cat ~/.config/disableinput ) = "false" ) ) + screenrotation.sh "inverted" + if ( ( $( cat ~/.config/disableinput ) = "true" ) ) then - disableInput + disableInput.sh fi - screenrotation.sh "inverted" ;; "Accelerometer orientation changed: left-up") echo "screen rotated to left" - if ( ( $( cat ~/.config/disableinput ) = "false" ) ) + screenrotation.sh "left" + if ( ( $( cat ~/.config/disableinput ) = "true" ) ) then - disableInput + disableInput.sh fi - screenrotation.sh "left" ;; "Accelerometer orientation changed: right-up") echo "screen rotated to right" - if ( ( $( cat ~/.config/disableinput ) = "false" ) ) + screenrotation.sh "right" + if ( ( $( cat ~/.config/disableinput ) = "true" ) ) then - disableInput + disableInput.sh fi - screenrotation.sh "right" ;; esac } diff --git a/disableInput.sh b/disableInput.sh new file mode 100644 index 0000000..db61a86 --- /dev/null +++ b/disableInput.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# @AUTHOR: Luca Leon Happel +# + +####################################### +# Disable keyboard and touchpad +####################################### +echo "Disabling keyboard and touchpad" +for id in $(xinput --list | sed -n '/.*Touchpad/s/.*=\([0-9]\+\).*/\1/p') +do + xinput --disable $id +done +for id in $(xinput --list | sed -n '/.*Mouse/s/.*=\([0-9]\+\).*/\1/p') +do + xinput --disable $id +done +for id in $(xinput --list | sed -n '/.*Keyboard/s/.*=\([0-9]\+\).*/\1/p') +do + xinput --disable $id +done diff --git a/enableInput.sh b/enableInput.sh new file mode 100644 index 0000000..801e1a2 --- /dev/null +++ b/enableInput.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# @AUTHOR: Luca Leon Happel +# + +echo "Enabling keyboard and touchpad" +for id in $(xinput --list | sed -n '/.*Touchpad/s/.*=\([0-9]\+\).*/\1/p') +do + xinput --enable $id +done +for id in $(xinput --list | sed -n '/.*Mouse/s/.*=\([0-9]\+\).*/\1/p') +do + xinput --enable $id +done +for id in $(xinput --list | sed -n '/.*Keyboard/s/.*=\([0-9]\+\).*/\1/p') +do + xinput --enable $id +done diff --git a/flake.nix b/flake.nix index b404c13..e7388f9 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,11 @@ chmod +x $out/bin/toggleautoscreenrotation.sh cp ./toggledisableinput.sh $out/bin/ chmod +x $out/bin/toggledisableinput.sh + + cp ./enableInput.sh $out/bin/ + chmod +x $out/bin/enableInput.sh + cp ./disableInput.sh $out/bin/ + chmod +x $out/bin/disableInput.sh ''; }; }