-
Notifications
You must be signed in to change notification settings - Fork 1
/
disp_config.sh
executable file
·65 lines (48 loc) · 2.43 KB
/
disp_config.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
58
59
60
61
62
63
64
65
#!/bin/sh
xrandr --auto
DUPLICATE="xrandr --output eDP1 --mode 1920x1080 --pos 0x0 --rotate normal --output DP1 --off --output HDMI1 --mode 1920x1080 --pos 0x0 --rotate normal --output VIRTUAL1 --off"
LAPTOPDOWN="xrandr --output eDP1 --mode 1600x900 --pos 160x1080 --rotate normal --output DP1 --off --output HDMI1 --mode 1920x1080 --pos 0x0 --rotate normal --output VIRTUAL1 --off"
LAPTOPRIGHT="xrandr --output eDP1 --mode 1600x900 --pos 1920x90 --rotate normal --output DP1 --off --output HDMI1 --mode 1920x1080 --pos 0x0 --rotate normal --output VIRTUAL1 --off"
ONE="xrandr --output eDP1 --mode 1920x1080 --pos 0x0 --rotate normal --output DP1 --off --output HDMI1 --off --output VIRTUAL1 --off"
LAPTOPLEFT="xrandr --output eDP1 --mode 1600x900 --pos 0x90 --rotate normal --output DP1 --off --output HDMI1 --mode 1920x1080 --pos 1600x0 --rotate normal --output VIRTUAL1 --off"
INVERTED="xrandr --output eDP1 --mode 1920x1080 --pos 0x0 --rotate inverted --output DP1 --off --output HDMI1 --off --output VIRTUAL1 --off"
LEFTINVERTED="xrandr --output eDP1 --mode 1600x900 --pos 1080x554 --rotate normal --output DP1 --off --output HDMI1 --mode 1920x1080 --pos 0x0 --rotate right --output VIRTUAL1 --off"
case "$1" in
-dup)
# Duplicate monitors.
$DUPLICATE &&
echo "Duplicating two monitors."
;;
-two)
# Two monitors.
$LAPTOPRIGHT && echo "Configuring 2 displays."
;;
-one)
$ONE && echo "Configuring single display."
;;
-up)
# HDMI2 up, monitor down.
$LAPTOPDOWN && echo "Configuring 2 displays."
;;
-inv)
# Sometimes useful when your laptop screen goes 360 degrees.
$INVERTED && echo "Configuring inverted screen."
;;
*)
# Check if laptop lid is open or close. Act according to that.
# If lid is open, configure right-left display, or else duplicate.
cat /proc/acpi/button/lid/LID/state | grep 'open' >/dev/null
STATE="$?"
if [ "$STATE" = '0' ]; then
xrandr | grep 'HDMI. connected' >/dev/null
STATE="$?"
if [ "$STATE" = '0' ]; then
$LAPTOPRIGHT && echo "Configuring 2 displays."
else
$ONE && echo "Configuring single display."
fi
else
$DUPLICATE && echo "Configuring duplicate display."
fi
;;
esac