-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautorotate
executable file
·36 lines (33 loc) · 954 Bytes
/
autorotate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
# inspired by
# https://gist.github.com/Migacz85/3f544933ce5add438555ba7cd33f0413
#
# uses screen (output) for my HP Spectre 13-ap0059dx. Check `swaymsg
# -t get_outputs` for your laptop's screen.
#
# put map_to_output statements in the sway config file so the
# input devices (touch screen, stylus) rotate as well, for example:
#
# input type:touch {
# map_to_output eDP-1
# }
#
# # stylus:
# input type:tablet_tool {
# map_to_output eDP-1
# }
monitor-sensor | while read -r line
do
if [ "$line" = "Accelerometer orientation changed: left-up" ]; then
swaymsg output eDP-1 transform 270
fi
if [ "$line" = "Accelerometer orientation changed: right-up" ]; then
swaymsg output eDP-1 transform 90
fi
if [ "$line" = "Accelerometer orientation changed: bottom-up" ]; then
swaymsg output eDP-1 transform 180
fi
if [ "$line" = "Accelerometer orientation changed: normal" ]; then
swaymsg output eDP-1 transform 0
fi
done