voidrice/.scripts/i3cmds/ddspawn

18 lines
548 B
Text
Raw Normal View History

2018-10-16 18:18:54 +00:00
#!/bin/sh
2019-01-04 00:11:39 +00:00
# Toggle floating dropdown terminal in i3, or start if non-existing.
# $1 is the script run in the terminal.
# All other args are terminal settings.
# Terminal names are in dropdown_* to allow easily setting i3 settings.
2018-10-16 18:18:54 +00:00
[ -z "$1" ] && exit
2019-01-04 00:11:39 +00:00
if xwininfo -tree -root | grep "(\"dropdown_$1\" ";
2018-10-16 18:18:54 +00:00
then
echo "Window detected."
2019-01-04 00:11:39 +00:00
i3 "[instance=\"dropdown_$1\"] scratchpad show; [instance=\"dropdown_$1\"] move position center"
2018-10-16 18:18:54 +00:00
else
echo "Window not detected... spawning."
i3 "exec --no-startup-id $TERMINAL -n dropdown_$1 ${@:2} -e $1"
2018-10-16 18:18:54 +00:00
fi