From acf0af089501a0d1d167df73426f28d57081df96 Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Thu, 20 Jan 2022 11:16:42 +0100 Subject: gruake: optimize non-tty use --- gruake | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'gruake') diff --git a/gruake b/gruake index 0f92745..4e6987e 100755 --- a/gruake +++ b/gruake @@ -1,11 +1,17 @@ #!/bin/sh # -# Guake-like show-and-hide terminal in a couple of lines of code. -# Powered by urxvt+tmux +# Guake-like show-and-hide terminal in a few lines of code. +# Powered by urxvt+tmux. ################################################################################ if pid=$(pgrep -f 'urxvt.*gruake'); then - kill $pid + kill "$pid" else - urxvt -name gruake -e sh -c 'tmux new -A -s gruake' + if [ -t 0 ]; then + # If running in a tty, spawn terminal in background + urxvt -name gruake -e sh -c 'tmux new -A -s gruake' & + else + # otherwise, probably run from a hotkey daemon so just exec + exec urxvt -name gruake -e sh -c 'tmux new -A -s gruake' + fi fi -- cgit v1.2.3