]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Fix(xclip): avoid 'Error: target STRING not available'
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 8 May 2022 14:03:41 +0000 (11:03 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 8 May 2022 14:03:41 +0000 (11:03 -0300)
lib/keyringer/actions/xclip

index da86315677c587d13f09c552e2e70c508cdee033..f63fdb5b72ad87191d20781c45a9b8aaaca2a43a 100755 (executable)
@@ -4,8 +4,11 @@
 #
 
 # Copy contents to clipboard.
+#
 # Function thanks to Password Store by Jason A. Donenfeld <Jason@zx2c4.com>
 # distributed under GPLv2+: http://www.zx2c4.com/projects/password-store/
+#
+# Adapted by rhatto
 clip() {
   # This base64 business is a disgusting hack to deal with newline inconsistancies
   # in shell. There must be a better way to deal with this, but because I'm a dolt,
@@ -14,7 +17,15 @@ clip() {
   #local xclip="xclip -selection clipboard"
   local xclip="xclip"
   before="$($xclip -o | base64)"
+
+  # Avoid "Error: target STRING not available"
+  # https://github.com/astrand/xclip/issues/38
+  echo "$RANDOM" | $xclip
+
+  # Copy text into clipboard
   echo -n "$1" | $xclip
+
+  # Cleanup procedure
   (
     sleep 45
     now="$($xclip -o | base64)"