feat: add a indicator for light/dark mode in waybar

This commit is contained in:
Bruno Carlin 2025-02-11 15:23:05 +01:00
parent 1d62e2150e
commit 0ed10feb6e
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 8E254EA0FFEB9B6D
3 changed files with 32 additions and 0 deletions

View file

@ -17,6 +17,7 @@
"modules-right": [ "modules-right": [
"idle_inhibitor", "idle_inhibitor",
"custom/ddcbrightness", "custom/ddcbrightness",
"custom/light-dark-mode",
"pulseaudio", "pulseaudio",
"network", "network",
"bluetooth", "bluetooth",
@ -210,5 +211,16 @@
"format-ok": "", "format-ok": "",
"system": true, // Monitor failed systemwide units. "system": true, // Monitor failed systemwide units.
"user": true // Ignore failed user units. "user": true // Ignore failed user units.
},
"custom/light-dark-mode": {
"exec": "/home/bca/.config/waybar/darkman",
"return-type": "json",
"format": "{icon}",
"tooltip": true,
"on-click": "darkman toggle",
"format-icons": {
"light": " ",
"dark": " "
}
} }
} }

19
waybar/.config/waybar/darkman Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
# vim: ft=bash
print_json() {
case "$1" in
prefer-dark)
echo '{"text": "dark", "alt": "dark", "class": "dark", "tooltip": "Dark mode"}'
;;
prefer-light)
echo '{"text": "light", "alt": "light", "class": "light", "tooltip": "Light mode"}'
;;
esac
}
print_json "$(gsettings get org.gnome.desktop.interface color-scheme | cut -nd"'" -f 2)"
gsettings monitor org.gnome.desktop.interface color-scheme | while read -r l; do
print_json "$(echo "$l" | cut -d"'" -f 2)"
done

View file

@ -97,6 +97,7 @@ button:hover {
#idle_inhibitor, #idle_inhibitor,
#scratchpad, #scratchpad,
#power-profiles-daemon, #power-profiles-daemon,
#customcustom-light-dark-mode,
#custom-ddcbrightness, #custom-ddcbrightness,
#idle_inhibitor, #idle_inhibitor,
#mpd { #mpd {