-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetmon-autorandr
executable file
·40 lines (34 loc) · 960 Bytes
/
setmon-autorandr
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
#!/bin/sh
# Arrange displays in a somewhat sensible way. Use autorandr to set
# configuration.
connectedOutputs=($(xrandr | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/"))
connectedNumber="${#connectedOutputs[@]}"
if [[ $connectedNumber -eq 1 ]]; then
echo "Only one display was found, '$connectedOutputs'."
autorandr default
exit 0
fi
currentProfile=($(autorandr 2>&1 | grep "(current)" |cut -d " " -f1))
currentProfile="${currentProfile[0]}"
case "$currentProfile" in
"default" | "laptop")
echo "using default/linux, switching to both"
autorandr both
exit 0
;;
"both")
echo "using both, switching to external"
autorandr external
exit 0
;;
"external")
echo "using external, switching to default"
autorandr default
exit 0
;;
*)
echo "using other, '$currentProfile', switching to default"
autorandr default
exit 0
;;
esac