You are not logged in.

#1 2009-01-20 12:05:05

novus
Member
Registered: 2009-01-16
Posts: 9

Another update notifyer for conky/pacman (with ShowSize support)

I made myself a little bash script to get update notifications in conky

Put

#!/bin/bash
pacman -Sy
return 0;

in /etc/cron.hourly/pmupdate.sh
make it executable

chmod +x /etc/cron.hourly/pmupdate.sh

Put this in ~/.conky/pmupdate.sh (or where ever you see fit)

#!/bin/sh

# Version 1.1.b2
#########################################################################################################################
### configuration setting

# # of packages in output list
list_len=8

# Conky parse code for "system is up to date" line
conky_parse_siutd=

# Conky parse code inserted before every package name
conky_parse_pkg=

# Conky parse code inserted before every package size
conky_parse_size='${goto 160}'

# Show a summary line at the end 'true' or anything
show_summary='true'

# Show remove package summary line at end. Set to 'true' or anything
show_remove_summary='true'

# # of packages in remove list, set to 0 to disable the list
rlist_len=2
# Notice that 'show_remove_summary' MUST be set to 'true' if you want to show a list of those packages

# Conky parse code inserted before summary line
conky_parse_summary=

### End of configuration
#########################################################################################################################

declare -a pkg size
IFS=`echo -en "\n\b"`

    if [ "$show_remove_summary" = 'true' ]; then
    for i in $(pacman -Qu | sed -n '/Remove/,/Total Re/p' | sed 's/\t/\n/; s/: /\n/; s/  /\n/g' | sed 's/^ //; /^$/d' | grep ']' | sed 's/ /!/' | cut -d '!' -f1 ); 
       do rpkg=( "${rpkg[@]}" "$i" )
    done

    for i in $(pacman -Qu | sed -n '/Remove/,/Total Re/p' | sed 's/\t/\n/; s/: /\n/; s/  /\n/g' | sed 's/^ //; /^$/d' | grep ']' | sed 's/ /!/' | cut -d '!' -f2 ); 
       do rsize=( "${rsize[@]}" "$i" )
    done
fi

    for i in $(pacman -Qu | sed 's/\t/\n/; s/: /\n/; s/  /\n/g' | sed -n '/Targets /,$p' | sed 's/^ //; /^$/d' | grep ']' | sed 's/ /!/' | cut -d '!' -f1 ); 
       do pkg=( "${pkg[@]}" "$i" )
    done

    for i in $(pacman -Qu | sed 's/\t/\n/; s/: /\n/; s/  /\n/g' | sed -n '/Targets /,$p' | sed 's/^ //; /^$/d' | grep ']' | sed 's/ /!/' | cut -d '!' -f2 ); 
       do size=( "${size[@]}" "$i" )
    done

IFS=$ORIGIFS
curr=0

if [ "$list_len" -gt "${#pkg[@]}" ]; then list_len=${#pkg[@]}; fi
if [ "$rlist_len" -gt "${#rpkg[@]}" ]; then rlist_len=${#rpkg[@]}; fi


if [ "${#pkg[@]}" = "0" ]; then echo $conky_parse_siutd "System is up to date"; exit 0; fi

while [ $curr != $list_len ]
do
    echo $conky_parse_pkg ${pkg[$curr]} $conky_parse_size ${size[$curr]}
    let "curr += 1"
done

if [ "$show_summary" = "true" ]; then echo $conky_parse_summary "${#pkg[@]} Packages to update"; fi

if [ $show_remove_summary = 'true' ]; then
    if [ "${#rpkg[@]}" -gt "0" ]; then
        echo $conky_parse_siutd "${#rpkg[@]} Packages will be removed"; 
    fi
fi

if [ "$rlist_len" -gt "0" ]; then
    if [ "${#rpkg[@]}" -gt "0" ]; then
            curr=0
            while [ $curr != $rlist_len ]
            do
                echo $conky_parse_pkg ${rpkg[$curr]} $conky_parse_size ${rsize[$curr]}
                let "curr += 1"
            done
    fi
fi

And finally in your .conkyrc

${execpi 900 sh <PATH TO pmupdate.sh>}

edit:
You have to use the ShowSize option for this to work.
edit your /etc/pacman.conf
in the Misc options section theres a line #ShowSize
remove the # in front of that line.

Change log
1.0 First release
1.1.b1 Added support for packages that's going to be removed
1.1.b2 BUG FIX: Output error, sometimes wrong count and bad list due to leading whitespaces

Last edited by novus (2009-01-22 11:58:22)

Offline

#2 2009-01-21 10:25:00

na12
Member
From: /home/serbia
Registered: 2008-12-23
Posts: 752

Re: Another update notifyer for conky/pacman (with ShowSize support)

won't work,always output is System is up to date,but...
[11:17:39 ~]$ pacman -Qu
Checking for package upgrades...

Remove (1): iproute-2.6.26-1 

Total Removed Size:   1.28 MB

Targets (4): iproute2-2.6.28-1  kernel26-2.6.28.1-1  libarchive-2.6.1-1 
             syslog-ng-2.1.3-2 

Total Download Size:    0.00 MB
Total Installed Size:   108.27 MB

Offline

#3 2009-01-21 12:37:32

novus
Member
Registered: 2009-01-16
Posts: 9

Re: Another update notifyer for conky/pacman (with ShowSize support)

na12, U'll need to edit u'r /etc/pacman.conf
in the misc options remove the # in front of ShowSize

I guess I wasn't clear enough in my original post, this script will ONLY work if ShowSize is enabled

Offline

#4 2009-01-21 13:02:22

na12
Member
From: /home/serbia
Registered: 2008-12-23
Posts: 752

Re: Another update notifyer for conky/pacman (with ShowSize support)

it works now,but what is this  ${goto 160}
[12:44:24 ~]$ sh ~/Desktop/pmupdate.sh
iproute-2.6.26-1 ${goto 160} [1.28 MB]
iproute2-2.6.28-1 ${goto 160} [0.48 MB]
kernel26-2.6.28.1-1 ${goto 160} [28.49 MB]
syslog-ng-2.1.3-2 ${goto 160} libarchive-2.6.1-1 [0.34 MB]
4 Packages to update

Last edited by na12 (2009-01-21 13:02:54)

Offline

#5 2009-01-21 13:09:38

novus
Member
Registered: 2009-01-16
Posts: 9

Re: Another update notifyer for conky/pacman (with ShowSize support)

na12 wrote:

it works now,but what is this  ${goto 160}
[12:44:24 ~]$ sh ~/Desktop/pmupdate.sh
iproute-2.6.26-1 ${goto 160} [1.28 MB]
iproute2-2.6.28-1 ${goto 160} [0.48 MB]
kernel26-2.6.28.1-1 ${goto 160} [28.49 MB]
syslog-ng-2.1.3-2 ${goto 160} libarchive-2.6.1-1 [0.34 MB]
4 Packages to update

That is for conky parsing, as this script is intended to be run from conky. put
${execpi 900 sh <PATH TO pmupdate.sh>}

in your conkyrc. if you want to use this script for something else then conky you can remove the goto in the configuration part if the script

Offline

#6 2009-01-21 13:28:23

na12
Member
From: /home/serbia
Registered: 2008-12-23
Posts: 752

Re: Another update notifyer for conky/pacman (with ShowSize support)

I descovered a bug,this is my pacman output:
[14:20:13 ~]$ pacman -Qu
Checking for package upgrades...

Remove (1): iproute-2.6.26-1 [1.28 MB] 

Total Removed Size:   1.28 MB

Targets (4): iproute2-2.6.28-1 [0.48 MB]  kernel26-2.6.28.1-1 [28.49 MB] 
             libarchive-2.6.1-1 [0.34 MB]  syslog-ng-2.1.3-2 [0.18 MB] 

Total Download Size:    0.00 MB
Total Installed Size:   108.27 MB
It can't output that some files has to be removed
[12:44:24 ~]$ sh ~/Desktop/pmupdate.sh
iproute-2.6.26-1 ${goto 160} [1.28 MB]
iproute2-2.6.28-1 ${goto 160} [0.48 MB]
kernel26-2.6.28.1-1 ${goto 160} [28.49 MB]
syslog-ng-2.1.3-2 ${goto 160} libarchive-2.6.1-1 [0.34 MB]
4 Packages to update

Offline

#7 2009-01-21 15:15:09

novus
Member
Registered: 2009-01-16
Posts: 9

Re: Another update notifyer for conky/pacman (with ShowSize support)

na12 wrote:

I descovered a bug,this is my pacman output: (...)

Thank you for reporting it, replace the old script with this

I haven't been able to test it as I already had updated everything when you reported it, but it should work. I'll change the script in the original post when I know it does.

Edit, There was another bug introduced in this fix but it's solved and the original post is updated with a hopefully bug free version

Last edited by novus (2009-01-22 09:59:00)

Offline

#8 2009-01-21 15:27:58

na12
Member
From: /home/serbia
Registered: 2008-12-23
Posts: 752

Re: Another update notifyer for conky/pacman (with ShowSize support)

not work again,it show 5 packages,but there is 8
[11:30:46 ~]$ sh /home/dany/OperaDownloads/pmupdate.sh
banshee-1.4.2-2 ${goto 160} [2.63 MB]
bash-3.2.048-2 ${goto 160} [0.54 MB]
curl-7.19.3-1 ${goto 160} brasero-0.9.1-1 [2.81 MB]
qt-4.4.3-5 ${goto 160} [0.53 MB]
terminator-0.12-1 ${goto 160} db-4.7.25-2 [4.27 MB]
5 Packages to update
[11:31:39 ~]$ pacman -Qu
Checking for package upgrades...

Targets (8): banshee-1.4.2-2 [2.63 MB]  bash-3.2.048-2 [0.54 MB] 
             brasero-0.9.1-1 [2.81 MB]  curl-7.19.3-1 [0.53 MB] 
             db-4.7.25-2 [4.27 MB]  qt-4.4.3-5 [19.20 MB]  rrdtool-1.3.6-1 [0.96 MB] 
             terminator-0.12-1 [0.16 MB] 

Total Download Size:    0.00 MB
Total Installed Size:   99.65 MB

Last edited by na12 (2009-01-22 10:39:16)

Offline

#9 2009-01-22 11:51:15

novus
Member
Registered: 2009-01-16
Posts: 9

Re: Another update notifyer for conky/pacman (with ShowSize support)

na12 wrote:

not work again,it show 5 packages,but there is 8

Are you really using the latest script that's in the first post? I noticed that same bug this morning but it's supposed to be fixed, and I'v tested it with your output and it works for me.

Offline

#10 2009-01-22 12:14:50

na12
Member
From: /home/serbia
Registered: 2008-12-23
Posts: 752

Re: Another update notifyer for conky/pacman (with ShowSize support)

now work perfectly,sorry i used previous script,I didn't saw that you put new

P.S. one suggestion,maybe it will be better use ${alignr} instead  of ${goto 160}

Last edited by na12 (2009-01-22 12:26:50)

Offline

#11 2009-04-17 19:22:42

sPHERE
Member
From: Москва
Registered: 2008-07-01
Posts: 76
Website

Re: Another update notifyer for conky/pacman (with ShowSize support)

Do I need dcron or something for this to work? Just asking.

Offline

Board footer

Powered by FluxBB