From 5e04c8685d1eabad10d29b10d55dbecbb2d17315 Mon Sep 17 00:00:00 2001 From: Sravan Balaji Date: Sun, 29 Sep 2024 21:10:43 -0400 Subject: [PATCH] Add dunst modules in a drawer group --- README.org | 120 +++++++++++++++++++++++++++++++++------- waybar/config.jsonc | 43 +++++++++++++- waybar/scripts/dunst.sh | 9 +++ waybar/style.css | 17 ++++++ 4 files changed, 169 insertions(+), 20 deletions(-) create mode 100755 waybar/scripts/dunst.sh diff --git a/README.org b/README.org index d37bcab..655c34a 100644 --- a/README.org +++ b/README.org @@ -42,15 +42,16 @@ - [[#configuration-1][Configuration]] - [[#styling][Styling]] - [[#modules][Modules]] - - [[#battery][battery]] - - [[#cpu][cpu]] - - [[#clock][clock]] - - [[#custompower-menu][custom/power-menu]] - - [[#dwltags][dwl/tags]] - - [[#disk][disk]] - - [[#memory][memory]] - - [[#pulseaudio][pulseaudio]] - - [[#tray][tray]] + - [[#battery][Battery]] + - [[#cpu][CPU]] + - [[#clock][Clock]] + - [[#dunst][Dunst]] + - [[#power-menu][Power Menu]] + - [[#dwl][dwl]] + - [[#disk][Disk]] + - [[#memory][Memory]] + - [[#pulseaudio][Pulseaudio]] + - [[#tray][Tray]] - [[#end-configuration][End Configuration]] - [[#justfile][Justfile]] @@ -540,8 +541,23 @@ sleep 5 "memory", "disk", "battery", - "clock" + "clock", + "group/dunst", ], + "group/dunst": { + "orientation": "horizontal", + "modules": [ + "custom/dunst-status", + "custom/dunst-history-view", + "custom/dunst-clear", + "custom/dunst-history-clear", + ], + "drawer": { + "transition-duration": 500, + "transition-left-to-right": true, + "click-to-reveal": false, + }, + }, #+END_SRC *** Styling @@ -561,7 +577,7 @@ window#waybar { ** Modules -*** battery +*** Battery **** Configuration @@ -584,7 +600,7 @@ window#waybar { } #+END_SRC -*** cpu +*** CPU **** Configuration @@ -605,7 +621,7 @@ window#waybar { } #+END_SRC -*** clock +*** Clock **** Configuration @@ -625,7 +641,73 @@ window#waybar { } #+END_SRC -*** custom/power-menu +*** Dunst + +**** Configuration + +#+BEGIN_SRC jsonc :tangle waybar/config.jsonc + "custom/dunst-status": { + "exec": "~/.config/dwl/waybar/scripts/dunst.sh", + "restart-interval": 1, + "on-click": "~/.scripts/dunst.sh --dnd", + "on-click-right": "~/.scripts/dunst.sh --rofi", + "tooltip": false, + }, + "custom/dunst-clear": { + "format": "", + "on-click": "~/.scripts/dunst.sh --close-all", + "tooltip": true, + "tooltip-format": "Close Open Notifications", + }, + "custom/dunst-history-view": { + "format": "󰋚", + "on-click": "~/.scripts/dunst.sh --history", + "tooltip": true, + "tooltip-format": "View Notification History", + }, + "custom/dunst-history-clear": { + "format": "󰎟", + "on-click": "~/.scripts/dunst.sh --history-clear", + "tooltip": true, + "tooltip-format": "Clear Notification History", + }, +#+END_SRC + +**** Styling + +#+BEGIN_SRC css :tangle waybar/style.css +#custom-dunst-status { + background: #50fa7b; + color: #282a36; +} +#custom-dunst-clear { + background: #50fa7b; + color: #282a36; +} +#custom-dunst-history-view { + background: #50fa7b; + color: #282a36; +} +#custom-dunst-history-clear { + background: #50fa7b; + color: #282a36; +} +#+END_SRC + +**** Script + +#+BEGIN_SRC shell :shebang #!/usr/bin/env bash :tangle waybar/scripts/dunst.sh +isPaused=$(dunstctl is-paused) +notificationCount=$(dunstctl count history) + +if [[ "$isPaused" == "true" ]]; then + echo "󰂛 $notificationCount" +else + echo "󰂚 $notificationCount" +fi +#+END_SRC + +*** Power Menu **** Configuration @@ -646,7 +728,7 @@ window#waybar { } #+END_SRC -*** dwl/tags +*** dwl **** Configuration @@ -684,7 +766,7 @@ window#waybar { } #+END_SRC -*** disk +*** Disk **** Configuration @@ -706,7 +788,7 @@ window#waybar { } #+END_SRC -*** memory +*** Memory **** Configuration @@ -728,7 +810,7 @@ window#waybar { } #+END_SRC -*** pulseaudio +*** Pulseaudio **** Configuration @@ -763,7 +845,7 @@ window#waybar { } #+END_SRC -*** tray +*** Tray **** Configuration diff --git a/waybar/config.jsonc b/waybar/config.jsonc index 0cb2cf0..29feb4a 100644 --- a/waybar/config.jsonc +++ b/waybar/config.jsonc @@ -25,8 +25,23 @@ "memory", "disk", "battery", - "clock" + "clock", + "group/dunst", ], + "group/dunst": { + "orientation": "horizontal", + "modules": [ + "custom/dunst-status", + "custom/dunst-history-view", + "custom/dunst-clear", + "custom/dunst-history-clear", + ], + "drawer": { + "transition-duration": 500, + "transition-left-to-right": true, + "click-to-reveal": false, + }, + }, "battery": { "interval": 60, @@ -47,6 +62,32 @@ "format": "󰥔 {:%H:%M}" }, + "custom/dunst-status": { + "exec": "~/.config/dwl/waybar/scripts/dunst.sh", + "restart-interval": 1, + "on-click": "~/.scripts/dunst.sh --dnd", + "on-click-right": "~/.scripts/dunst.sh --rofi", + "tooltip": false, + }, + "custom/dunst-clear": { + "format": "", + "on-click": "~/.scripts/dunst.sh --close-all", + "tooltip": true, + "tooltip-format": "Close Open Notifications", + }, + "custom/dunst-history-view": { + "format": "󰋚", + "on-click": "~/.scripts/dunst.sh --history", + "tooltip": true, + "tooltip-format": "View Notification History", + }, + "custom/dunst-history-clear": { + "format": "󰎟", + "on-click": "~/.scripts/dunst.sh --history-clear", + "tooltip": true, + "tooltip-format": "Clear Notification History", + }, + "custom/power-menu": { "format": "󰀻", "on-click": "rofi -show combi", diff --git a/waybar/scripts/dunst.sh b/waybar/scripts/dunst.sh new file mode 100755 index 0000000..fb87020 --- /dev/null +++ b/waybar/scripts/dunst.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +isPaused=$(dunstctl is-paused) +notificationCount=$(dunstctl count history) + +if [[ "$isPaused" == "true" ]]; then + echo "󰂛 $notificationCount" +else + echo "󰂚 $notificationCount" +fi diff --git a/waybar/style.css b/waybar/style.css index 60ea491..ca9d8f2 100644 --- a/waybar/style.css +++ b/waybar/style.css @@ -24,6 +24,23 @@ window#waybar { color: #282a36; } +#custom-dunst-status { + background: #50fa7b; + color: #282a36; +} +#custom-dunst-clear { + background: #50fa7b; + color: #282a36; +} +#custom-dunst-history-view { + background: #50fa7b; + color: #282a36; +} +#custom-dunst-history-clear { + background: #50fa7b; + color: #282a36; +} + #custom-power-menu { background: #8be9fd; color: #282a36;