From 381ab705c4e9f79cbbc3bc2c990409cf90f2ba3d Mon Sep 17 00:00:00 2001 From: Adam Gausmann Date: Wed, 4 Jun 2025 11:30:50 -0500 Subject: [PATCH] add waybar-void-update-checker --- templates/.config/waybar/config.jsonc.j2 | 9 +++++++++ templates/bin/waybar-void-update-checker | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100755 templates/bin/waybar-void-update-checker diff --git a/templates/.config/waybar/config.jsonc.j2 b/templates/.config/waybar/config.jsonc.j2 index 026cd8a..0748d94 100644 --- a/templates/.config/waybar/config.jsonc.j2 +++ b/templates/.config/waybar/config.jsonc.j2 @@ -10,6 +10,7 @@ "modules-center": [ ], "modules-right": [ + "custom/void-updates", {% for iface in host.wireless + host.ethernet %} "network#{{ iface }}", @@ -37,6 +38,14 @@ "niri/workspaces": { "format": "\uf111" }, + + "custom/void-updates": { + "exec": "waybar-void-update-checker", + "hide-empty-text": true, + "return-type": "json", + // every 7 hours + "interval": 25200, + }, {% for iface in host.wireless %} "network#{{ iface }}": { diff --git a/templates/bin/waybar-void-update-checker b/templates/bin/waybar-void-update-checker new file mode 100755 index 0000000..9ab6307 --- /dev/null +++ b/templates/bin/waybar-void-update-checker @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +info="$(xbps-install -Mun)" + +PKG_COUNT="$(echo "$info" | wc -l)" +[ $PKG_COUNT -eq 0 ] && exit + +DL_SIZE="$(echo "$info" | awk '{s+=$6}END{print s}' | numfmt --to=iec-i)B" + +echo '{"text": "\uf468 '"$PKG_COUNT"'", "tooltip": "'"$PKG_COUNT"' packages have updates; '"$DL_SIZE"' download"}'