voidrice/.scripts/i3cmds/ddspawn

25 lines
918 B
Text
Raw Normal View History

2018-10-16 18:18:54 +00:00
#!/bin/sh
# This script simplifies dropdown windows in i3.
2018-10-17 11:01:14 +00:00
# Shows/hides a scratchpad of a given name, if it doesn't exist, creates it.
2018-10-16 18:18:54 +00:00
# Usage:
# argument 1: script to run in dropdown window
# all other args are interpreted as options for your terminal
# My usage:
2019-01-03 18:51:38 +00:00
# ddspawn
2018-10-16 18:18:54 +00:00
# bindsym $mod+u exec --no-startup-id ddspawn tmuxdd
# Will hide/show window running the `tmuxdd` script when I press mod+u in i3
# bindsym $mod+a exec --no-startup-id ddspawn dropdowncalc -f mono:pixelsize=24
# Similar to above but with `dropdowncalc` and the other args are interpretated as for my terminal emulator (to increase font)
[ -z "$1" ] && exit
if xwininfo -tree -root | grep "(\"$1\" ";
then
echo "Window detected."
2019-01-03 18:51:38 +00:00
i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center"
2018-10-16 18:18:54 +00:00
else
echo "Window not detected... spawning."
2019-01-03 19:52:36 +00:00
i3 "exec --no-startup-id $TERMINAL -n $1 $(echo "$@" | cut -d ' ' -f2-) -e $1"
2018-10-16 18:18:54 +00:00
fi