This repository has been archived by the owner on May 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrotate-screen.sh
57 lines (57 loc) · 1.82 KB
/
rotate-screen.sh
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
monitor-sensor --accel| while read -r line; do
if [[ $line =~ "orientation" ]]; then
if [[ $line =~ "changed" ]]; then
newOr=$(echo $line | grep -o -E "changed:.*" | sed "s/changed: //");
else
oldOr=$(echo $line | grep -o -E "orientation: [^\)]*" | sed "s/orientation: //");
fi;
echo "$oldOr -> $newOr";
if [[ -n $newOr ]]; then
if [[ $oldOr == "normal" ]]; then
if [[ $newOr == "right-up" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1..3})
fi;
if [[ $newOr == "left-up" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1})
fi;
if [[ $newOr == "bottom-up" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1..2})
fi;
fi;
if [[ $oldOr == "left-up" ]]; then
if [[ $newOr == "normal" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1..3})
fi;
if [[ $newOr == "bottom-up" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1})
fi;
if [[ $newOr == "right-up" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1..4})
fi;
fi;
if [[ $oldOr == "bottom-up" ]]; then
if [[ $newOr == "left-up" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1..3})
fi;
if [[ $newOr == "right-up" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1})
fi;
if [[ $newOr == "normal" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1..2})
fi;
fi;
if [[ $oldOr == "right-up" ]]; then
if [[ $newOr == "bottom-up" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1..3})
fi;
if [[ $newOr == "normal" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1})
fi;
if [[ $newOr == "left-up" ]]; then
ydotool key $(printf '29:1 66:1 66:0 29:0 %.0s' {1..2})
fi;
fi;
oldOr=$newOr;
fi;
fi; done