From a7e060b62fa1230adabf272273c1321a1d6a5dd2 Mon Sep 17 00:00:00 2001 From: Beau Hastings Date: Mon, 2 Nov 2020 15:42:57 +0800 Subject: [PATCH] feat: support for colors when using dunst Signed-off-by: Beau Hastings --- README.md | 1 + volume | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b953137..c7ca43b 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ Environment Variables: CANBERRA_PATH path to canberra-gtk-play NOTIFY_SEND_PATH path to notify-send or notify-send.py USE_NOTIFY_SEND_PY flag to use notify-send.py instead of notify-send + NO_NOTIFY_COLOR flag to disable colors in notifications ``` ## Migrating diff --git a/volume b/volume index 15d0aea..c629491 100755 --- a/volume +++ b/volume @@ -146,7 +146,7 @@ define_notify() { ) local -a hints=( int:value:"$vol" - # Legacy hint that was renamed to x-canonical-private-synchronous in NotifyOSD + # Replaces previous notification in some notification servers string:synchronous:volume # Replaces previous notification in NotifyOSD string:x-canonical-private-synchronous:volume @@ -165,9 +165,22 @@ define_notify() { hints+=(string:sound-name:audio-volume-change) fi + if ! isset NO_NOTIFY_COLOR && [[ $NOTIFICATION_METHOD == "dunst" ]]; then + if is_muted; then + hints+=(string:fgcolor:"$COLOR_MUTED") + else + hints+=(string:fgcolor:"$(volume_color "$vol")") + fi + fi + if $USE_DUNSTIFY; then args+=(-r 1000) + # Transient notifications will bypass the idle_threshold setting. + # Should be boolean, but Notify-OSD doesn't support boolean yet. Dunst checks + # for int and bool with transient so lets play nice with both servers. + hints+=(int:transient:1) + read -ra hints <<< "${hints[@]/#/-h }" "${DUNSTIFY_PATH:+${DUNSTIFY_PATH%/}/}dunstify" "${hints[@]}" "${args[@]}" "$text" elif isset USE_NOTIFY_SEND_PY; then @@ -474,6 +487,7 @@ ${COLOR_YELLOW}Environment Variables:${COLOR_RESET} ${COLOR_CYAN}CANBERRA_PATH${COLOR_RESET} path to canberra-gtk-play ${COLOR_CYAN}NOTIFY_SEND_PATH${COLOR_RESET} path to notify-send or notify-send.py ${COLOR_CYAN}USE_NOTIFY_SEND_PY${COLOR_RESET} flag to use notify-send.py instead of notify-send + ${COLOR_CYAN}NO_NOTIFY_COLOR${COLOR_RESET} flag to disable colors in notifications EOF exit "$EX_USAGE" }