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-05-12 01:35:19 +00:00
|
|
|
script=$1
|
|
|
|
shift
|
|
|
|
if xwininfo -tree -root | grep "(\"dropdown_$script\" ";
|
2018-10-16 18:18:54 +00:00
|
|
|
then
|
|
|
|
echo "Window detected."
|
2019-05-12 01:35:19 +00:00
|
|
|
i3 "[instance=\"dropdown_$script\"] scratchpad show; [instance=\"dropdown_$script\"] move position center"
|
2018-10-16 18:18:54 +00:00
|
|
|
else
|
|
|
|
echo "Window not detected... spawning."
|
2019-05-12 01:35:19 +00:00
|
|
|
i3 "exec --no-startup-id $TERMINAL -n dropdown_$script $@ -e $script"
|
2018-10-16 18:18:54 +00:00
|
|
|
fi
|