mirror of https://github.com/captn3m0/Scripts.git
snippy changes to use i3 for focusing back after dmenu
This commit is contained in:
parent
49862a4f71
commit
b576c59662
24
snippy.sh
24
snippy.sh
|
@ -27,12 +27,15 @@
|
||||||
# TIP: If you're using XMonad, add something like this to xmonad.hs
|
# TIP: If you're using XMonad, add something like this to xmonad.hs
|
||||||
# ((mod4Mask, xK_s), spawn "/path/to/snippy")
|
# ((mod4Mask, xK_s), spawn "/path/to/snippy")
|
||||||
#
|
#
|
||||||
|
# Notes: I have disabled GUIPASTE, because that screws up my cursor position
|
||||||
|
# and pastes in the wrong place. Instead I just use i3 focus
|
||||||
|
#
|
||||||
|
#
|
||||||
DIR=${HOME}/.snippy
|
DIR=${HOME}/.snippy
|
||||||
APPS="xdotool xsel dmenu"
|
APPS="xdotool xsel dmenu"
|
||||||
DMENU_ARGS="-b"
|
DMENU_ARGS="-b"
|
||||||
TMPFILE="/tmp/.snippy.tmp"; :>$TMPFILE
|
TMPFILE="/tmp/.snippy.tmp"; :>$TMPFILE
|
||||||
# if nothing happens, try "xdotool click 2", "xdotool key ctrl+v" or "xdotool key ctrl+shift+v"
|
|
||||||
GUIPASTE="xdotool click 2"
|
|
||||||
CLIPASTE="xdotool key ctrl+v"
|
CLIPASTE="xdotool key ctrl+v"
|
||||||
|
|
||||||
# smarty like template engine which executes inline bash in (bashdown) strings (replaces variables with values e.g.)
|
# smarty like template engine which executes inline bash in (bashdown) strings (replaces variables with values e.g.)
|
||||||
|
@ -65,6 +68,10 @@ init(){
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log(){
|
||||||
|
echo $1 >> /home/nemo/.log/snippy.log
|
||||||
|
}
|
||||||
|
|
||||||
run(){
|
run(){
|
||||||
cd ${DIR}
|
cd ${DIR}
|
||||||
# Use the filenames in the snippy directory as menu entries.
|
# Use the filenames in the snippy directory as menu entries.
|
||||||
|
@ -77,16 +84,13 @@ run(){
|
||||||
else
|
else
|
||||||
${FILE} &> $TMPFILE # execute as bashcommand
|
${FILE} &> $TMPFILE # execute as bashcommand
|
||||||
fi
|
fi
|
||||||
xsel --input < $TMPFILE
|
|
||||||
# Paste into the current application.
|
|
||||||
[[ is_window ]] && ${GUIPASTE} || ${CLIPASTE} # cli or gui paste
|
|
||||||
}
|
|
||||||
|
|
||||||
|
xclip -selection c < $TMPFILE
|
||||||
|
# xsel < $TMPFILE
|
||||||
|
|
||||||
is_window(){
|
focused_window_id="$(xdotool getwindowfocus)"
|
||||||
name="$(xdotool getwindowname $(xdotool getwindowfocus) | tr '[:upper:]' '[:lower:]')"
|
i3-msg '[id="$focused_window_id"] focus'
|
||||||
[[ ! "$name" =~ term|tilda ]] && return 1
|
xdotool key ctrl+v
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init && run
|
init && run
|
Loading…
Reference in New Issue