-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcycle_monitor.sh
More file actions
executable file
·75 lines (60 loc) · 1.82 KB
/
Copy pathcycle_monitor.sh
File metadata and controls
executable file
·75 lines (60 loc) · 1.82 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
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
#!/usr/bin/env bash
# Set the laptop monitor to a lower resolution
EXTERNAL_OUTPUT="DP-3-1"
HDMI_OUTPUT="HDMI-1"
INTERNAL_OUTPUT="eDP-1"
monitor_mode=`i3-input -P "Monitor config: " | grep -oP '(?<=command\ =\ )(\w*)'`
# # if we don't have a file, start at zero
# if [ ! -f "/tmp/monitor_mode.dat" ] ; then
# monitor_mode="laptop"
# # otherwise read the value from the file
# else
# monitor_mode=`cat /tmp/monitor_mode.dat`
# fi
if [ $monitor_mode = "office" ]; then
xrandr --output $INTERNAL_OUTPUT \
--scale 1x1 \
--mode 1360x768 \
--output $EXTERNAL_OUTPUT \
--primary \
--auto \
--dpi 109 \
--left-of $INTERNAL_OUTPUT
sed -i '6s/.*/Xft.dpi: 108/' ~/.Xdefaults
fi
if [ $monitor_mode = "laptop" ]; then
xrandr --output $INTERNAL_OUTPUT \
--auto \
--primary \
--dpi 209.8 \
--output $EXTERNAL_OUTPUT \
--off
sed -i '6s/.*/Xft.dpi: 170/' ~/.Xdefaults
fi
if [ $monitor_mode = "home" ]; then
xrandr --output $INTERNAL_OUTPUT \
--scale 1x1 \
--mode 1360x768 \
--output $HDMI_OUTPUT \
--mode 1920x1200 \
--primary \
--auto \
--dpi 109 \
--left-of $INTERNAL_OUTPUT
sed -i '6s/.*/Xft.dpi: 96/' ~/.Xdefaults
fi
# Reload the config and restart i3...
xrdb -merge ~/.Xdefaults
sleep 1
i3-msg reload
sleep 1
i3-msg restart
sleep 2
# ...Very specific to this setup...
# Reloads the BG images so they fit properly
# after a resolution/DPI change
feh --bg-fill --randomize ~/Pictures/Desktops/*
# Notify what monitor mode we just switched to...
notify-send -u low "Monitor mode changed!" "Monitor set to <b><i>${monitor_mode}</i></b>."
# Store it for no good reason...
echo "${monitor_mode}" > /tmp/monitor_mode.dat