-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetmonitorposition
More file actions
executable file
·43 lines (37 loc) · 1.04 KB
/
setmonitorposition
File metadata and controls
executable file
·43 lines (37 loc) · 1.04 KB
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
#!/bin/bash
# DESCRIPTION: Set position of a monitor relative to others.
# DEPENDENCIES: dmenu xrandr
[ -n "$1" ] && subjectmon="$1"
MONITORS=( $(xrandr -q | awk '$2 == "connected" {print $1}') )
in_MONITORS ()
{
# Empty input: trivially not in monitors.
[ -z "$1" ] && return 1
local m
for m in "${MONITORS[@]}"; do
if [ "$1" = "$m" ]; then
# Found.
return 0
fi
done
return 1
}
if ! in_MONITORS "$subjectmon"; then
mon="$(for m in "${MONITORS[@]}"; do echo "$m"; done |
dmenu -l 20 -p 'Which monitor to change?')" || exit 1
else
mon="$subjectmon"
fi
[ -z "$mon" ] && exit 1
relativetomon="$(for m in "${MONITORS[@]}"; do [ "$m" != "$mon" ] && echo "$m"; done |
dmenu -l 20 -p "$mon: Which monitor to position relative to?")" || exit 1
[ -z "$relativetomon" ] && exit 1
position="$(cat <<'EOF' | dmenu -l 20 -p "$mon->$relativetomon: Which position?"
left-of
right-of
above
below
same-as
EOF
)"
xrandr --output "$mon" --auto --"$position" "$relativetomon" && notify-send -t 5000 monitor_position "Set '$mon' ${position/-/ } '$relativetomon'"