You are not logged in.

#1 2010-12-14 03:10:05

presentgear
Member
Registered: 2010-12-14
Posts: 15

conky doesn't always show output from bash script

Hi all - I'm a new Arch user, recently upgraded from Mint. So far I'm loving my Openbox setup on my netbook, with one little problem.

I was inspired by this for my conky system monitor:
https://bbs.archlinux.org/viewtopic.php?id=37284

but I don't know python, barely know bash and wanted to learn something about pacman by doing it myself.  I've got the "pacman -Sy" sync script in my cron.hourly and the following script works fine in the shell and SOMETIMES in the conky display.

#!/bin/bash
#return the download size of the packages needing updates

rm -f /tmp/list.txt
rm -f /tmp/sizey.txt

pacman -Qu | awk '{print $1}' > /tmp/list.txt

if [ ! -s /tmp/list.txt ]; then
     echo "UPDATED"
else
    size=0
    cat /tmp/list.txt |while read pkgname; do
        tempsize=$(cat /var/lib/pacman/sync/*/$pkgname*/desc | grep -A 1 %CSIZE% | grep -v %CSIZE%)
        size=$(($size + $tempsize))
        echo $size > /tmp/sizey.txt
    done

    sizey=$(cat /tmp/sizey.txt)
    sizemb=$(($sizey / 1048576))
    pkgnumber=$(pacman -Qu | wc -l)
    echo "$pkgnumber,$sizemb MB"
fi

running in the shell right now gives:

sh pacsize.sh

4,0 MB

(meaning 4 packages need updating, with less than 1MB to download)  I'm not blessed with screen space on my netbook, so this output is all I need.

This is in my conkyrc: ${execi 3650 sh pacsize.sh}

Twice now I have seen the output show up as expected, and then later that day show nothing.  This is happening right now - but, as above, the script is working.  One thing I noticed is that it takes just over a second for the script to finish in the shell.  This makes sense because it has to scan through the entire /var/lib/pacman/sync folder.

My theory for this inconsistent behavior is that the script takes to long to finish and therefore "misses" the window of time that conky allows during each refresh.  I am not a programmer, so this theory is probably overly simplistic, but I need some help.  Any ideas or ways to diagnose how conky is handling my script?

Offline

#2 2010-12-14 03:36:40

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,543

Re: conky doesn't always show output from bash script

presentgear wrote:

Twice now I have seen the output show up as expected, and then later that day show nothing.  This is happening right now - but, as above, the script is working.  One thing I noticed is that it takes just over a second for the script to finish in the shell.  This makes sense because it has to scan through the entire /var/lib/pacman/sync folder.

My theory for this inconsistent behavior is that the script takes to long to finish and therefore "misses" the window of time that conky allows during each refresh.  I am not a programmer, so this theory is probably overly simplistic, but I need some help.  Any ideas or ways to diagnose how conky is handling my script?

You could try setting the value of update_interval to some value larger than 1 and see if it resolves the problem.

Offline

#3 2010-12-14 04:03:17

presentgear
Member
Registered: 2010-12-14
Posts: 15

Re: conky doesn't always show output from bash script

Ha! It works!

I guess I assumed the update interval was the time between "instantaneous" updates.  Good to know.  Thanks skunktrader.


EDIT:
This does make my cpu and network load monitors less informative with the delay... Guess I should go for a faster script.

Last edited by presentgear (2010-12-14 04:05:06)

Offline

Board footer

Powered by FluxBB