feat(mako): improves notifications

This commit is contained in:
2026-05-04 20:14:54 -04:00
parent bd25cc4efc
commit f7620ab2c7
3 changed files with 30 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
font=JetBrainsMono Nerd Font 14
font=JetBrainsMono Nerd Font 12
background-color=#191A1C
text-color=#BDBDBD
border-color=#39CC9B

View File

@@ -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() {

View File

@@ -158,8 +158,8 @@ tooltip {
padding: 0px 19px 0px 14px;
}
#custom-mako.dnd {
color: @warning;
#custom-mako {
min-width: 42px;
}
#custom-mako.active {