From 539c487bf0c2d1af56a62596b70e72796013793f Mon Sep 17 00:00:00 2001 From: BarbUk Date: Mon, 13 Apr 2020 17:05:07 +0400 Subject: [PATCH] Use xsel instead of xclip when target is not necessary and clean clipboard before using it --- snippy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/snippy b/snippy index e7f6151..8893b44 100755 --- a/snippy +++ b/snippy @@ -211,7 +211,9 @@ run() { fi # save current clipboard - current_clipboard=$(xsel -b) + current_clipboard=$(xsel --clipboard) + # clear clipboard + xsel --clipboard --clear # replace {clipboard} by the clipboard content # use awk to handle correctly multiline clipboard if grep -q "$clipboard_placeholder" "$tmpfile"; then @@ -224,7 +226,6 @@ run() { perl -pi -e 'chomp if eof' "$tmpfile" fi - # define cursor position and line at 0, we don't need to go up or left if there is no {cursor} placeholder cursor_line_position=0 cursor_position=0 @@ -251,16 +252,15 @@ run() { # Copy snippet in clipboard if is_rich_snippet "${snippets_directory}/${snippet}"; then - xclip -t text/html -selection clipboard < "$tmpfile" + xclip -target text/html -selection clipboard -in -loops 1 < "$tmpfile" else - xclip -selection clipboard < "$tmpfile" + xsel --clipboard --input < "$tmpfile" fi # Paste into the current application. if is_gui; then # We need a little pause to handle the time to focus on the window sleep 0.225 - wait ${GUIPASTE} move_cursor "Up" $cursor_line_position else