summaryrefslogtreecommitdiff
path: root/dot-config/bspwm/themes/hack/polybar/scripts/updates.sh
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-06-03 19:56:39 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-06-03 19:56:39 +0800
commitca968c4e5040f1ff4b5b5e12d9312360d807dcc1 (patch)
tree9900920e8f566794560c1519678e344351d2803b /dot-config/bspwm/themes/hack/polybar/scripts/updates.sh
parent5f3deaff0bf006a1a353e57b82ad48c0e8f143bc (diff)
added submodules, change . -> dot (see man stow --dotfiles)
Diffstat (limited to 'dot-config/bspwm/themes/hack/polybar/scripts/updates.sh')
-rwxr-xr-xdot-config/bspwm/themes/hack/polybar/scripts/updates.sh47
1 files changed, 47 insertions, 0 deletions
diff --git a/dot-config/bspwm/themes/hack/polybar/scripts/updates.sh b/dot-config/bspwm/themes/hack/polybar/scripts/updates.sh
new file mode 100755
index 00000000..105584a2
--- /dev/null
+++ b/dot-config/bspwm/themes/hack/polybar/scripts/updates.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+
+## Copyright (C) 2020-2022 Aditya Shakya <adi1090x@gmail.com>
+
+NOTIFY_ICON=/usr/share/icons/Papirus/32x32/apps/system-software-update.svg
+
+get_total_updates() { UPDATES=$(checkupdates 2>/dev/null | wc -l); }
+
+while true; do
+ get_total_updates
+
+ # notify user of updates
+ if hash notify-send &>/dev/null; then
+ if (( UPDATES > 50 )); then
+ notify-send -u critical -i $NOTIFY_ICON \
+ "You really need to update!!" "$UPDATES New packages"
+ elif (( UPDATES > 25 )); then
+ notify-send -u normal -i $NOTIFY_ICON \
+ "You should update soon" "$UPDATES New packages"
+ elif (( UPDATES > 2 )); then
+ notify-send -u low -i $NOTIFY_ICON \
+ "$UPDATES New packages"
+ fi
+ fi
+
+ # when there are updates available
+ # every 10 seconds another check for updates is done
+ while (( UPDATES > 0 )); do
+ if (( UPDATES == 1 )); then
+ echo " $UPDATES"
+ elif (( UPDATES > 1 )); then
+ echo " $UPDATES"
+ else
+ echo " None"
+ fi
+ 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
+ echo " None"
+ sleep 1800
+ get_total_updates
+ done
+done