diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2021-08-04 19:47:17 -0400 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2021-08-04 19:47:17 -0400 |
commit | 0d847937606863d2ca29bf45e88ce7a4ce35f817 (patch) | |
tree | 936eac064805ee0e784f2ea027036f167167c6db | |
parent | 1f624ca63f948f95155f2a95fe8f0d762fb863cb (diff) |
Good terminal app toggle script
-rwxr-xr-x | .local/bin/toggle | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/.local/bin/toggle b/.local/bin/toggle new file mode 100755 index 0000000..71392df --- /dev/null +++ b/.local/bin/toggle @@ -0,0 +1,29 @@ +#!/bin/sh + +# toggle [-f/-t] software flags + +# Spawn a floating (or not) terminal window: +# f/float: should the window float +# t/title: title of the terminal window +# software: Software to run +# flags: flags for the softare +# It is expected that all flags be called separately (no -ft). +# It is expected that all flags be called at the beggining. + +title="terminal" +class="terminal" + +for arg in "$@"; do + case $arg in + -f|--float) class="dropdown" && shift ;; + -t=*|--title=*) title="${arg#*=}" && shift ;; + *) ;; + esac +done + +software="$1" +shift +flags="$@" + +killall "$software" || $TERMINAL --class "$class" -t "$title" -e $software $flags + |