From 01dbabf5a1703ca037ed981093e901f316dc34a1 Mon Sep 17 00:00:00 2001 From: Siddharth Dushantha Date: Fri, 20 Mar 2020 16:10:40 +0100 Subject: [PATCH] use -z to check if a string is empty or not Previously I used: [[ $STRING == "" ]] && do_something To check if a string was empty or not, but this can be simplified a lot by writing: [ -z $STRING ] && do_something --- kunst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kunst b/kunst index a175e3a..5048fd1 100755 --- a/kunst +++ b/kunst @@ -183,9 +183,9 @@ pre_exit() { main() { - [[ $KUNST_MUSIC_DIR != "" ]] && MUSIC_DIR=$KUNST_MUSIC_DIR - [[ $KUNST_SIZE != "" ]] && SIZE=$KUNST_SIZE - [[ $KUNST_POSITION != "" ]] && POSITION=$KUNST_POSITION + [ -z $KUNST_MUSIC_DIR ] && MUSIC_DIR=$KUNST_MUSIC_DIR + [ -z $KUNST_SIZE ] && SIZE=$KUNST_SIZE + [ -z $KUNST_POSITION ] && POSITION=$KUNST_POSITION # Flag to run some commands only once in the loop FIRST_RUN=true @@ -231,9 +231,9 @@ main() { while true; do mpc idle player &>/dev/null && (mpc status | grep "\[playing\]" &>/dev/null) && break done - if [ ! $SILENT ]; then - echo "kunst: received event from mpd" - fi + + [ ! $SILENT ] && echo "kunst: received event from mpd" + if [ "$VIEWER" = 'imv' ]; then imv-msg "$(cat /tmp/kunst.pid)" close all imv-msg "$(cat /tmp/kunst.pid)" open "$COVER"