summaryrefslogtreecommitdiff
path: root/.i3/scripts/ddspawn
diff options
context:
space:
mode:
authorVito Graffagnino <vito@graffagnino.xyz>2020-09-08 18:10:49 +0100
committerVito Graffagnino <vito@graffagnino.xyz>2020-09-08 18:10:49 +0100
commit3b0142cedcde39e4c2097ecd916a870a3ced5ec6 (patch)
tree2116c49a845dfc0945778f2aa3e2118d72be428b /.i3/scripts/ddspawn
parent8cc927e930d5b6aafe3e9862a61e81705479a1b4 (diff)
Added the relevent parts of the .config directory. Alss add ssh config
Diffstat (limited to '.i3/scripts/ddspawn')
-rwxr-xr-x.i3/scripts/ddspawn25
1 files changed, 25 insertions, 0 deletions
diff --git a/.i3/scripts/ddspawn b/.i3/scripts/ddspawn
new file mode 100755
index 0000000..0871a59
--- /dev/null
+++ b/.i3/scripts/ddspawn
@@ -0,0 +1,25 @@
+#!/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"