Created
November 12, 2013 16:22
-
-
Save powerswitch/7433766 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# rotate the screen depending on notebook position | |
# need: xrotate script, thinkpad_acpi, tp_smapi | |
export DISPLAY=":0" | |
DISPLAY=:0 | |
x=$(sed "s_(\([-0-9]\+\),.*)_\1_" /sys/devices/platform/hdaps/position) | |
y=$(sed "s_(.*,\([-0-9]\+\))_\1_" /sys/devices/platform/hdaps/position) | |
tablet=$(cat /sys/devices/platform/thinkpad_acpi/hotkey_tablet_mode) | |
x=$(($x-512)) | |
y=$(($y+512)) | |
echo "X-Achse: $x, Y-Achse: $y, Tablet mode: $tablet" | |
if [ $tablet -eq 1 ]; then | |
echo $(($x+$y)) | |
if [ $x -gt $y ] && [ $(($x+$y)) -lt -20 ]; then xrotate 0 | |
elif [ $x -gt $y ] && [ $(($x+$y)) -gt 20 ]; then xrotate 3 | |
elif [ $x -le $y ] && [ $(($x+$y)) -lt -20 ]; then xrotate 1 | |
elif [ $x -le $y ] && [ $(($x+$y)) -gt 20 ]; then xrotate 2 | |
else xrotate 0 | |
fi | |
else | |
xrotate 0 | |
fi | |
# x y | |
# 0 normal: 0 -150 | |
# 1 links: -150 0 | |
# 2 umgekehrt: 0 150 | |
# 3 rechts: 150 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment