Tuesday, March 23, 2021

Update notifications in Conky

 

An improved Conky system updates notification for Debian (The first version and information on how to enable package list update if you are not using Gnome, which I assume you're not, as Gnome already has update notifications.). This one includes the time of the last package list update so you can see that the system is actually checking for updates, and tells you if there are any security updates (it should list package names to if there are security updates, but I haven't been able to test this yet.) The script requires aptitude.

I used the following code:

Linux - display or upgrade security updates only using apt

How to know last time `apt-get update` was executed?

if_match in Conky

DevHumor

Here's the code:

${if_match ${execi 1800 aptitude search "~U" | wc -l}==0}\ ${alignr}No updates available ${alignr}${color grey}Last check:${color} ${execi 1800 ls -l /var/cache/apt/pkgcache.bin | awk '{print $6,$7,$8}'} ${else}${alignr}Updates available: ${execi 1800 aptitude search "~U" | wc -l} ${alignr}Security: ${execi 1800 aptitude search '~U ~ODebian' -F "%p %O"|awk '/Debian-Security/' | wc -l}  ${execi 1800 aptitude search '~U ~ODebian' -F "%p %O"|awk '/Debian-Security/ {print $1}'} ${endif}

EDIT:

Replaced

${execi 1800 ls -l /var/cache/apt/pkgcache.bin | cut -d' ' -f6,7,8}

with

${execi 1800 ls -l /var/cache/apt/pkgcache.bin | awk '{print $6,$7,$8}'}

The first command would only output the date when the date was one digit only.

[Edit 24/8/21: Bullseye is now released and the first security updates have arrived, allowing me to test the script. I have corrected a typo which meant number of security updates was not displayed.]




No comments:

Post a Comment