From b6542d1f7e69644e26ac2911bdde1fd285bdcca4 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 11 Dec 2018 17:16:04 +0100 Subject: [PATCH] Fully rewrite without text and more colors Signed-off-by: Knut Ahlers --- .config/i3blocks/arch-update | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.config/i3blocks/arch-update b/.config/i3blocks/arch-update index da8e7f1..cc88aa6 100755 --- a/.config/i3blocks/arch-update +++ b/.config/i3blocks/arch-update @@ -16,9 +16,19 @@ function get_grep() { updates=$(checkupdates) -num=$(echo "${updates}" | grep -c -- '->') +num=$(echo "${updates}" | grep -c -- '->' || true) -req_restart="" -echo "${updates}" | grep -qE "^($(get_grep)) " && req_restart=' (reboot)' +# No updates: Gray +color="#7f7f7f" +display_num="" -printf "\uf94f %d %s%s" $num $(${HOME}/bin/pluralize Update $num) "${req_restart}" +# Normal updates: White +[ $num -gt 0 ] && { + color="#ffffff" + display_num="${num}" +} + +# Requires reboot: Red +(echo "${updates}" | grep -qE "^($(get_grep))") && color="#dd0000" + +printf '\uf94f %s' "${color}" "${display_num}"