-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathis-dark-mode
executable file
·30 lines (27 loc) · 980 Bytes
/
is-dark-mode
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
#!/bin/bash
set -u -o pipefail
# https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.portal.Settings
if command -v dbus-send >/dev/null; then
if setting=$(dbus-send \
--session \
--print-reply=literal \
--reply-timeout=1000 \
--dest=org.freedesktop.portal.Desktop \
/org/freedesktop/portal/desktop \
org.freedesktop.portal.Settings.Read \
string:'org.freedesktop.appearance' \
string:'color-scheme' | awk '{ print $4 }'); then
if [[ $setting == 1 ]]; then
exit 0
else
exit 1
fi
fi
fi
if command -v gsettings >/dev/null; then
[[ $(gsettings get org.gnome.desktop.interface color-scheme) == \'prefer-dark\' ]]
elif command -v defaults >/dev/null; then
[[ $(defaults read -g AppleInterfaceStyle 2>/dev/null) == "Dark" ]]
else
exit 0
fi