diff --git a/dots/.config/waybar/config b/dots/.config/waybar/config index 716e544b..a586fcc8 100644 --- a/dots/.config/waybar/config +++ b/dots/.config/waybar/config @@ -17,6 +17,7 @@ "custom/media" ], "modules-right": [ + "custom/pacman-update", "custom/asusmode", "network", "clock", @@ -195,6 +196,14 @@ "return-type": "json", "on-click": "playerctl play-pause", "exec": "~/.config/waybar/scripts/get-media.bash" + }, + "custom/pacman-update": { + "return-type": "json", + "exec": "~/.config/waybar/scripts/get-pacman-package-updates.bash", + "exec-if": "((\"$(checkupdates | wc -l)\" > 0))", + "format": "󰇚 {}", + "tooltip": true, + "interval": 10 } } ] diff --git a/dots/.config/waybar/scripts/get-pacman-package-updates.bash b/dots/.config/waybar/scripts/get-pacman-package-updates.bash new file mode 100755 index 00000000..83c1d480 --- /dev/null +++ b/dots/.config/waybar/scripts/get-pacman-package-updates.bash @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +main() { + local package_updates + package_updates="$(checkupdates | cut -d " " -f1)" + package_update_number="$(printf "%s" "${package_updates}" | wc -l)" + + # Limit the number of results shown to ten, add trailing ellipsis + if ((package_update_number > 10)); then + package_updates="$(printf "%s" "${package_updates}" | head -n 10)" + package_updates+="\n..." + fi + + + printf '{"text": "%s", "tooltip": "%s"}\n' "${package_update_number}" "${package_updates//$'\n'/\\n}" +} + +main diff --git a/dots/.config/waybar/style.css b/dots/.config/waybar/style.css index 37732ccc..cd9206ac 100644 --- a/dots/.config/waybar/style.css +++ b/dots/.config/waybar/style.css @@ -66,6 +66,7 @@ #clock, #wireplumber, #image, +#custom-pacman-update, #custom-lock { background-color: #16161d; color: #dcd7ba; @@ -221,6 +222,11 @@ background-color: #ff5d62; } +/* Pacman Updates */ +#custom-pacman-update { + color: #7E9CD8; +} + /* Asus Fan Mode */ #custom-asusmode { color: #ffa066;