commit 52b144d970f1a2aae73059fde52e8e614b5bc3e1
parent 9c436084f26e9d15188b153b1b36780fe4e17502
Author: Chris Down <chris@chrisdown.name>
Date: Tue, 20 Feb 2018 10:09:24 +0000
Revert "Take clipboard ownership prior to clipnotify"
This reverts commit eb7d2b94817e8b66f62dc372a204a78a12e3ef0f.
Diffstat:
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/clipmenud b/clipmenud
@@ -115,19 +115,6 @@ exec {lock_fd}> "$lock_file"
sleep_cmd=(sleep "${CM_SLEEP:-0.5}")
while true; do
- # We need to take ownership synchronously before we run `clipnotify` as
- # otherwise we could enter an infinite loop.
- if (( CM_OWN_CLIPBOARD )) && element_in clipboard "${cm_selections[@]}"; 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.
- _xsel -k --clipboard
- fi
-
if ! (( CM_ONESHOT )); then
if (( has_clipnotify )); then
# Fall back to polling if clipnotify fails
@@ -177,6 +164,22 @@ while true; do
debug "Writing $first_line to $cache_file"
printf '%s\n' "$first_line" >> "$cache_file"
+ if (( CM_OWN_CLIPBOARD )) && [[ $selection != primary ]] &&
+ element_in clipboard "${cm_selections[@]}"; 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.
+ _xsel -k --"$selection"
+ fi
+
if (( CM_MAX_CLIPS )); then
mapfile -t to_remove < <(
head -n -"$CM_MAX_CLIPS" "$cache_file" |