Use xsel instead of xclip when target is not necessary and clean

clipboard before using it
This commit is contained in:
BarbUk 2020-04-13 17:05:07 +04:00
parent 6aae510e0f
commit 539c487bf0

10
snippy
View File

@ -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