Use xsel instead of xclip when target is not necessary and clean
clipboard before using it
This commit is contained in:
parent
6aae510e0f
commit
539c487bf0
10
snippy
10
snippy
@ -211,7 +211,9 @@ run() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# save current clipboard
|
# save current clipboard
|
||||||
current_clipboard=$(xsel -b)
|
current_clipboard=$(xsel --clipboard)
|
||||||
|
# clear clipboard
|
||||||
|
xsel --clipboard --clear
|
||||||
# replace {clipboard} by the clipboard content
|
# replace {clipboard} by the clipboard content
|
||||||
# use awk to handle correctly multiline clipboard
|
# use awk to handle correctly multiline clipboard
|
||||||
if grep -q "$clipboard_placeholder" "$tmpfile"; then
|
if grep -q "$clipboard_placeholder" "$tmpfile"; then
|
||||||
@ -224,7 +226,6 @@ run() {
|
|||||||
perl -pi -e 'chomp if eof' "$tmpfile"
|
perl -pi -e 'chomp if eof' "$tmpfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# define cursor position and line at 0, we don't need to go up or left if there is no {cursor} placeholder
|
# 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_line_position=0
|
||||||
cursor_position=0
|
cursor_position=0
|
||||||
@ -251,16 +252,15 @@ run() {
|
|||||||
|
|
||||||
# Copy snippet in clipboard
|
# Copy snippet in clipboard
|
||||||
if is_rich_snippet "${snippets_directory}/${snippet}"; then
|
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
|
else
|
||||||
xclip -selection clipboard < "$tmpfile"
|
xsel --clipboard --input < "$tmpfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Paste into the current application.
|
# Paste into the current application.
|
||||||
if is_gui; then
|
if is_gui; then
|
||||||
# We need a little pause to handle the time to focus on the window
|
# We need a little pause to handle the time to focus on the window
|
||||||
sleep 0.225
|
sleep 0.225
|
||||||
wait
|
|
||||||
${GUIPASTE}
|
${GUIPASTE}
|
||||||
move_cursor "Up" $cursor_line_position
|
move_cursor "Up" $cursor_line_position
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user