summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdot/local/bin/thinkpad-rotate70
-rw-r--r--dot/xbindkeysrc8
2 files changed, 78 insertions, 0 deletions
diff --git a/dot/local/bin/thinkpad-rotate b/dot/local/bin/thinkpad-rotate
new file mode 100755
index 0000000..db44030
--- /dev/null
+++ b/dot/local/bin/thinkpad-rotate
@@ -0,0 +1,70 @@
1#!/bin/bash
2# This is a script that toggles rotation of the screen through xrandr,
3# and also toggles rotation of the stylus, eraser and cursor through xsetwacom
4
5query_screen()
6{
7 xrandr --verbose -q | while read screen conn p _ _ orientation _; do
8 [ "$conn" = connected -a "$p" = primary ] || continue
9 echo "$screen $orientation"
10 break
11 done
12}
13
14screen_properties=$(query_screen)
15orientation=${screen_properties#* }
16screen_name=${screen_properties% *}
17
18xrandr_to_xsetwacom()
19{
20 case "$1" in
21 normal) echo none ;;
22 right) echo cw ;;
23 inverted) echo half ;;
24 left) echo ccw ;;
25 esac
26}
27
28set_rotation()
29{
30 local x="$(xrandr_to_xsetwacom "$1")"
31 xrandr --output "${screen_name}" --rotate "$1"
32 xsetwacom set 14 Rotate "$x"
33 xsetwacom set 15 Rotate "$x"
34 xsetwacom set 16 Rotate "$x"
35}
36
37flip()
38{
39 case "$orientation" in
40 normal) set_rotation inverted ;;
41 right) set_rotation left ;;
42 inverted) set_rotation normal ;;
43 left) set_rotation right ;;
44 esac
45}
46
47rotate_right()
48{
49 case "$orientation" in
50 normal) set_rotation right ;;
51 right) set_rotation inverted ;;
52 inverted) set_rotation left ;;
53 left) set_rotation normal ;;
54 esac
55}
56
57if [ $# = 0 ]; then
58 flip
59 exit
60elif [ "$1" = rotate ]; then
61 rotate_right
62elif [ "$(xrandr_to_xsetwacom "$1")" ]; then
63 set_rotation "$1"
64else
65 exec >&2
66 echo "Usage: $0 [normal|right|inverted|left]"
67 echo
68 echo " With arguments, set the screen orientation."
69 echo " Without arguments, flip the screen orientation 180 degrees."
70fi
diff --git a/dot/xbindkeysrc b/dot/xbindkeysrc
index 26461f5..e5786e8 100644
--- a/dot/xbindkeysrc
+++ b/dot/xbindkeysrc
@@ -54,6 +54,14 @@
54"pavol --mute" 54"pavol --mute"
55 XF86AudioMute 55 XF86AudioMute
56 56
57"thinkpad-rotate"
58 XF86TaskPane
59"thinkpad-rotate rotate"
60 XF86RotateWindows
61"thinkpad-rotate normal"
62 XF86ScreenSaver
63
64
57# set directly keycode (here control + f with my keyboard) 65# set directly keycode (here control + f with my keyboard)
58#"xterm" 66#"xterm"
59# c:41 + m:0x4 67# c:41 + m:0x4