-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange-bright
executable file
·84 lines (75 loc) · 1.63 KB
/
change-bright
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
78
79
80
81
82
83
84
#!/usr/bin/zsh
# adjust brightness levels
# support for a laptop and one external monitor through xrandr brightness
# occasionally it takes a while to run xbacklight after xrandr, is prob kernel issue
# change this to match your external monitor's name.
# if you don't know it, run `xrandr | grep 'connected | grep -v 'dis'`
extConnected=false
extMonitor=HDMI-0
extStatus="$(xrandr | awk "/$extMonitor/"'{print $2}')"
backlight="$(xbacklight)"
if [[ "${extStatus}" == connected ]]; then
extBright=$(xrandr --verbose |
grep -A5 "${extMonitor}" |
awk -F' ' '/Brightness/{print $2}')
extConnected=true
fi
lower() {
# lower brightness of laptop brightness and ext monitor
if [[ -n "${extConnected}" ]]; then
if ((extBright > 0.2)); then
xrandr --output "${extMonitor}" --brightness "$((extBright - 0.05))"
fi
fi
if ((backlight > 20)); then
xbacklight -dec 5
fi
return
}
raise() {
# raise brightness of laptop and ext monitor
if [[ -n "${extConnected}" ]]; then
if ((extBright <= 1.0)); then
xrandr --output "${extMonitor}" --brightness "$((extBright + 0.05))"
fi
fi
if ((backlight <= 100)); then
xbacklight -inc 5
fi
return
}
min() {
# set monitors to lowest brightness
if [[ -n "${extConnected}" ]]; then
xrandr --output "${extMonitor}" --brightness 0.2
fi
xbacklight -set 20
}
max() {
# set monitors to highest brightness
if [[ -n "${extConnected}" ]]; then
xrandr --output "${extMonitor}" --brightness 1.0
fi
xbacklight -set 100
}
main() {
case "$1" in
lower)
lower
;;
raise)
raise
;;
min)
min
;;
max)
max
;;
*)
echo "Takes options for: lower, raise, min, max"
;;
esac
}
main "$@"
exit 0