-
Notifications
You must be signed in to change notification settings - Fork 1
/
dock.menu
executable file
·51 lines (40 loc) · 1.12 KB
/
dock.menu
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
#!/bin/bash
# choose display setting
notify(){
notify-send -a "dock" -i "computer" "$1" "$2"
}
readarray -t connected < <(xrandr | grep " connected " | cut -d" " -f1)
[[ "${#connected[@]}" -lt 1 ]] && notify "No monitors connected" && exit
internal="${connected[0]}"
external(){
[[ "${#connected[@]}" -le 1 ]] && notify "No external monitors connected" && exit
echo "${connected[-1]}"
}
layout="$( \
awk '/^case/,/^esac/' "$0" |
grep -E "^\s*[a-zA-Z0-9-]*)$" |
sed -E 's/[ \)]//g' |
dmenu -i -l 20 -p "Monitor Layout")"
[[ "$layout" ]] || exit
case "$layout" in
dock)
xrandr --output "$(external)" --auto --output "$internal" --off
;;
dock-1440p)
xrandr --output "$(external)" --mode 2560x1440 --output "$internal" --off
;;
undock)
xrandr --output "$internal" --auto --output "$(external)" --off
;;
mirror)
xrandr --output "$(external)" --auto --same-as "$internal"
;;
*)
echo "Invalid layout"
exit
esac
notify "$layout"
killall --quiet thonkbar lemonbar
thonkbar &
wall --rng
# vim: set ft=bash: