feat(waybar): show pacman updates available

This commit is contained in:
Price Hiller 2023-06-03 14:54:12 -05:00
parent 0b8cabcf5a
commit 0e797ea18f
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8
3 changed files with 33 additions and 0 deletions

View File

@ -17,6 +17,7 @@
"custom/media" "custom/media"
], ],
"modules-right": [ "modules-right": [
"custom/pacman-update",
"custom/asusmode", "custom/asusmode",
"network", "network",
"clock", "clock",
@ -195,6 +196,14 @@
"return-type": "json", "return-type": "json",
"on-click": "playerctl play-pause", "on-click": "playerctl play-pause",
"exec": "~/.config/waybar/scripts/get-media.bash" "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
} }
} }
] ]

View File

@ -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

View File

@ -66,6 +66,7 @@
#clock, #clock,
#wireplumber, #wireplumber,
#image, #image,
#custom-pacman-update,
#custom-lock { #custom-lock {
background-color: #16161d; background-color: #16161d;
color: #dcd7ba; color: #dcd7ba;
@ -221,6 +222,11 @@
background-color: #ff5d62; background-color: #ff5d62;
} }
/* Pacman Updates */
#custom-pacman-update {
color: #7E9CD8;
}
/* Asus Fan Mode */ /* Asus Fan Mode */
#custom-asusmode { #custom-asusmode {
color: #ffa066; color: #ffa066;