From 70921a3e3f28f6642e757f8a28927ae577fcca0f Mon Sep 17 00:00:00 2001 From: BarbUk Date: Fri, 3 Jul 2020 14:34:06 +0400 Subject: [PATCH] Fix paste when focus is slow --- snippy | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/snippy b/snippy index 46ba53a..65dbb87 100755 --- a/snippy +++ b/snippy @@ -54,10 +54,6 @@ readonly snippets_directory=$XDG_CONFIG_HOME/snippy readonly rofi_args=(-dmenu -i -sort -async-pre-read 20 -theme-str 'element-icon { size: 2.35ch;}' -kb-accept-custom "" -kb-custom-1 "Ctrl+Return") readonly fzf_args=(--select-1 --reverse --inline-info --multi --preview '( bat --style auto --color always --language bash {} || highlight --force -O ansi -l {} 2> /dev/null ) | head -200' -1) -# if nothing happens, try "xdotool click 2", "xdotool key ctrl+v" or "xdotool key ctrl+shift+v" -readonly GUIPASTE="xdotool key ctrl+v" -readonly CLIPASTE="xdotool key ctrl+shift+v" - # Placeholders readonly cursor_placeholder="{cursor}" readonly clipboard_placeholder="{clipboard}" @@ -377,11 +373,14 @@ run() { # 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 - ${GUIPASTE} + sleep 0.1 + # Paste + xdotool key ctrl+v + # And another pause to empty the paste buffer before anything else + sleep 0.1 move_cursor "Up" $cursor_line_position else - ${CLIPASTE} + xdotool key ctrl+shift+v if is_vim; then move_cursor "Up" $cursor_line_position fi