sb

shitty bar for dwm
git clone git://git.ckyln.com/~cem/sb.git
Log | Files | Refs | README | LICENSE

commit 52308d035cd102e11327b2e98693a62ac597c1af
parent 8870a6462df68025ef33cbec7fcf8125590d5adf
Author: Cem Keylan <cem@ckyln.com>
Date:   Tue,  7 Jul 2020 10:46:14 +0300

sb: conditional clear command

Diffstat:
Msb | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sb b/sb @@ -72,7 +72,15 @@ command -v bar >/dev/null 2>&1 || trap cleanup EXIT INT QUIT HUP if [ "$nobar" = 1 ]; then - while :; do clear; bar; printf '\n'; sleep "${SLEEPTIME:=1}"; done + while :; do + # If stdout belongs to sb, clear the screen each time the bar is being + # printed. If stdout doesn't belong to us, that means sb is being piped + # and we are most likely not dealing with a terminal. In such a case we + # should not clear the screen. + [ -t 1 ] && clear + printf ' %s\n' "$(bar)" + sleep "${SLEEPTIME:=1}" + done else while :; do xsetroot -name " $(bar)"; sleep "${SLEEPTIME:=1}"; done fi