You are not logged in.

#26 2007-12-14 03:48:12

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: dzen & xmobar Hacking Thread

thayer wrote:
buttons wrote:

...I really, really want to use these full-colour xpms but the cpu usage is too high on my laptop for something that updates every second.  I'll stick to my zsh scripts (running every 5-15 minutes) for these, but the rest looks pretty useful.

Hey buttons, out of curiosity how much of a difference are you seeing with the xpm's?  I'm using a full bar of xpm images, but I only see about a 1% difference in cpu usage (and at that level, it's hard to say whether it's actually from the xpm's) between my xpm-enabled conkyrc and plain text conkyrc.

With conky-cli|dzen2 updating every 1 second, my cpu utilization is about 2%/1% idling (dual core).  With the xpms drawn, it's about 2%/3%. 

With my bash|dzen2 config updating every 3 seconds, I was idling at 10%/10% and spiking up to 30% every other second.

!

It depends on what's in your monitoring app, obviously, but I was seeing 0 CPU usage idling zsh|dzen2, and now about 1-2% CPU usage idling with conky|dzen2.  Both with a couple xpms.

Thing is, the conky script (with xpms) updates much, much, much more often than my dzen (I have one called dzenlong, which updates weather and pacman every 15 minutes), while conky updates each second.  The problem is with the constant updates.

Currently I'm using the following:
CPU: gpubar 0.0
Battery: gdbar + zsh + dzen, XBM 0.0
Weather and Updates: perl scripts + dzen + XPM 0.0
Date: dzen + zsh 0.0

I guess CPU and battery are the only ones updating every second, but with XBM (not colour!) they don't use any CPU even with zsh.


Cthulhu For President!

Offline

#27 2007-12-14 04:44:39

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: dzen & xmobar Hacking Thread

You are aware that conky's update interval can be changed in .conkyrc, right? I use 2 seconds, but you could easily change it to 15 secs or even 10 minutes:

update_interval 15
#update_interval 600

That's food for thought though and thanks for posting your findings (I've been wanting to benchmark a bit more myself, but I'm busy with finals.)


thayer williams ~ cinderwick.ca

Offline

#28 2007-12-14 04:51:23

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: dzen & xmobar Hacking Thread

Sure, but then the nicest parts of conky (easy cpu, mem, netspeed, etc) are mostly useless.  Of course, I could make a SEPARATE conky/dzen, but then I'm already using separate dzens...

Blarg.

I think the worst problem is 1280 is just not enough pixels to fit all the crap I'd like to put in a bar sad

EDIT: Good luck with finals!  I just had my final yesterday, now I'm avoiding christmas-break work wink

Last edited by buttons (2007-12-14 04:52:10)


Cthulhu For President!

Offline

#29 2007-12-14 05:13:40

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: dzen & xmobar Hacking Thread

200712140007261440x900skd8.th.png

Aaaand then again, conky is enormously convenient!

Um...simple battery icon switcher for dzen:

#!/bin/zsh

# vim: ft=zsh ts=4

icon() {
    
    ac_state=`cat /proc/acpi/ac_adapter/AC/state |grep off-line`

    if [[ $ac_state == "" ]]; then
        print -n "^i(/home/buttons/.bitmaps/power-ac.xbm)"
    else
        print -n "^i(/home/buttons/.bitmaps/power-bat.xbm)"
    fi
}

print "$(icon)"

Yeah, you could probably put that IN the conky code, but I prefer ${exec} for cleanliness.

We'll see if I hate it and switch back to 4 dzens tongue  I kinda miss gcpubar already.


Cthulhu For President!

Offline

#30 2007-12-14 19:44:24

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: dzen & xmobar Hacking Thread

If anyone is using weather.com's official interface perl script, I discovered today that weather.com had changed their icons somewhat, and the ones you'll find linked from Rob's site aren't totally correct.  For instance, the icon for Partly Cloudy shows up as "HOT".  At 6C, that's not the word I would've used.

So anyway, when you sign up for weather.com's xml thingie they give you a link to their SDK, which is a zip file full of icons and some other useless things.  Go into the 32x32 folder and run the following (requires imagemagick):

#!/bin/sh
for i in `ls`; do
convert -resize 14x14 $i $i
convert $i `echo $i | sed -e 's/\.png/-scaled\.xpm/'`
rm $i
done

Good as new!  A whole directory full of nice, scaled xpms for your use.

Should look like this:
weatherpreviewjw9.png

There now, that's a bit more truthful than "HOT."


Cthulhu For President!

Offline

#31 2007-12-14 20:27:42

cu3edweb
Member
From: USA
Registered: 2007-10-07
Posts: 291

Re: dzen & xmobar Hacking Thread

I know this is a little off topic but what gtk theme do you use buttons?

Offline

#32 2007-12-14 21:39:10

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: dzen & xmobar Hacking Thread

cu3edweb wrote:

I know this is a little off topic but what gtk theme do you use buttons?

Divinorum.  The green version, obv wink


Cthulhu For President!

Offline

#33 2007-12-16 02:32:02

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

buttons wrote:

If anyone is using weather.com's official interface perl script, I discovered today that weather.com had changed their icons somewhat, and the ones you'll find linked from Rob's site aren't totally correct.  For instance, the icon for Partly Cloudy shows up as "HOT".  At 6C, that's not the word I would've used.

So anyway, when you sign up for weather.com's xml thingie they give you a link to their SDK, which is a zip file full of icons and some other useless things.  Go into the 32x32 folder and run the following (requires imagemagick):

Thanks for pointing this out. The weather script also cotains some alternative icons which are somewhat ugly, though the ones from weather.com are really nice and most importantly correct smile.

#!/bin/sh
for i in `ls`; do
convert -resize 14x14 $i $i
convert $i `echo $i | sed -e 's/\.png/-scaled\.xpm/'`
rm $i
done

Good as new!  A whole directory full of nice, scaled xpms for your use.

If you don't mind, a slightly slimmer version:

for i in *.png; do convert -scale 14x14 "$i" "${i%%.*}-scaled.xpm"; done

Should look like this:
http://img518.imageshack.us/img518/6748 … iewjw9.png

There now, that's a bit more truthful than "HOT."

Cool setup smile

Last edited by gotmor (2007-12-16 02:32:49)

Offline

#34 2007-12-16 02:42:54

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: dzen & xmobar Hacking Thread

gotmor wrote:

If you don't mind, a slightly slimmer version:

for i in *.png; do convert -scale 14x14 "$i" "${i%%.*}-scaled.xpm"; done

Not at all! Actually I did it in like 10 steps at first.  Shell scripting was never my first love wink

gotmor wrote:

Should look like this:
http://img518.imageshack.us/img518/6748 … iewjw9.png

There now, that's a bit more truthful than "HOT."

Cool setup smile

Thanks!


Cthulhu For President!

Offline

#35 2007-12-16 14:06:23

quarks
Member
From: Netherlands
Registered: 2007-05-14
Posts: 66

Re: dzen & xmobar Hacking Thread

buttons wrote:

As posted in the screenshots thread:

#!/bin/zsh
# vim:ft=zsh ts=4

myvol() {

    percentage=`amixer |grep -A 6 \'Front\' |awk {'print $5'} |grep -m 1 % |sed -e 's/[][%]//g'`
    ismute=`amixer |grep -A 6 \'Front\'|awk {'print $7'} |grep -m 1 "[on|off]" | sed -e 's/[][]//g'`

    if [[ $ismute == "off" ]]; then
        print -n "$(echo "0" | gdbar -fg '#aecf96' -bg gray40 -h 7 -w 60)"
    else
        print -n "$(echo $percentage |gdbar -fg '#aecf96' -bg gray40 -h 7 -w 60)"
    fi
}

while true; do
    print "^i(/home/buttons/.bitmaps/volume.xbm)$(myvol)"
    sleep 1
done

Obviously you'll have to change the path to the bitmap, and unless you have a strange soundcard as I do, you'll probably want 'Master' rather than 'Front' as well.  And if your soundcard apparently only outputs mono and has no mute function, like my Audigy ::mutter::, change the awk command in percentage to be print $4 and ignore the mute bit.

Credits go to Theomachos for providing a battery script to get me started.

I tried to get this working but the bar and percentage stays at zero.
Here's the relevant code:

# Volume 
myvol() {
    percentage=`amixer | grep -A 6 "Master" | awk {'print $5'} | grep -m 1 % | sed -e 's/[][%]//g'`
    print -n "$(echo $percentage | gdbar -fg '#aecf96' -bg gray40 -h 7 -w 60)"
}

# Main

while true; do

VOLUME=$(myvol)

    echo "^fg(#80AA83)^p(0)^i(${ICONPATH}/volume.xbm)^fg()${VOLUME}"

sleep $SLEEP
       
done | dzen2 -x 3 -y -3 -ta l -p -e

But:

amixer | grep -A 6 "Master" | awk {'print $5'} | grep -m 1 % | sed -e 's/[][%]//g'

outputs the correct volume percentage of the Master Volume Playback from my Audigy 2 ZS card.
What's wrong here?

Offline

#36 2007-12-16 14:25:16

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: dzen & xmobar Hacking Thread

quarks wrote:

What's wrong here?

Hmm.  I just tried out your code, and it works for me.  This isn't giving you any errors or anything if you run it from the command line?  You haven't done something very silly like pipe this through bash/sh or forgotten to install gdbar from the dzen package, right?

I can't think of what's wrong if your percentage command works.

Try out just running your script from the command line (sans the | dzen after done) and post the output.


Cthulhu For President!

Offline

#37 2007-12-16 15:52:09

quarks
Member
From: Netherlands
Registered: 2007-05-14
Posts: 66

Re: dzen & xmobar Hacking Thread

buttons wrote:
quarks wrote:

What's wrong here?

Hmm.  I just tried out your code, and it works for me.  This isn't giving you any errors or anything if you run it from the command line?  You haven't done something very silly like pipe this through bash/sh or forgotten to install gdbar from the dzen package, right?

I can't think of what's wrong if your percentage command works.

Try out just running your script from the command line (sans the | dzen after done) and post the output.

It works now, I forgot about the line number (which oddly didn't show in the terminal).  hmm
The function is now:

myvol() {
    percentage=`amixer | grep -A 6 "Master" | awk {'print $4'} | grep -m 1 % | sed -e 's/[][%]//g'| sed -e 's/5://g'`
    print -n "$(echo $percentage | gdbar -fg '#aecf96' -bg gray40 -h 7 -w 60)"
}

Offline

#38 2007-12-16 16:23:24

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

quarks wrote:

It works now, I forgot about the line number (which oddly didn't show in the terminal).  hmm
The function is now:

myvol() {
    percentage=`amixer | grep -A 6 "Master" | awk {'print $4'} | grep -m 1 % | sed -e 's/[][%]//g'| sed -e 's/5://g'`
    print -n "$(echo $percentage | gdbar -fg '#aecf96' -bg gray40 -h 7 -w 60)"
}

While your code may perfectly work, it does a bit to much spawing to extract a single value in my opinion.

So, I'd like to suggest a different solution:

This is what "amixer sget Master" outputs in my case:

Simple mixer control 'Master',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 23 [74%]
  Front Right: Playback 23 [74%]

We are interested in the percentage value in between [ ]. Further we assume left/right levels are the same:

myvol() {
    print `amixer sget Master|sed -ne 's/^.*Left: .*\[\([0-9]*\)%\]$/\1/p'` | gdbar
}

Have fun, Rob.

Offline

#39 2007-12-16 17:50:02

quarks
Member
From: Netherlands
Registered: 2007-05-14
Posts: 66

Re: dzen & xmobar Hacking Thread

gotmor wrote:

While your code may perfectly work, it does a bit to much spawing to extract a single value in my opinion.

So, I'd like to suggest a different solution:

This is what "amixer sget Master" outputs in my case:

Simple mixer control 'Master',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 31
  Mono:
  Front Left: Playback 23 [74%]
  Front Right: Playback 23 [74%]

We are interested in the percentage value in between [ ]. Further we assume left/right levels are the same:

myvol() {
    print `amixer sget Master|sed -ne 's/^.*Left: .*\[\([0-9]*\)%\]$/\1/p'` | gdbar
}

Have fun, Rob.

Thanks, that's definetely better although I'm not sure how to get that working.
I'm not familiar with sed regex.

My output of that command is:

Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined
  Playback channels: Mono
  Limits: Playback 0 - 100
  Mono: Playback 40 [40%] [-24.00dB]

Could you show me wat sed regular expressions to use for this?

Offline

#40 2007-12-16 17:58:39

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

quarks wrote:

My output of that command is:

Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined
  Playback channels: Mono
  Limits: Playback 0 - 100
  Mono: Playback 40 [40%] [-24.00dB]

Could you show me wat sed regular expressions to use for this?

Sure smile

sed -ne 's/^.*Mono: .*\[\([0-9]*\)%\].*$/\1/p'

Basically your line starts with "Mono" (matched by:  "^.*Mono:") in contrast to "Front left" and has some more things after the percentage value (matched by: ".*$").
Everything else is the same as above..

Bye, Rob.

Offline

#41 2007-12-16 18:22:21

quarks
Member
From: Netherlands
Registered: 2007-05-14
Posts: 66

Re: dzen & xmobar Hacking Thread

gotmor wrote:
quarks wrote:

My output of that command is:

Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined
  Playback channels: Mono
  Limits: Playback 0 - 100
  Mono: Playback 40 [40%] [-24.00dB]

Could you show me wat sed regular expressions to use for this?

Sure smile

sed -ne 's/^.*Mono: .*\[\([0-9]*\)%\].*$/\1/p'

Basically your line starts with "Mono" (matched by:  "^.*Mono:") in contrast to "Front left" and has some more things after the percentage value (matched by: ".*$").
Everything else is the same as above..

Bye, Rob.

Thanks, that works great. cool

Oh and while I'm still here; how can I integrate gcpubar in a function of an existing script?
E.g. like here: http://robm.selfip.net/wiki.sh/-main/DzenAndXmonad
Seems like I can only get it working when I use a second script.

Offline

#42 2007-12-16 19:06:18

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

quarks wrote:

Thanks, that works great. cool

Nice!

Oh and while I'm still here; how can I integrate gcpubar in a function of an existing script?
E.g. like here: http://robm.selfip.net/wiki.sh/-main/DzenAndXmonad
Seems like I can only get it working when I use a second script.

You can perfectly integrate it into a function.

Calculating the cpu usage needs at least 2 samples over some interval of time, here comes gcpubar's "-c" option into use.
And as we do not want to wait too long for the calculation we choose a small interval with the "-i" option to retrieve our samples.
The more samples we collect over time the more accurate/stable is the result, the drawback is that it will take longer until we get the actual result.

gcpubar -c 2 -i 0.2

The only problem with this method is that gcpubar will show all values, i.e. "-c 5" will print out 5 usage values, although we are only interested in the last one.
The solution is simple:

COUNT=3
IVAL=0.2

gcpubar -c $COUNT -i $IVAL | tail -1

HTH, Rob.

Offline

#43 2007-12-16 19:32:22

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

Re: dzen & xmobar Hacking Thread

Rob,

I've been asked by a couple users as to whether dzen can provide 'clickable' workspace names for xmonad, similar to wmii or dwm.  Is such a thing possible, or on a TODO list somewhere?  I haven't tried xmobar myself, but I don't think it can do this either.  Personally, I can live without it, but I admit it would be nice for those one-handed-taco-eating-times!


thayer williams ~ cinderwick.ca

Offline

#44 2007-12-16 19:48:39

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

thayer wrote:

Rob,

I've been asked by a couple users as to whether dzen can provide 'clickable' workspace names for xmonad, similar to wmii or dwm.  Is such a thing possible, or on a TODO list somewhere?  I haven't tried xmobar myself, but I don't think it can do this either.  Personally, I can live without it, but I admit it would be nice for those one-handed-taco-eating-times!

Yes, it can in (horizontal) menu mode, though the real issue here is xmonad. It does not provide any means to remote control it sad

Example:

for i in ws:1 ws:2 ws:3 ws:4; do echo $i; done | dzen2 -m h -l 4 -p -e 'button1=menuprint;button3=exit'

Last edited by gotmor (2007-12-16 19:54:56)

Offline

#45 2007-12-16 20:14:48

quarks
Member
From: Netherlands
Registered: 2007-05-14
Posts: 66

Re: dzen & xmobar Hacking Thread

gotmor wrote:
quarks wrote:

Thanks, that works great. cool

Nice!

Oh and while I'm still here; how can I integrate gcpubar in a function of an existing script?
E.g. like here: http://robm.selfip.net/wiki.sh/-main/DzenAndXmonad
Seems like I can only get it working when I use a second script.

You can perfectly integrate it into a function.

Calculating the cpu usage needs at least 2 samples over some interval of time, here comes gcpubar's "-c" option into use.
And as we do not want to wait too long for the calculation we choose a small interval with the "-i" option to retrieve our samples.
The more samples we collect over time the more accurate/stable is the result, the drawback is that it will take longer until we get the actual result.

gcpubar -c 2 -i 0.2

The only problem with this method is that gcpubar will show all values, i.e. "-c 5" will print out 5 usage values, although we are only interested in the last one.
The solution is simple:

COUNT=3
IVAL=0.2

gcpubar -c $COUNT -i $IVAL | tail -1

HTH, Rob.

Yes, works beautifully! big_smile

Now I just need to add the HDD usage script and the script is complete.

Offline

#46 2007-12-17 12:40:17

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: dzen & xmobar Hacking Thread

I have installed dzen2-gadgets, but it still complains about gdbar not being found, what's wrong?


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#47 2007-12-18 11:22:51

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: dzen & xmobar Hacking Thread

Hello,

I'm just writing to inform you that dzen's wiki has moved to:

    http://dzen.geekmode.org/wiki/wiki.cgi/-main/

I will keep a permanent redirect from the old site for some time,
though.

The wiki is open for everyone, so please feel free to extend and                                                       
enhance it.


Bye, Rob.

Offline

#48 2007-12-19 16:04:59

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: dzen & xmobar Hacking Thread

Ok, now I have shamefully solved my gdbar problem, but I have another one. My refresh rate for the volume is set to 1 (sleep 1), so it flashes constantly. Is there any way to have the volume displayed real time and not having the bar flickering?


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#49 2007-12-19 16:51:39

buttons
Member
From: NJ, USA
Registered: 2007-08-04
Posts: 620

Re: dzen & xmobar Hacking Thread

finferflu wrote:

Ok, now I have shamefully solved my gdbar problem, but I have another one. My refresh rate for the volume is set to 1 (sleep 1), so it flashes constantly. Is there any way to have the volume displayed real time and not having the bar flickering?

It shouldn't do this, even on .5s.  Are you sure you don't have something else trying to overwrite that area?

The answer to your second question appears to be no, unfortunately.  From limited research, it looks like there are some laptop acpi modules that can control this, but that's it.

For what it's worth, I stopped using volume monitors because they use too much CPU calling amixer and parsing the output.  An interesting project for someone would be to hack amixer to accept a parameter that causes it to only display the primary volume expressed as an integer, a la:

%amixer -z
70

I'm still not sure it would be worth it from a CPU-usage perspective...


Cthulhu For President!

Offline

#50 2007-12-19 17:09:55

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: dzen & xmobar Hacking Thread

Thanks buttons,
I have noticed that CPU consumption as well, I think I'll stick with Sonata. I can control the volume through it.


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

Board footer

Powered by FluxBB