Hi, I have to first say, I love this distro! My first archlinux distro, and I dont think I would ever switch to anything else! I have used multiple DEs as well as WM, and I decided to stay with openbox, its truly amazing with polybar and plank, etc, lots of customization’s, which I love! I am a beginner/intermediate linux user, I am trying to learn more, so any help and guidance would be greatly appreciated!
The issue I am having is that the updates module in polybar will not update if it has less than 1 update available. For example, it says I have this many number of updates, I perform the updates, but the reading on the bar is stuck at 1…I am copying information here, to see if anyone can help me:
This is from the polybar modules.conf file:
;;;;;;;;;
;; PKG ;;
;;;;;;;;;
[module/pkg]
type = custom/script
exec = updates.sh
exec-if = "ping -q -w 2 -c 1 176.34.135.167 > /dev/null"
label-padding = 1
label = %output%
tail = true
This is from my updates.sh file:
#!/usr/bin/env bash
BAR_ICON=""
NOTIFIED=0
NOTIFY_ICON=/usr/share/icons/gnome/32x32/apps/system-software-update.png
get_total_updates()
{
UPDATES=$(checkupdates 2>/dev/null | wc -l)
}
while true; do
# print the icon first to avoid gibberish in polybar
echo $BAR_ICON
get_total_updates
# notify user of updates
if (( NOTIFIED == 0 )) && hash notify-send >/dev/null 2>&1; then
if (( UPDATES > 50 )); then
notify-send -u critical -i $NOTIFY_ICON "Updates Available" "$UPDATES packages"
elif (( UPDATES > 25 )); then
notify-send -u normal -i $NOTIFY_ICON "Updates Available" "$UPDATES packages"
elif (( UPDATES > 2 )); then
notify-send -u low -i $NOTIFY_ICON "Updates Available" "$UPDATES packages"
fi
NOTIFIED=1
fi
# when there are updates available
# every 10 seconds another check for updates is done
while (( UPDATES > 0 )); do
(( UPDATES == 1 )) && echo "$UPDATES Update" || { (( UPDATES > 1 )) && echo "$UPDATES Updates"; }
sleep 10
get_total_updates
done
# when no updates are available, use a longer loop, this saves on CPU
# and network uptime, only checking once every 30 min for new updates
while (( UPDATES == 0 )); do
sleep 1800
get_total_updates
done
done
I am thinking that within the updates.sh file near the bottom there where is says while … I need to modify something there but im not sure what that would be…
Any help/guidance would be greatly appreciated! Also as a side note, does anyone have any book or something I could read in my spare time to do shell scripting so that I could have solved this myself? I am a firm believer of give a man a fish, he eats for a day, teach me to fish, so I can ‘eat’ my entire life! hahah
Thanks!