From f7620ab2c705901c9f09f05dbd82d9c25f688ceb Mon Sep 17 00:00:00 2001 From: Jonathan Bourdon Date: Mon, 4 May 2026 20:14:54 -0400 Subject: [PATCH] feat(mako): improves notifications --- mako/.config/mako/config | 2 +- .../waybar/scripts/mako-notifications.sh | 33 +++++++++++++++---- waybar/.config/waybar/style.css | 4 +-- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/mako/.config/mako/config b/mako/.config/mako/config index d7ca1f0..3343089 100644 --- a/mako/.config/mako/config +++ b/mako/.config/mako/config @@ -1,4 +1,4 @@ -font=JetBrainsMono Nerd Font 14 +font=JetBrainsMono Nerd Font 12 background-color=#191A1C text-color=#BDBDBD border-color=#39CC9B diff --git a/waybar/.config/waybar/scripts/mako-notifications.sh b/waybar/.config/waybar/scripts/mako-notifications.sh index 1792724..c4c7aa7 100755 --- a/waybar/.config/waybar/scripts/mako-notifications.sh +++ b/waybar/.config/waybar/scripts/mako-notifications.sh @@ -4,8 +4,25 @@ set -eu dnd_mode="do-not-disturb" -json_escape() { - printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g; s/\t/\\t/g' +json_string() { + if command -v jq >/dev/null 2>&1; then + printf '%s' "$1" | jq -Rs . + return + fi + + printf '%s' "$1" | awk ' + BEGIN { ORS = "" } + { + gsub(/\\/, "\\\\") + gsub(/"/, "\\\"") + gsub(/\t/, "\\t") + if (NR > 1) { + printf "\\n" + } + printf "%s", $0 + } + END { printf "\n" } + ' } refresh_waybar() { @@ -29,8 +46,10 @@ is_dnd() { status() { if ! modes="$(makoctl mode 2>/dev/null)"; then - tooltip="$(json_escape "Mako is unavailable")" - printf '{"text":" n/a","class":"disabled","tooltip":"%s"}\n' "$tooltip" + text="$(json_string " n/a")" + class="$(json_string "disabled")" + tooltip="$(json_string "Mako is unavailable")" + printf '{"text":%s,"class":%s,"tooltip":%s}\n' "$text" "$class" "$tooltip" return fi @@ -51,12 +70,14 @@ status() { label="Do Not Disturb is off" fi - tooltip="$(json_escape "$label + text="$(json_string "$icon $count")" + class="$(json_string "$state")" + tooltip="$(json_string "$label $count pending notifications Left click toggles DND Right click opens the notification list")" - printf '{"text":"%s %s","class":"%s","tooltip":"%s"}\n' "$icon" "$count" "$state" "$tooltip" + printf '{"text":%s,"class":%s,"tooltip":%s}\n' "$text" "$class" "$tooltip" } toggle() { diff --git a/waybar/.config/waybar/style.css b/waybar/.config/waybar/style.css index d47a929..471da96 100644 --- a/waybar/.config/waybar/style.css +++ b/waybar/.config/waybar/style.css @@ -158,8 +158,8 @@ tooltip { padding: 0px 19px 0px 14px; } -#custom-mako.dnd { - color: @warning; +#custom-mako { + min-width: 42px; } #custom-mako.active {