fix: notify when clipboard utility is missing #2
+23
-3
@@ -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 ──────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user