fix: notify when clipboard utility is missing
Release on Merge / release (pull_request) Successful in 6s
Release on Merge / release (pull_request) Successful in 6s
- 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
This commit is contained in:
+23
-3
@@ -160,7 +160,7 @@ copy_to_clipboard() {
|
|||||||
elif command -v xclip &>/dev/null; then
|
elif command -v xclip &>/dev/null; then
|
||||||
printf '%s' "$text" | xclip -selection clipboard
|
printf '%s' "$text" | xclip -selection clipboard
|
||||||
else
|
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
|
echo " Value: $text" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -172,6 +172,12 @@ notify_result() {
|
|||||||
notify-send -i "color-picker" "color-tool" "$value" || true
|
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 ──────────────────────────────────────────────────────────────
|
# ── Color picker ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
# Generate the internal Python helper for KDE Plasma color picking
|
# Generate the internal Python helper for KDE Plasma color picking
|
||||||
@@ -458,8 +464,22 @@ process_color() {
|
|||||||
echo -e "$output_text"
|
echo -e "$output_text"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ $copy_mode -eq 1 ]] && copy_to_clipboard "$output_text" || true
|
local copy_failed=0
|
||||||
[[ $notify_mode -eq 1 ]] && notify_result "$output_text" || true
|
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 ──────────────────────────────────────────────────────────
|
# ── Argument parsing ──────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user