Skip to content

Instantly share code, notes, and snippets.

@powerswitch
Created November 12, 2013 16:22
Show Gist options
  • Save powerswitch/7433766 to your computer and use it in GitHub Desktop.
Save powerswitch/7433766 to your computer and use it in GitHub Desktop.
#!/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