From 2f4c2a68a1cbebb0e06a5b3296e4bbb575c5fcb2 Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 5 Nov 2018 17:51:24 -0500 Subject: scripts sorted --- .scripts/i3cmds/ddspawn | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 .scripts/i3cmds/ddspawn (limited to '.scripts/i3cmds/ddspawn') diff --git a/.scripts/i3cmds/ddspawn b/.scripts/i3cmds/ddspawn new file mode 100755 index 0000000..aedcd18 --- /dev/null +++ b/.scripts/i3cmds/ddspawn @@ -0,0 +1,26 @@ +#!/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: +# ddpawn +# 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." +else + echo "Window not detected... spawning." + i3 "exec --no-startup-id $TERMINAL -n $1 $(echo "$@" | cut -d ' ' -f2-) -e $1" && i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" + sleep .25 # This sleep is my laziness, will fix later (needed for immediate appearance after spawn). +fi +i3 "[instance=\"$1\"] scratchpad show; [instance=\"$1\"] move position center" -- cgit v1.3.1