Skip to content

Commit

Permalink
fixed input disableing
Browse files Browse the repository at this point in the history
  • Loading branch information
Quoteme committed Aug 29, 2022
1 parent 4db5b99 commit 7fb7a4e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 47 deletions.
58 changes: 11 additions & 47 deletions autoscreenrotation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Expand Down
21 changes: 21 additions & 0 deletions disableInput.sh
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions enableInput.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
};
}
Expand Down

0 comments on commit 7fb7a4e

Please sign in to comment.