#!/bin/bash set -euo pipefail find_clipboard_command() { if command -v xclip &>/dev/null; then echo xclip -out -selection clipboard elif command -v xsel &>/dev/null; then echo xsel --output --clipboard else echo "No clipboard command found" >&2 exit 1 fi } clipman_settings() { xfconf-query -c xfce4-panel -p /plugins/clipman/settings/enable-actions "$@" 2>/dev/null } restore_clipman_actions() { if [ -n "$1" ]; then clipman_settings -s "$1" fi } main() { CLIPMAN_ACTION_STATE=$(clipman_settings || echo) trap 'restore_clipman_actions "$CLIPMAN_ACTION_STATE"' EXIT clipman_settings -s 'false' >/dev/null || true CLIPBOARD_COMMAND=$(find_clipboard_command) recent_value=$(eval "$CLIPBOARD_COMMAND") while true; do value=$(eval "$CLIPBOARD_COMMAND") if [ "$recent_value" != "$value" ]; then recent_value=$value echo "$recent_value" fi sleep 0.1 done } main "$@"