voidrice/.scripts/i3cmds/ddspawn
Louis-Michel Raynauld fd7c65f8ff Fix for spawning scripts that require no args
For example, "ddspawn vifm" is generating the failing commad "st vifm -e vifm" without this fix.
This proposed change fixes this issue so that "ddspawn vifm" generates the correct "st -e vifm". It also simplify  the i3 command in my view.
Thanks for sharing this helpful script, I used it everywhere!
2019-05-09 12:58:41 -07:00

17 lines
548 B
Bash
Executable file

#!/bin/sh
# 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.
[ -z "$1" ] && exit
if xwininfo -tree -root | grep "(\"dropdown_$1\" ";
then
echo "Window detected."
i3 "[instance=\"dropdown_$1\"] scratchpad show; [instance=\"dropdown_$1\"] move position center"
else
echo "Window not detected... spawning."
i3 "exec --no-startup-id $TERMINAL -n dropdown_$1 ${@:2} -e $1"
fi