diff options
author | tdro <tdro@users.noreply.github.com> | 2022-01-14 02:58:21 -0500 |
---|---|---|
committer | tdro <tdro@users.noreply.github.com> | 2022-01-14 03:32:31 -0500 |
commit | daf1622d40a81c7902134880b643ce271c4b8f6f (patch) | |
tree | 76cd2f1ebaef88fabb624c6705ba4afab945d23a | |
parent | f214b128ff56037ff6a73bb970ea86a14e7f1980 (diff) | |
download | dotfiles-daf1622d40a81c7902134880b643ce271c4b8f6f.tar.gz dotfiles-daf1622d40a81c7902134880b643ce271c4b8f6f.tar.bz2 dotfiles-daf1622d40a81c7902134880b643ce271c4b8f6f.zip |
.local/bin/scripts/dropdown-terminal: Track PID
-rwxr-xr-x | .local/bin/scripts/dropdown-terminal | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/.local/bin/scripts/dropdown-terminal b/.local/bin/scripts/dropdown-terminal index c62c891..36f3448 100755 --- a/.local/bin/scripts/dropdown-terminal +++ b/.local/bin/scripts/dropdown-terminal @@ -1,7 +1,6 @@ #!/bin/sh -eu name=dropdown-terminal state=/tmp/"$name"_lQ5GnvRpQ6 -options=$(grep --count . $state || true) terminal="urxvt -pe tabbed -geometry 150x20 -title $name" [ ! -f $state ] && { @@ -9,10 +8,14 @@ terminal="urxvt -pe tabbed -geometry 150x20 -title $name" touch $state && exit; } +options=$(grep --count . $state || true) + [ "$options" != "1" ] && { printf '1\n' > $state; } +pid=$(pgrep --full "title $name" | head --lines 1) + visible=$(awk 'NR==1 { print; exit }' $state) -window=$(wmctrl -lpGx | awk "/ $name$/"'{ print $1 }') +window=$(wmctrl -lpGx | awk "/$pid/"'{ print $1 }') [ -z "$window" ] && rm "$state" && "$0" && exit; |