ddspawn simplification
This commit is contained in:
@@ -1,24 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This script simplifies dropdown windows in i3.
|
||||
# Shows/hides a scratchpad of a given name, if it doesn't exist, creates it.
|
||||
# Usage:
|
||||
# argument 1: script to run in dropdown window
|
||||
# all other args are interpreted as options for your terminal
|
||||
# My usage:
|
||||
# ddspawn
|
||||
# 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)
|
||||
# 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 "(\"$1\" ";
|
||||
if xwininfo -tree -root | grep "(\"dropdown_$1\" ";
|
||||
then
|
||||
echo "Window detected."
|
||||
i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center"
|
||||
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 $1 $(echo "$@" | cut -d ' ' -f2-) -e $1"
|
||||
i3 "exec --no-startup-id $TERMINAL -n dropdown_$1 $(echo "$@" | cut -d ' ' -f2-) -e $1"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user