You are not logged in.

#1 2011-03-18 01:41:40

metre
Member
Registered: 2011-03-13
Posts: 130

[SOLVED] Conky config: show packages number

Hi there,
how can I do this?
Is this possible only through a script, like 'pacman -Q | wc -l'? Or can I do it through conky, directly?
Thank you in advance

Last edited by metre (2011-03-18 10:28:28)

Offline

#2 2011-03-18 01:48:53

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,356

Re: [SOLVED] Conky config: show packages number

Your question is unclear. What number? If you mean simply the total count of installed packages, then yes that command would output the right number.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#3 2011-03-18 05:08:39

mekh
Member
Registered: 2011-01-31
Posts: 11

Re: [SOLVED] Conky config: show packages number

Hi.
You could try somthing like this in ~/.conkyrc:
Update: ${alignr}${execi 600 sudo pacman -Sy >/dev/null 2>&1 &&  pacman -Qu | wc -l} package(s)

But before that you have to edit /etc/sudoers:
username ALL=(ALL) ALL, NOPASSWD: /usr/bin/pacman -Sy

Last edited by mekh (2011-03-18 05:11:59)

Offline

#4 2011-03-18 07:05:25

ViruSzZ
Member
From: The Streets
Registered: 2010-10-14
Posts: 202
Website

Re: [SOLVED] Conky config: show packages number

mekh wrote:

Hi.
You could try somthing like this in ~/.conkyrc:
Update: ${alignr}${execi 600 sudo pacman -Sy >/dev/null 2>&1 &&  pacman -Qu | wc -l} package(s)

But before that you have to edit /etc/sudoers:
username ALL=(ALL) ALL, NOPASSWD: /usr/bin/pacman -Sy

I`m using this simple bash script to get the number of packages in my conky & I`m executing it in the conky like this: ${execi 600 sudo /path/to/script}

#!/bin/bash
#
_pacPackages=`pacman -Qu | wc -l`
pacman -Syy >/dev/null 2>&1
if [ $_pacPackages -eq 0 ];
then
        echo "No new packages";
elif [ $_pacPackages -eq 1 ];
then
        echo "1 new package";
else
        echo "$_pacPackages new packages";
fi
exit 0

Their Momma Made Em, Their Momma Gave em & now she can`t even SAVE`em | My WebLog

Offline

#5 2011-03-18 09:36:41

mekh
Member
Registered: 2011-01-31
Posts: 11

Re: [SOLVED] Conky config: show packages number

ViruSzZ wrote:

I`m using this simple bash script to get the number of packages in my conky & I`m executing it in the conky like this: ${execi 600 sudo /path/to/script}

What about sudo and root password entering?

Actualy my code doesn't work properly sometimes (only for me?). If you try to execute that comand (sudo pacman -Sy >/dev/null 2>&1 &&  pacman -Qu | wc -l) in console - it always works great, but in conky it may displays nothing (sometimes).
The solution is to separate command into two lines:

.....
${font Poky:size=12}i${font}   Update: ${alignr}${execi 600 pacman -Qu | wc -l} package(s)
.....
#Bottom of ~/.conkyrc 
${execi 600 sudo pacman -Sy >/dev/null 2>&1}

I don't know the reason why it so, but in my case it's a fact.

Here is my conky screenshot.
conkys.th.jpg

Last edited by mekh (2011-03-18 09:53:11)

Offline

#6 2011-03-18 09:59:44

ViruSzZ
Member
From: The Streets
Registered: 2010-10-14
Posts: 202
Website

Re: [SOLVED] Conky config: show packages number

mekh wrote:
ViruSzZ wrote:

I`m using this simple bash script to get the number of packages in my conky & I`m executing it in the conky like this: ${execi 600 sudo /path/to/script}

What about sudo and root password entering?

Here is my conky screenshot.
http://img200.imageshack.us/img200/4165/conkys.th.jpg

I think I added a sudoers entry to allow passwordless sudo on this script. It is something like this:

_USERNAME_ ALL=(ALL) NOPASSWD: /path/to/pacman_script

Also, this part in the script 'pacman -Syy >/dev/null 2>&1' should look like this 'sudo pacman -Syy >/dev/null 2>&1'.


Their Momma Made Em, Their Momma Gave em & now she can`t even SAVE`em | My WebLog

Offline

#7 2011-03-18 10:27:38

metre
Member
Registered: 2011-03-13
Posts: 130

Re: [SOLVED] Conky config: show packages number

ngoonee wrote:

Your question is unclear. What number? If you mean simply the total count of installed packages, then yes that command would output the right number.

You're right, I spoke in 'engrish'. Shame on me: I meant a check for total number of installed packages.
Anyway, as usual, very useful and interesting answers.

So, in the end I used:

Conky

${color red}Packages:$color ${execi 600 /pkgnum}

and

Script

#!/bin/bash

pkgg=`pacman -Q | wc -l`
echo "$pkgg"

Thank you! smile

Offline

Board footer

Powered by FluxBB