feat(mako): improves notifications
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
font=JetBrainsMono Nerd Font 14
|
font=JetBrainsMono Nerd Font 12
|
||||||
background-color=#191A1C
|
background-color=#191A1C
|
||||||
text-color=#BDBDBD
|
text-color=#BDBDBD
|
||||||
border-color=#39CC9B
|
border-color=#39CC9B
|
||||||
|
|||||||
@@ -4,8 +4,25 @@ set -eu
|
|||||||
|
|
||||||
dnd_mode="do-not-disturb"
|
dnd_mode="do-not-disturb"
|
||||||
|
|
||||||
json_escape() {
|
json_string() {
|
||||||
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g; s/\t/\\t/g'
|
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() {
|
refresh_waybar() {
|
||||||
@@ -29,8 +46,10 @@ is_dnd() {
|
|||||||
|
|
||||||
status() {
|
status() {
|
||||||
if ! modes="$(makoctl mode 2>/dev/null)"; then
|
if ! modes="$(makoctl mode 2>/dev/null)"; then
|
||||||
tooltip="$(json_escape "Mako is unavailable")"
|
text="$(json_string " n/a")"
|
||||||
printf '{"text":" n/a","class":"disabled","tooltip":"%s"}\n' "$tooltip"
|
class="$(json_string "disabled")"
|
||||||
|
tooltip="$(json_string "Mako is unavailable")"
|
||||||
|
printf '{"text":%s,"class":%s,"tooltip":%s}\n' "$text" "$class" "$tooltip"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -51,12 +70,14 @@ status() {
|
|||||||
label="Do Not Disturb is off"
|
label="Do Not Disturb is off"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tooltip="$(json_escape "$label
|
text="$(json_string "$icon $count")"
|
||||||
|
class="$(json_string "$state")"
|
||||||
|
tooltip="$(json_string "$label
|
||||||
$count pending notifications
|
$count pending notifications
|
||||||
Left click toggles DND
|
Left click toggles DND
|
||||||
Right click opens the notification list")"
|
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() {
|
toggle() {
|
||||||
|
|||||||
@@ -158,8 +158,8 @@ tooltip {
|
|||||||
padding: 0px 19px 0px 14px;
|
padding: 0px 19px 0px 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#custom-mako.dnd {
|
#custom-mako {
|
||||||
color: @warning;
|
min-width: 42px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#custom-mako.active {
|
#custom-mako.active {
|
||||||
|
|||||||
Reference in New Issue
Block a user