-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdarkmode
executable file
·43 lines (37 loc) · 882 Bytes
/
darkmode
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
#!/usr/bin/env bash
# darkmode -- Toggle between light/dark mode in GNOME
setbacklight() {
local light_mode=$1
case $HOSTNAME in
midnight)
local hi=3043 lo=743 dev=intel_backlight;;
*)
return;;
esac
local path=/sys/class/backlight/${dev?}/brightness
local current=$(< $path)
if (( light_mode && current < hi )); then
sudo sh -c "echo $hi > $path"
elif (( !light_mode && current > lo )); then
sudo sh -c "echo $lo > $path"
fi
}
schema=org.gnome.desktop.interface
key=color-scheme
value="'prefer-dark'"
case $(gsettings get $schema $key) in
"$value")
setbacklight 1 &
gsettings reset $schema $key
text=disabled;;
*)
setbacklight 0 &
gsettings set $schema $key "$value"
text=enabled;;
esac
if [ -t 1 ]; then
echo "Dark Mode has been $text."
else
notifysend -r hotkey -e -i "dark-mode-symbolic" \
"Dark Mode" "Dark Mode has been $text."
fi