Add notification toggle

Amolith created

Change summary

dot_config/polybar/config.ini.tmpl                   | 19 +++++++++++--
dot_config/polybar/executable_notification-toggle.sh | 13 +++++++++
2 files changed, 28 insertions(+), 4 deletions(-)

Detailed changes

dot_config/polybar/config.ini.tmpl 🔗

@@ -30,7 +30,7 @@ font-1 = "JetBrainsMono NF:style=Regular:size=12;2"
 modules-left = i3
 modules-center = xwindow
 {{- if ne .chezmoi.hostname "glade" }}
-modules-right = updates caffeine wlan mic pulseaudio cpu memory date time {{ if eq .chezmoi.hostname "sidhe" }}battery{{ end }}
+modules-right = updates caffeine notifications mic pulseaudio cpu memory date time {{ if eq .chezmoi.hostname "sidhe" }}battery{{ end }}
 {{- else }}
 modules-right = wlan pulseaudio cpu memory date battery
 {{- end }}
@@ -209,8 +209,9 @@ format-volume = <ramp-volume> <label-volume>
 label-volume =  %percentage%%
 label-volume-foreground = ${root.foreground}
 
-label-muted = 󰝟
-label-muted-foreground = ${colors.foreground-alt}
+label-muted = " 󰝟 "
+label-muted-foreground = ${colors.background}
+label-muted-background = ${colors.primary}
 
 ramp-volume-0 = "󰕿"
 ramp-volume-1 = "󰖀"
@@ -237,8 +238,18 @@ format = <label>
 [module/mic]
 type = custom/script
 exec = ~/.config/polybar/mic-toggle.sh
-interval = 1
 click-left = ~/.config/polybar/mic-toggle.sh toggle
+interval = 1
+
+env-color_background = ${colors.background}
+env-color_primary = ${colors.primary}
+env-color_foreground = ${colors.foreground}
+
+[module/notifications]
+type = custom/script
+exec = ~/.config/polybar/notification-toggle.sh
+click-left = ~/.config/polybar/notifications.sh toggle
+interval = 1
 
 env-color_background = ${colors.background}
 env-color_primary = ${colors.primary}

dot_config/polybar/executable_notification-toggle.sh 🔗

@@ -0,0 +1,13 @@
+#!/bin/bash
+
+if [ "$1" = "toggle" ]; then
+    dunstctl set-paused toggle
+fi
+
+is_paused=$(dunstctl is-paused)
+
+if [ "$is_paused" = "true" ]; then
+    echo "%{F${color_background}}%{B${color_primary}} 󰂛 %{B- F-}"
+else
+    echo "%{F${color_foreground}}%{B${color_background}} 󰂚 %{B- F-}"
+fi