blob: 679a7df58242c7c2c9ffad0242ba3d9a727bd14d (
plain) (
blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#!/bin/bash
# External monitor manager:
# Profiles are hardcoded to automate connection to know setups. Using
# `--list` flag it will list all connected external monitors with
# relevant info.
MAIN="LVDS-1"
declare -A CONNECTED
while read -r port edid; do
if [[ $port != $MAIN ]]; then
CONNECTED+=( ["$port"]="$edid" )
fi
done < <(xrandr --prop | awk '
!/^[ \t]/ {
if (port && edid) print port, edid
port=$1
edid=""
}
/[:.]/ && rec {
sub(/.*000000fc00/, "", edid)
edid = substr(edid, 0, 26) "0a"
sub(/0a.*/, "", edid)
rec=0
}
rec {
sub(/[ \t]+/, "")
edid = edid $0
}
/EDID.*:/ {
rec=1
}
')
if [ "$#" -gt 0 ] && [ "$1" == "--list" ]; then
for i in "${!CONNECTED[@]}"
do
brand=$(xxd -r -p <<< "${CONNECTED[$i]}")
echo -e "$i:\t${CONNECTED[$i]}\t($brand)"
done
else
ACTIVE=$(xrandr --listactivemonitors | awk '/^[ \t]/ { print $4 }')
# Office config
# VGA-1: 44454c4c20503233313748 (DELL P2317H)
# DP-2: 44454c4c2055323431324d (DELL U2412M)
PROFILE="OFFICE"
if [[ ${CONNECTED["VGA-1"]} == "44454c4c20503233313748" ]] && [[ ${CONNECTED["DP-2"]} == "44454c4c2055323431324d" ]]; then
if grep -qs "VGA-1" <<< "$ACTIVE"; then
xrandr --output VGA-1 --off --output LVDS-1 --auto --output DP-2 --off
notify-send "$PROFILE profile: OFF"
else
notify-send "$PROFILE profile: ON"
xrandr --output VGA-1 --auto --rotate left --output DP-2 --auto --right-of VGA-1 --output LVDS-1 --off
fi
exit 0
fi
# Home config
# VGA-1: 44454c4c20503232313148 (DELL P2211H)
# DP-2: 44454c4c2055323431324d (DELL U2412M)
PROFILE="HOME"
if [[ ${CONNECTED["VGA-1"]} == "44454c4c2055323431324d" ]]; then
if grep -qs "VGA-1" <<< "$ACTIVE"; then
xrandr --output VGA-1 --off --output LVDS-1 --auto
notify-send "$PROFILE profile: OFF"
else
notify-send "$PROFILE profile: ON"
xrandr --output VGA-1 --auto --output LVDS-1 --auto --left-of VGA-1
fi
exit 0
fi
notify-send "No matching monitor profile!"
fi
|