diff --git a/usr/lib/byobu/.shutil b/usr/lib/byobu/.shutil index 7261c983..107b3ac7 100644 --- a/usr/lib/byobu/.shutil +++ b/usr/lib/byobu/.shutil @@ -64,4 +64,16 @@ rtrim() { _RET=${cur} } +readfile() { + local c="" r="" cr=" +" + OIFS="$IFS"; IFS=""; + while read c; do + r="$r${cr}$c" + done + IFS=$OIFS + _RET=${r} + return 0 +} + # vi: syntax=sh ts=4 noexpandtab diff --git a/usr/lib/byobu/custom b/usr/lib/byobu/custom index 86f3969c..638d3309 100755 --- a/usr/lib/byobu/custom +++ b/usr/lib/byobu/custom @@ -30,15 +30,18 @@ CACHE="$DIR/$PKG.custom" # Loop over custom scripts for i in "$DATA/bin/"[0-9]*_*; do [ -x "$i" ] || continue - script=$(basename "$i") - freq=$(echo "$script" | awk -F_ '{print $1}') - lastrun=$(stat -c %Y "$CACHE.$script") 2>/dev/null || lastrun=0 - expiration=$(expr $lastrun + $freq) + script=${script##*/} + freq=${script%%_*} + freq=${freq#0} + [ -r "$CACHE.$script.last" ] && read lastrun "$CACHE.$script.last" || + lastrun=0 + expiration=$(($lastrun+$freq)) if [ $NOW -ge $expiration ]; then - # Update the cache - $i $@ > "$CACHE.$script" 2>/dev/null + "$i" "$@" > "$CACHE.$script" 2>/dev/null + echo "${NOW}" > "$CACHE.$script.last" fi - output=$(cat "$CACHE.$script") + readfile < "$CACHE.$script" + output="${_RET}" case "$output" in *"$ESC{"*) # User has formatted the colors