View Full Version : Using bash to grep package updates?

April 4th, 2007, 12:38 AM
I'm interested in getting Conky to run a bash script hourly with execi that would grep a list of available packages to update from a dist-upgrade and output them in conky. I got the idea after seeing an Arch Linux user use conky to track the latest uploads to Arch repos. The difference was Arch repos have RSS feeds on package updates so he used the conky RSS plugin. I've been able to find no such Ubuntu repo feeds and so have fallen on this as a method. I figure I can either get a bash script to simulate a dist-upgrade and grep the updates. I've modified visudo to allow it to run like so:

# User privilege specification
root ALL=(ALL) ALL
redline ALL=NOPASSWD: /home/redline/scripts/conky_updates.sh

This is the script I'm using:

# Runs “apt-get update” and prints the output of a simulated
# dist-upgrade if new packages are found.

if [[ `apt-get update 2>&1 | grep Get` ]]; then
if [[ `apt-get –simulate dist-upgrade 2>&1 | grep Inst` ]]; then
apt-get –simulate dist-upgrade
(Sourced from:

Conky however fails to post the results to the desktop and I know there are waiting updates because I see the update manager notification in my panel.

Finally, Here's the conky.rc excerpt:

UPDATES ${hr 2}$color
${execi 1800 /home/redline/scripts/conky_updates.sh}

If anyone wants the full conky.rc or other information it's available on request. Anyone have any advice? What am I doing wrong?

April 4th, 2007, 03:53 AM
Cool idea, could you explain the syntax of execi. As in what does the 1800 mean. I assume an interval but maybe not.

April 4th, 2007, 07:43 AM
1800 is the interval (in seconds) between which to run the shell script. The two lines I provided are excerpted from my Conky configuration file (conky.rc). You can find examples of conky config files and shell scripts for various functions at http://conky.sourceforge.net/screenshots.html

The conky manpage is online at http://conky.sourceforge.net/docs.html

An example of the look I'm trying to emulate can be found on this arch install:
My install presently looks like this:

I feel like everything should be configured correctly but it doesn't output the dist-upgrade results.

Any other questions please let me know. Thanks for your help.

April 4th, 2007, 02:46 PM
if you want rss feed s of ubuntu updates try


April 4th, 2007, 04:10 PM
THANK YOU! ssam, you're the greatest. How did you find about the feed if I might ask?

April 4th, 2007, 06:48 PM
Ok, so here is what /etc/sudoers (visudo) looks like

bruenig ALL=NOPASSWD: /home/bruenig/script

Here is what /home/bruenig/script looks like (slightly modified)


if [[ $(apt-get update 2>&1 | grep Get) ]]; then
if [[ $(apt-get --simulate upgrade 2>&1 | grep Inst) ]]; then
apt-get --simulate upgrade | awk '/Inst/ {print $2}'
echo "No updates"

And here is what the .conkyrc line looks like

${execi 1800 sudo /home/bruenig/script}

Here is what it looks like when there are updates.

Here is what it looks like when there aren't any updates.

April 4th, 2007, 07:06 PM
Thanks a million, bruenig. That's perfect.

April 5th, 2007, 11:39 AM
THANK YOU! ssam, you're the greatest. How did you find about the feed if I might ask?

these have been mentioned on the ubuntu-dev mailing list a few times.