commit 2ab5b5b502b83c0ba3239da50dd5475a5b5e9061
parent 9efd96b4053aa5bddac5aee58b07efbd4ad905d2
Author: Chris Down <chris@chrisdown.name>
Date: Wed, 9 Nov 2016 11:38:41 +0000
Only take ownership of clipboard if we would not skip this clip
Fixes #34, an issue with pcmanfm GUI file copy/paste.
Diffstat:
M | clipmenud | | | 34 | +++++++++++++++++++--------------- |
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/clipmenud b/clipmenud
@@ -55,24 +55,9 @@ while sleep "${CLIPMENUD_SLEEP:-0.5}"; do
if type -p xsel >/dev/null 2>&1; then
debug 'Using xsel'
data=$(xsel -o --"$selection"; printf x)
- # Take ownership of the clipboard, in case the original application
- # is unable to serve the clipboard request (due to being suspended,
- # etc).
- #
- # Primary is excluded from the change of ownership as applications
- # sometimes act up if clipboard focus is taken away from them --
- # for example, urxvt will unhilight text, which is undesirable.
- if [[ $selection != primary ]]; then
- xsel -o --"$selection" | xsel -i --"$selection"
- fi
else
debug 'Using xclip'
data=$(xclip -o -sel "$selection"; printf x)
- # See above comments about taking ownership of the clipboard for
- # context.
- if [[ $selection != primary ]]; then
- xclip -o -sel "$selection" | xclip -i -sel "$selection"
- fi
fi
debug "Data before stripping: $data"
@@ -110,5 +95,24 @@ while sleep "${CLIPMENUD_SLEEP:-0.5}"; do
debug "Writing $data to $filename"
printf '%s' "$data" > "$filename"
+
+ if ! (( NO_OWN_CLIPBOARD )) && [[ $selection != primary ]]; then
+ # Take ownership of the clipboard, in case the original application
+ # is unable to serve the clipboard request (due to being suspended,
+ # etc).
+ #
+ # Primary is excluded from the change of ownership as applications
+ # sometimes act up if clipboard focus is taken away from them --
+ # for example, urxvt will unhilight text, which is undesirable.
+ #
+ # We can't colocate this with the above copying code because
+ # https://github.com/cdown/clipmenu/issues/34 requires knowing if
+ # we would skip first.
+ if type -p xsel >/dev/null 2>&1; then
+ xsel -o --"$selection" | xsel -i --"$selection"
+ else
+ xclip -o -sel "$selection" | xclip -i -sel "$selection"
+ fi
+ fi
done
done