From 5f659b90e309244656234b16d7bc724ae1ee3d3a Mon Sep 17 00:00:00 2001 From: rootiest Date: Tue, 28 Apr 2026 22:17:31 -0400 Subject: [PATCH] fix: notify when clipboard utility is missing - Add notify_error function to send normal urgency warning notifications - Update process_color to track clipboard failure and trigger error notification - Improve warning message when clipboard utilities (wl-copy/xclip) are absent --- color-tool | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/color-tool b/color-tool index 616a847..b2c77a5 100755 --- a/color-tool +++ b/color-tool @@ -160,7 +160,7 @@ copy_to_clipboard() { elif command -v xclip &>/dev/null; then printf '%s' "$text" | xclip -selection clipboard else - echo "Warning: no clipboard utility found (install wl-copy or xclip)" >&2 + echo "Warning: Missing clipboard utility. Please install wl-clipboard (preferred) or xclip." >&2 echo " Value: $text" >&2 return 1 fi @@ -172,6 +172,12 @@ notify_result() { notify-send -i "color-picker" "color-tool" "$value" || true } +notify_error() { + local value="$1" + command -v notify-send &>/dev/null || return 0 + notify-send -u normal -i "dialog-warning" "color-tool" "$value" || true +} + # ── Color picker ────────────────────────────────────────────────────────────── # Generate the internal Python helper for KDE Plasma color picking @@ -458,8 +464,22 @@ process_color() { echo -e "$output_text" fi - [[ $copy_mode -eq 1 ]] && copy_to_clipboard "$output_text" || true - [[ $notify_mode -eq 1 ]] && notify_result "$output_text" || true + local copy_failed=0 + if [[ $copy_mode -eq 1 ]]; then + if ! copy_to_clipboard "$output_text"; then + copy_failed=1 + fi + fi + + if [[ $notify_mode -eq 1 ]]; then + if [[ $copy_failed -eq 1 ]]; then + notify_error "Missing clipboard utility. Please install wl-clipboard (preferred) or xclip. + +Value: $output_text" + else + notify_result "$output_text" + fi + fi } # ── Argument parsing ──────────────────────────────────────────────────────────