You are not logged in.
Pages: 1
Topic closed
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
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
Have you tried lyraes?
Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.
Offline
/me don't know what it is....
ktr
Offline
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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Hi Xyne,
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
exactly
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 and it's simple !
I'll tell you if it's truly fine when I have something to update !
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
Last edited by Kooothor (2008-10-19 00:02:43)
ktr
Offline
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
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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
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
ktr
Offline
#!/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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Thanks this was exactly what i needed.
Offline
Nice, thanks
ktr
Offline
Thanks Xyne, nice script.
Offline
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
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
Offline
somehow this script always shows me "nothing to update" until i 'manually' run pacman -Qu in a terminal, which renders it pretty useless
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 Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Offline
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
I arch, you arch, he arch, she arch, we arch, they arch...
Offline
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
pacman -Qu | wc -l
Offline
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.
Offline
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
Roline - please apply some common sense, and stick to the guidelines. Read the link posted above for full details.
Closed.
Offline
Pages: 1
Topic closed