From 7ab17e5f76a4b965d919053b54dec967ffdb67ce Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 5 Dec 2018 12:17:45 +0100 Subject: [PATCH] Mark packages requiring a system reboot Signed-off-by: Knut Ahlers --- .config/i3blocks/arch-update | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.config/i3blocks/arch-update b/.config/i3blocks/arch-update index 1f066ce..831213f 100755 --- a/.config/i3blocks/arch-update +++ b/.config/i3blocks/arch-update @@ -1,7 +1,24 @@ #!/bin/bash set -euo pipefail -u=$(checkupdates | wc -l) -[ $u -gt 0 ] || exit +req_restart_prefix=( + linux + systemd +) -printf "\uf94f %d %s" $u $(${HOME}/bin/pluralize Update $u) +function get_grep() { + local IFS_bak="${IFS}" + IFS="|" + echo "${req_restart_prefix[*]}" + IFS="${IFS_bak}" +} + +updates=$(checkupdates) + +num=$(echo "${updates}" | wc -l) +[ $num -gt 0 ] || exit + +req_restart="" +echo "${updates}" | grep -qE "^($(get_grep)) " && req_restart=' (reboot)' + +printf "\uf94f %d %s%s" $num $(${HOME}/bin/pluralize Update $num) "${req_restart}"