You are not logged in.
Similar to the xmonad Hacking Thread, feel free to post any tips, tricks or questions regarding the dzen or xmobar utilities.
Update May 2011: My current configs, including dzen, xmobar and conky scripts can be found at github:
http://github.com/thayerwilliams
Original snippet posted 2007-12-04:
Here's a simple time/date statusbar I patched together from various online examples:
#!/bin/sh
FG='#ffffff'
BG='#003aff'
FONT='-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*'
while true ; do
dt=`date +"%a %b %d %l:%M %p "`
printf "%s\n" "$dt"
sleep 20
done | dzen2 -e '' -x '800' -h '14' -w '880' -ta r -fg $FG -bg $BG -fn $FONT
Saved as ~/bin/dzheader, it's executed via my xmonad startup script.
Last edited by thayer (2011-05-11 17:13:31)
thayer williams ~ cinderwick.ca
Offline
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.
Cthulhu For President!
Offline
gcpubar -fg '#aecf96' -bg gray40 -h 7 -w 75 | dzen2 -ta l -w 275 -bg '#000000' -fg 'grey70' -fn '-*-terminus-*-*-*-*-12-*-*-*-*-*-iso8859' -e '' &
This is a nice-looking CPU bar.
/is double-posting again.
Last edited by buttons (2007-12-05 01:36:51)
Cthulhu For President!
Offline
So, this is just a copy from dzen's wiki and will look like
Collapsed:
Uncollapsed:
#!/bin/bash
#
# (c) 2007 by Robert Manea
#
# Left mouse button toggles detailed view
# Right mouse button quits
#--[ Configuration ]---------------------------------------------------
# bg color
BG='#494b4f'
# fg color
FG='grey70'
# font
FNT='-*-profont-*-*-*-*-11-*-*-*-*-*-iso8859'
# x position
XPOS=1435
# y position
YPOS=0
# title width
TWIDTH=125
# details area width
DWIDTH=150
# events & actions
ACT='button1=togglecollapse;button3=exit'
#----------------------------------------------------------------------
AWKS='/MemTotal/ {mtotal=$2};
/MemFree/ {mfree=$2};
/Active/ {mactive=$2};
/^Cached/ {mcached=$2};
/SwapTotal/ {swtotal=$2};
/SwapFree/ {swfree=$2};
END {
print mtotal-mfree " " mtotal;
print mactive " " mtotal;
print mcached " " mtotal;
print swtotal-swfree " " swtotal; }'
while echo ' Mem:
Active:
Cached:
Swap : ' | paste - <(awk "$AWKS" /proc/meminfo | gdbar -fg '#aecf96' -bg '#37383a' -w 50 -h 7); do
sleep 5
done | dzen2 -ta l -l 3 -u -fn $FNT -p -bg $BG -fg $FG -x $XPOS -y $YPOS -tw $TWIDTH -w $DWIDTH -sa c -e $ACT
Offline
I know you can have tabs and such with xmonad, but is there any way to make dzen more useful in other WMs? For instance I'm currently using Openbox and I'd like to have a task list or something like that. Also is there any way to make dzen _not_ be on the highest z-axis level? Whenever I full screen mplayer and other apps, dzen stays on top looking fugly.
How do you mix different stuff together? Like having the date, the memory bar with slave windows as above, and other various things together. Are seperate instances of dzen required? Do I just hack it up with different width and x-axis values?
Does anyone have a solution for a tray? I'm using trayer but it's taking up a few pixels more than dzen, and dzen covers it up so I made a fugly gap to the left. Is there any way to integrate a tray into dzen? It has images...
Offline
I have tweaked and uploaded my monitor-script....
You can get it here: http://www.pindundin.de/files/mymon.sh
Features:
- Maildir Checker
- Battery Status with color change (yellow = half, red = low)
- Volume ( thanks to buttons for the mute-thingy ! )
- Date ( WOW !!! )
Last edited by Theomachos (2007-12-05 11:05:23)
There is one thing even more vital to science than intelligent methods; and that is, the sincere desire to find out the truth, whatever it may be.
Charles S. Peirce
Offline
I know you can have tabs and such with xmonad, but is there any way to make dzen more useful in other WMs? For instance I'm currently using Openbox and I'd like to have a task list or something like that. Also is there any way to make dzen _not_ be on the highest z-axis level? Whenever I full screen mplayer and other apps, dzen stays on top looking fugly.
You can manipulate the stacking order with the 'raise' and 'lower' actions. Basically you'd bind those action to some suitable event (like button1, sigusr2, onstart, etc.).
How do you mix different stuff together? Like having the date, the memory bar with slave windows as above, and other various things together. Are seperate instances of dzen required? Do I just hack it up with different width and x-axis values?
Well, starting multiple instances is a particulary straightforward method. Although you can build a multiplexer to arrange the items. One quite easy way is to use a couple of fifos and a small script which collects data from them and passes it to dzen in the desired order.
Does anyone have a solution for a tray? I'm using trayer but it's taking up a few pixels more than dzen, and dzen covers it up so I made a fugly gap to the left. Is there any way to integrate a tray into dzen? It has images...
Tray icon support is (currently) not on the TODO of dzen for two reasons. First there are already tools out there that do an excellent job, and
supporting trays would be only useful to people using dzen as a statusbar.
So, i'd like to support the most general case and keep dzen as slim and easy to use as possible .
Offline
PKGBUILD to support full colour XPM files in dzen2:
pkgname=dzen2
pkgver=0.8.5
pkgrel=1
arch=(i686 x86_64)
pkgdesc="X notification utility"
url="http://gotmor.googlepages.com/dzen"
license=("MIT")
depends=('libx11')
makedepends=('gcc')
source=(http://gotmor.googlepages.com/$pkgname-$pkgver.tar.gz)
md5sums=('5978620c2124c8a8ad52d7f17ce94fd7')
build()
{
cd $startdir/src/$pkgname-$pkgver
patch config.mk <<EOF
7,8c7,8
< PREFIX = /usr/local
< MANPREFIX = \${PREFIX}/share/man
---
> PREFIX = /usr
> MANPREFIX = \${PREFIX}/man
10,11c10,11
< X11INC = /usr/X11R6/include
< X11LIB = /usr/X11R6/lib
---
> X11INC = /usr/include
> X11LIB = /usr/lib
22,23c22,23
< LIBS = -L/usr/lib -lc -L\${X11LIB} -lX11
< CFLAGS = -Os \${INCS} -DVERSION=\"\${VERSION}\"
---
> #LIBS = -L/usr/lib -lc -L\${X11LIB} -lX11
> #CFLAGS = -Os \${INCS} -DVERSION=\"\${VERSION}\"
26,27c26,27
< #LIBS = -L/usr/lib -lc -L\${X11LIB} -lX11 -lXpm
< #CFLAGS = -Os \${INCS} -DVERSION=\"\${VERSION}\" -DDZEN_XPM
---
> LIBS = -L/usr/lib -lc -L\${X11LIB} -lX11 -lXpm
> CFLAGS = -Os \${INCS} -DVERSION=\"\${VERSION}\" -DDZEN_XPM
EOF
make || return 1
mkdir -p $startdir/pkg/usr/share/licenses/$pkgname
cp $startdir/src/$pkgname-$pkgver/LICENSE $startdir/pkg/usr/share/licenses/$pkgname/license
chmod 644 $startdir/pkg/usr/share/licenses/$pkgname/license
make DESTDIR=$startdir/pkg install
}
With this I was able to get the dzen weather script featured in Rob's infamous config working. Links to all the XPMs are also available from that link.
It's soooo nice. Thanks Rob!
Cthulhu For President!
Offline
Xilon wrote:I know you can have tabs and such with xmonad, but is there any way to make dzen more useful in other WMs? For instance I'm currently using Openbox and I'd like to have a task list or something like that. Also is there any way to make dzen _not_ be on the highest z-axis level? Whenever I full screen mplayer and other apps, dzen stays on top looking fugly.
You can manipulate the stacking order with the 'raise' and 'lower' actions. Basically you'd bind those action to some suitable event (like button1, sigusr2, onstart, etc.).
How do you mix different stuff together? Like having the date, the memory bar with slave windows as above, and other various things together. Are seperate instances of dzen required? Do I just hack it up with different width and x-axis values?
Well, starting multiple instances is a particulary straightforward method. Although you can build a multiplexer to arrange the items. One quite easy way is to use a couple of fifos and a small script which collects data from them and passes it to dzen in the desired order.
Does anyone have a solution for a tray? I'm using trayer but it's taking up a few pixels more than dzen, and dzen covers it up so I made a fugly gap to the left. Is there any way to integrate a tray into dzen? It has images...
Tray icon support is (currently) not on the TODO of dzen for two reasons. First there are already tools out there that do an excellent job, and
supporting trays would be only useful to people using dzen as a statusbar.
So, i'd like to support the most general case and keep dzen as slim and easy to use as possible .
Didn't realise we had the dzen2 dev here .
The onstart=lower even trick seems to have done the trick, thanks. Using pipes seems quite interesting and powerful, similar to wmii's "plan9 way". I might be able to make some quite interesting things with that . Stalonetray seems to be quite nice so I think that will do.
Offline
Nice thread thayer,
I've been experimenting with conky-cli+dzen2 as a statusbar the last couple of days, and they work great together. I just wanted to share my dzen2+conky-cli config with you, I use conky-cli because my scripting skills are lacking and I find that conky-cli uses less cpu than the bash-scripts. Some may say that using conky is defeating the purpose of dzen, but I don't know of any way to use icons (xpm+xbm) and draw seperators with conky.
This is my dzen2 startup in .xinitrc:
~/bin/conky-cli -c ~/.conkyrc6 | dzen2 -x 648 -bg '#000000' -fg '#435493' -ta r -sa r -fn '-*-montecarlo-medium-*-*-*-11-*-*-*-*-*-*-*' -p -e '' &
This is my conky-cli .conkyrc: (conky-cli is in AUR)
background no
out_to_console yes
update_interval 5.0
total_run_times 0
uppercase no
use_spacer yes
TEXT
^r(2x10)^fg(#B64403)^r(2x10) mem: $memperc% ^r(2x10)^fg(#435493)^r(2x10) root: $fs_free_perc% ^r(2x10)^fg(#B64403)^r(2x10) ^i(/home/edgar/dzen_bitmaps/cpu13.xpm) $cpu%/${acpitemp}C ^r(2x10)^fg(#435493)^r(2x10) ^i(/home/edgar/dzen_bitmaps/kalarm13.xpm) ${time %d-%m-%y %H:%M} ^r(2x10)^fg(#B64403)^r(2x10)
And combined it looks like this:
Cheers,
Offline
Well, until I get a releasable script going i thought I'll just post the way I'm calculating network rates.
You'll get this:
#!/bin/sh
# icons
ICONPATH=/home/robert/dzen_bitmaps
# network interface
INTERFACE=eth0
# update every x seconds
SLEEP=1
# Here we remember the previous rx/tx counts
RXB=`cat /sys/class/net/${INTERFACE}/statistics/rx_bytes`
TXB=`cat /sys/class/net/${INTERFACE}/statistics/tx_bytes`
while :; do
# get new rx/tx counts
RXBN=`cat /sys/class/net/${INTERFACE}/statistics/rx_bytes`
TXBN=`cat /sys/class/net/${INTERFACE}/statistics/tx_bytes`
# calculate the rates
# format the values to 4 digit fields
RXR=$(printf "%4d\n" $(echo "($RXBN - $RXB) / 1024/${SLEEP}" | bc))
TXR=$(printf "%4d\n" $(echo "($TXBN - $TXB) / 1024/${SLEEP}" | bc))
# print out the rates with some nice formatting
echo "${INTERFACE}: ^fg(white)${RXR}kB/s^fg(#80AA83)^p(3)^i(${ICONPATH}/arr_down.xbm)^fg(white)${TXR} kB/s^fg(orange3)^i(${ICONPATH}/arr_up.xbm)^fg()"
# reset old rates
RXB=$RXBN; TXB=$TXBN
sleep $SLEEP
done | dzen2
Edit: Fetch the newest icon pack including the up/down arrows from here
Have fun, Rob.
Last edited by gotmor (2007-12-10 11:23:36)
Offline
In case anyone seeks some nice icons for dzen, he may have a look here: dzen icon packs.
You are also welcome to contribute your own icon sets ...
Offline
In case anyone seeks some nice icons for dzen, he may have a look here: dzen icon packs.
You are also welcome to contribute your own icon sets ...
Thanks for hosting those, Rob and thanks also for the network rate script! I was struggling with that for a while and although Cerebral and others offered some suggestions, I just couldn't get it working on my own.
thayer williams ~ cinderwick.ca
Offline
Have fun, Rob.
Thanks for dzen, all those ideas and scripts. I haven't done any tests yet, but I thought I'd ask you before I do that since you probably have the most insight in all this.
The question is if you know what would be the most system efficient way (memory, etc.) to utilize dzen in combination with xmonad.
1. Single dzen vs. multiple dzen instances.
2. Shell scripts vs (ie) conky
3. In case of shell scripts a single script combining all parts (like date/mail/mpd, etc) vs seperate scripts.
Like I said I haven't tested anything yet, but a single shell script in a single dzen instance seems the most efficient way to go. Anyway, thanks to anybody with some insight.
Offline
With Rob's net script I am getting a error command not found for line 22 and 23
RXR=$(printf "%4d\n" $(echo "($RXBN - $RXB) / 1024/${SLEEP}" | bc))
TXR=$(printf "%4d\n" $(echo "($TXBN - $TXB) / 1024/${SLEEP}" | bc))
Do I need to change something?
Thanks
Offline
If your error message looks something like this:
line 22: bc: command not found
Then you need to install "bc" with "pacman -S bc"
Offline
I've been experimenting with conky-cli+dzen2 as a statusbar the last couple of days, and they work great together...
Ashren, *ugh* I've spent about 12 hours of my spare time trying to write a little bash script without even knowing that coky-cli existed! I don't know why, but the first time I read your post I didn't clue in to what you were saying. I read it again today and after checking out conky-cli I've got a kickass dzen bar with half the work and less than half the CPU usage. Thanks so much for the tip!
I've got it set up so that only the active network is shown (wifi shows signal strength and essid in addition to up/down rates). The icons toggle for wifi/ethernet and ac/battery status too. Great stuff.
Here's a screenshot showing AC and ethernet and another showing battery and wifi.
~/.conkyrc:
background no
out_to_console yes
update_interval 2.0
total_run_times 0
use_spacer no
TEXT
^i(/home/thayer/.xmonad/dzen/music.xpm)^fg(#555555) $mpd_smart ^fg():: CPU ^fg(#ff0000)${cpu cpu1}%^fg(#ffffff)/^fg(#ff0000)${cpu cpu2}% ^fg()${loadavg 1 2 3} ^i(/home/thayer/.xmonad/dzen/temp.xpm)^fg(#ff9900)${i8k_cpu_temp}c ^fg()${freq_g 1}/${freq_g 2}GHz ^i(/home/thayer/.xmonad/dzen/mem.xbm) RAM $memperc% ${if_empty ${exec awk '{print $2}' /proc/acpi/ac_adapter/AC/state | grep 'on-line'}}^i(/home/thayer/.xmonad/dzen/battery2.xpm)${else}^i(/home/thayer/.xmonad/dzen/power-ac.xpm)${endif}^fg(#0066ff) $battery $battery_time ${if_empty ${exec ifconfig wlan0 | grep 'inet addr:'}}^i(/home/thayer/.xmonad/dzen/network.xpm) ^fg(#99cc33)${downspeed eth0}k/s ^i(/home/thayer/.xmonad/dzen/down.xpm) ^fg(#ff3300)${upspeed eth0}k/s^i(/home/thayer/.xmonad/dzen/up.xpm)${else}^i(/home/thayer/.xmonad/dzen/wifi.xpm) ^fg(#aaaaaa)${exec iwconfig wlan0 | grep 'Signal level' | cut -d= -f3 | awk '{print 100+$1 "%"}'} ^fg(#ffffff)${exec iwgetid | cut -d\" -f2 | awk '{print $1}'} ^fg(#99cc33)${downspeed wlan0}k/s ^i(/home/thayer/.xmonad/dzen/down.xpm) ^fg(#ff3300)${upspeed wlan0}k/s ^i(/home/thayer/.xmonad/dzen/up.xpm)${endif} ^fg(#ffffff)${time %a %b %d %I:%M%P}
~/bin/dzonky:
FG='#aaaaaa'
BG='#1a1a1a'
FONT='-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*'
conky | dzen2 -e '' -x '550' -h '16' -w '1130' -ta r -fg $FG -bg $BG -fn $FONT
Last edited by thayer (2010-12-05 23:24:42)
thayer williams ~ cinderwick.ca
Offline
Wow, thayer that setup looks slick. I'm glad you could use the tip, and it's nice to have confirmed that conky-cli does use less cpu power compared to the bash-scripts.
Here's my current config, the top statusbar:
background no
out_to_console yes
update_interval 4.5
total_run_times 0
uppercase no
use_spacer yes
TEXT
^r(2x15) ^fg(#63B966)^i(/home/edgar/dzen_bitmaps/arr_down.xbm)^fg(#000000)${downspeed eth0} ^fg(#435493)^i(/home/edgar/dzen_bitmaps/arr_up.xbm)^fg(#000000)${upspeed eth0} ^r(2x15) ^i(/home/edgar/dzen_bitmaps/interact14.xpm) $memperc% ^r(2x15) ^i(/home/edgar/dzen_bitmaps/computer14.xpm) $fs_free_perc% ^r(2x15) ^i(/home/edgar/dzen_bitmaps/cpu14.xpm) $cpu% @ ${acpitemp}C ^r(2x15) ^i(/home/edgar/dzen_bitmaps/mini.clock2.xpm) ${time %d-%m-%y %H:%M}
And the rss feed in the bottom:
background no
out_to_console yes
update_interval 15
total_run_times 0
uppercase no
use_spacer yes
TEXT
^fg(#9ab8c2)^bg(#435493)New Arch Pkgs ^fg(#000000)^bg(#9ab8c2) ${rss http://www.archlinux.org/feeds/packages/ 30 item_title 0} ^r(2x2) ${rss http://www.archlinux.org/feeds/packages/ 30 item_title 1} ^r(2x2) ${rss http://www.archlinux.org/feeds/packages/ 30 item_title 2} ^r(2x2) ${rss http://www.archlinux.org/feeds/packages/ 30 item_title 3} ^r(2x2) ${rss http://www.archlinux.org/feeds/packages/ 30 item_title 4} ^r(2x2) ${rss http://www.archlinux.org/feeds/packages/ 30 item_title 5} ^fg(#9ab8c2)^bg(#435493)OSnews ^fg(#000000)^bg(#9ab8c2) ${rss http://osnews.com/feed.php?k=News 20 item_title 0} ^r(2x2) ${rss http://osnews.com/feed.php?k=News 20 item_title 1} ^r(2x2) ${rss http://osnews.com/feed.php?k=News 20 item_title 2} ^r(2x2)
To get a rss feed working you have to add --enable-rss in the PKGBUILD. And
You can check out the screenshot here: http://gotmor.googlepages.com/Xmonad_sc … n-full.jpg
I've encountered one strange bug, when firing up xmonad, the separators i.e.(^r(2x15)) sometimes grows considerably in length. Anyone else noticed this?
Last edited by Ashren (2007-12-13 12:07:22)
Offline
Wow, thayer that setup looks slick. I'm glad you could use the tip, and it's nice to have confirmed that conky-cli does use less cpu power compared to the bash-scripts.
Hm, so all bash scripts have the same cpu usage?
Otherwise, how do you compare?
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
I didn't run any comparative tests, so people please ignore my blatant statements on cpu usage.
In theory conky which is programmed i C should be less cpu intensive than bash-scripts right?
On my old hardware I'm sure I can feel a difference, though.
Offline
I've encountered one strange bug, when firing up xmonad, the separators i.e.(^r(2x15)) sometimes grows considerably in length. Anyone else noticed this?
Yep.
Cthulhu For President!
Offline
Ashren wrote:I've encountered one strange bug, when firing up xmonad, the separators i.e.(^r(2x15)) sometimes grows considerably in length. Anyone else noticed this?
Yep.
I have seen this s few times
Offline
dzonky.sh
FG='#aaaaaa'
BG='#1a1a1a'
FN='-*-bitstream vera sans mono-medium-r-normal-*-10-*-*-*-*-*-*-*'
conky | dzen2 -e '' -x '550' -h '16' -w '800' -ta r -fg '#FFFFFF' -bg '#000000' -fn '-*-bitstream vera sans-medium-r-normal-*-11-*-*-*-*-*-*-*'
.conkyrc
background no
out_to_console yes
update_interval 2.0
total_run_times 0
use_spacer no
TEXT
^fg(#FFFFFF)^i(/home/r00/images/bitmaps/mpd.xbm)^fg(#99ccFF) $mpd_smart ^fg(#FFFFFF)^i(/home/r00/images/bitmaps/cpu.xbm)^fg(#99CCFF) $cpu% ^fg(#FFFFFF)^i(/home/r00/images/bitmaps/mem.xbm) ^fg(#99CCFF)$memperc% ^fg(#FFFFFF)^i(/home/r00/images/bitmaps/battery.xbm)^fg(#99CCFF) ${battery_time C1B0} ^fg(#FFFFFF)(^fg(#99CCFF)${battery_percent C1B0}%^fg(#FFFFFF)) ^fg(#FFFFFF)^i(/home/r00/images/bitmaps/net-wifi5.xbm)^fg(#99CCFF) ${exec iwgetid | cut -d\" -f2 | awk '{print $1}'} ^fg(#FFFFFF)(^fg(#99CCFF)${exec iwconfig wlan0 | grep 'Signal level' | cut -d= -f3 | awk '{print 100+$1 "%"}'}^fg(#FFFFFF)) ^fg(#efefef) ${time %a %b %d %I:%M%P}
Offline
Just playing with this conky and dzen thing. 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.
Last edited by buttons (2007-12-14 02:59:29)
Cthulhu For President!
Offline
...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.
thayer williams ~ cinderwick.ca
Offline