You are not logged in.

#1 2008-10-18 22:33:01

Kooothor
Member
From: Paname
Registered: 2008-08-02
Posts: 226

[request filled] Conky script to get the number of pacman updates

Hi everyone,

I'm not very good at scripting but I would like to have something that displays :

UPDATE : 2 new packages

in my conky smile
All the other pacman scripts I found were too complicated, here I just want to know how many packages are waiting for upgrade.
I already have a pacman -Sy cronified hourly.

How can one manage to do that, any help appreciated !

Regards,


~ktr

Last edited by Kooothor (2008-10-19 11:03:40)


ktr

Offline

#2 2008-10-18 22:58:58

haxit
Member
From: /home/haxit
Registered: 2008-03-04
Posts: 1,247
Website

Re: [request filled] Conky script to get the number of pacman updates

Have you tried lyraes?


Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.

Offline

#3 2008-10-18 23:09:45

Kooothor
Member
From: Paname
Registered: 2008-08-02
Posts: 226

Re: [request filled] Conky script to get the number of pacman updates

/me don't know what it is....


ktr

Offline

#4 2008-10-18 23:28:31

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [request filled] Conky script to get the number of pacman updates

I take it that you've seen all of these:
http://bbs.archlinux.org/viewtopic.php?id=53761
http://bbs.archlinux.org/viewtopic.php?id=44023
http://bbs.archlinux.org/viewtopic.php?id=37284


You can try this:

#!/usr/bin/perl
use strict;
use warnings;
print ((`pacman -Qu` =~ m/^[^\s]+\s\((\d+)\):/m) ? $1 : 0);

Save it as "list_upgradable.pl", make it executable (chmod 755 list_upgradable.pl), then invoke it to get the number of upgradable packages.

I have some other code snippets to display more info if you want more than just the number of packages.

*edit*
This script does not update the database for you. You need to use cron to do that. Take a look at this post below to see how.

Last edited by Xyne (2009-06-10 20:19:40)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#5 2008-10-18 23:56:46

Kooothor
Member
From: Paname
Registered: 2008-08-02
Posts: 226

Re: [request filled] Conky script to get the number of pacman updates

Hi Xyne,

exactly smile


Xyne wrote:

You can try this:

#!/usr/bin/perl
use strict;
use warnings;
print ((`pacman -Qu` =~ m/^[^\s]+\s\((\d+)\):/m) ? $1 : 0);

Thanks, it seems to work fine big_smile and it's simple !
I'll tell you if it's truly fine when I have something to update !

Xyne wrote:

I have some other code snippets to display more info if you want more than just the number of packages.

Thanks, but I'd like to keep it simple smile

Last edited by Kooothor (2008-10-19 00:02:43)


ktr

Offline

#6 2008-10-19 00:09:22

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [request filled] Conky script to get the number of pacman updates

Kooothor wrote:
Xyne wrote:

I have some other code snippets to display more info if you want more than just the number of packages.

Thanks, but I'd like to keep it simple smile

Don't worry, I was just thinking of some simple one-line sentence depending on whether there are updatable packages (e.g. "nothing to update", "1 package waiting for update", "x packages waiting for update").

I'm glad I could help anyway.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#7 2008-10-19 00:21:22

Kooothor
Member
From: Paname
Registered: 2008-08-02
Posts: 226

Re: [request filled] Conky script to get the number of pacman updates

Xyne wrote:

simple one-line sentence depending on whether there are updatable packages (e.g. "nothing to update", "1 package waiting for update", "x packages waiting for update").

Interesting, please post it big_smile


ktr

Offline

#8 2008-10-19 02:02:55

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [request filled] Conky script to get the number of pacman updates

#!/usr/bin/perl
use strict;
use warnings;
my $n = ((`pacman -Qu` =~ m/^[^\s]+\s\((\d+)\):/m) ? $1 : 0);
if ($n == 0)
{
     print "nothing to update"
}
elsif($n == 1)
{
     print "1 new package"
}
else
{
     print "$n new packages"
}

Just change the output to whatever you want.

Last edited by Xyne (2008-10-19 02:03:27)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#9 2008-10-19 09:28:38

Vintendo
Member
From: Netherlands
Registered: 2008-04-21
Posts: 375
Website

Re: [request filled] Conky script to get the number of pacman updates

Thanks this was exactly what i needed.

Offline

#10 2008-10-19 10:52:19

Kooothor
Member
From: Paname
Registered: 2008-08-02
Posts: 226

Re: [request filled] Conky script to get the number of pacman updates

Nice, thanks smile


ktr

Offline

#11 2008-12-19 16:34:27

linko
Member
From: Mississippi
Registered: 2008-12-06
Posts: 16

Re: [request filled] Conky script to get the number of pacman updates

Thanks Xyne, nice script.

Offline

#12 2009-06-08 22:26:56

luuuciano
Member
Registered: 2007-01-27
Posts: 310

Re: [request filled] Conky script to get the number of pacman updates

but this needs root access?
or let normal user to run pacman?

Last edited by luuuciano (2009-06-08 22:27:08)


I arch, you arch, he arch, she arch, we arch, they arch...

Offline

#13 2009-06-08 22:29:27

SkonesMickLoud
Arch Linux f@h Team Member
From: The D of C
Registered: 2008-09-20
Posts: 178

Re: [request filled] Conky script to get the number of pacman updates

luuuciano wrote:

but this needs root access?
or let normal user to run pacman?

No root access needed.  This script doesn't actually do anything.  Doesn't download or install anything.  Just finds out how many packages are avaliable for update.

Last edited by SkonesMickLoud (2009-06-08 22:31:00)

Offline

#14 2009-06-10 18:52:21

k3ttc4r
Member
From: around somewhere
Registered: 2008-12-28
Posts: 137
Website

Re: [request filled] Conky script to get the number of pacman updates

somehow this script always shows me "nothing to update" until i 'manually' run pacman -Qu in a terminal, which renders it pretty useless sad


arch64   ||   github | dotshare | blog

Offline

#15 2009-06-10 20:17:40

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [request filled] Conky script to get the number of pacman updates

k3ttc4r wrote:

somehow this script always shows me "nothing to update" until i 'manually' run pacman -Qu in a terminal, which renders it pretty useless sad

Running "pacman -Qu" doesn't update anything. You must mean "pacman -Sy". The script isn't meant to update the database for you. You need to use cron to do that. Just add a script to /etc/cron.hourly so it gets updated, e.g.

#!/bin/bash
pacman -Sy 1>/dev/null 2>&1

You could also use rebase to update the database if you want to avoid unnecessary writing to the disk.

Btw, for anyone interesting in the script that I posted above, take a look at paconky.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#16 2009-06-10 22:16:39

k3ttc4r
Member
From: around somewhere
Registered: 2008-12-28
Posts: 137
Website

Re: [request filled] Conky script to get the number of pacman updates

yeah, pacman -Sy, that's what i meant..

now that you pointed it out to me, i could have gotten it myself tongue
thanks, though!


arch64   ||   github | dotshare | blog

Offline

#17 2009-08-12 15:36:59

userlander
Member
Registered: 2008-08-23
Posts: 413

Re: [request filled] Conky script to get the number of pacman updates

This script suddenly stopped working for me after working great for months. I call it from .conkyrc with

${execi 30 /home/user/bin/pacman-updates}

with /home/user/bin/pacman-updates being:

#!/usr/bin/perl
## script by Xyne
## http://bbs.archlinux.org/viewtopic.php?id=57291

use strict;
use warnings;
my $n = ((`pacman -Qu` =~ m/^[^\s]+\s\((\d+)\):/m) ? $1 : 0);
if ($n == 0)
{
     print "No new packages"
}
elsif($n == 1)
{
     print "1 new package"
}
else
{
     print "$n new packages"
}

pacman -Sy is in crontab, and pacman -Qu shows the update. All the other conky execi variable stuff is working (lm_sensors, gmail update, etc.) anyone see why pacman script isn't updating??

Offline

#18 2009-08-12 16:33:44

luuuciano
Member
Registered: 2007-01-27
Posts: 310

Re: [request filled] Conky script to get the number of pacman updates


I arch, you arch, he arch, she arch, we arch, they arch...

Offline

#19 2009-08-12 19:00:05

userlander
Member
Registered: 2008-08-23
Posts: 413

Re: [request filled] Conky script to get the number of pacman updates

muchas gracias!


>> edit: small update. I  added

chomp ($n);

before the if statement to prevent the last condition from printing out on two lines. current script:

#!/usr/bin/perl
## script by Xyne
## http://bbs.archlinux.org/viewtopic.php?id=57291
use strict;
use warnings;
my $n = (`pacman -Qu | wc -l`);
chomp ($n);
if ($n == 0)
{
     print "No new packages"
}
elsif($n == 1)
{
     print "1 new package"
}
else
{
print "$n new packages " 
}

Last edited by userlander (2009-08-15 16:42:02)

Offline

#20 2010-03-05 22:49:30

shura
Member
Registered: 2010-03-05
Posts: 1

Re: [request filled] Conky script to get the number of pacman updates

pacman -Qu | wc -l

Offline

#21 2010-03-05 22:59:23

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [request filled] Conky script to get the number of pacman updates

shura wrote:

pacman -Qu | wc -l

Welcome to the forums shura. Please look over the rules, specifically necro-bumping http://wiki.archlinux.org/index.php/For … Bumping.27

This solution was also posted in luuuciano's link above.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#22 2010-03-06 12:43:39

Roline
Member
From: Netherlands
Registered: 2009-12-05
Posts: 207
Website

Re: [request filled] Conky script to get the number of pacman updates

Technically i'm not necrobumping right now, anyway. I can't get the cronjob to work. I added the script to the folder /etc/cron.hourly but it doesn't update... Cocky stays at 0 untill I update pacman myself.


Bitbucket - DeviantART - Userstyles
*Currently Not Using Arch

Offline

#23 2010-03-06 19:48:51

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [request filled] Conky script to get the number of pacman updates

Roline - please apply some common sense, and stick to the guidelines. Read the link posted above for full details.

Closed.

Offline

Board footer

Powered by FluxBB