Tablet mode rotation script

This commit is contained in:
John Mertz 2023-04-11 19:51:46 -04:00
parent 6c466e6dc9
commit 2ff35c6d24
Signed by: jpm
GPG Key ID: E9C5EA2D867501AB
1 changed files with 48 additions and 0 deletions

48
thinkpad/tablet_mode.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/bash
ON=0
if [ -z $1 ]; then
#echo "Argument not provided. Detecting current orientation"
IN=''
for i in `swaymsg -pt get_outputs`; do
#echo $i
if [[ $i == 'Output' ]]; then
IN='OUTPUT'
#echo "Found Output key: $i"
elif [[ $IN == 'OUTPUT' ]]; then
#echo "Found Output: $i"
if [[ $i == 'eDP-1' ]]; then
IN='EDP1'
else
IN=''
fi
elif [[ $IN == 'EDP1' ]]; then
if [[ $i == 'Transform:' ]]; then
#echo "Found transform key: $i"
IN='TRANSFORM'
fi
elif [[ $IN == 'TRANSFORM' ]]; then
#echo "Found transform value: $i"
if [[ $i != 'normal' ]]; then
ON=1
#echo "Found non-default transform $i"
fi
break
fi
done
elif [[ $1 == 'on' ]]; then
ON=0
elif [[ $1 == 'off' ]]; then
ON=1
else
echo "Invalid argument '$1'. Either 'on', 'off' or no argument to toggle"
exit
fi
if [[ $ON == 0 ]]; then
#echo "Tablet mode is off, enabling..."
swaymsg output eDP-1 transform 270
else
#echo "Tablet mode is on, disabing..."
swaymsg output eDP-1 transform 0
fi