[ Content | View menu ]

dzen & dmenu

I have been fiddling with my laptop recently and have just set up two must-have programs for minimal users, dzen and dmenu. dzen is a status bar that displays whatever is sent to it on standard input, so it is a useful output for monitoring programs. dmenu displays a simple menu that accepts a list of options seperated by newlines on standard input, and echoes the selected output on standard output.

dzen

I decided to use the output of conky-cli as the standard input for dzen, as I knew the .conkyrc syntax and could quite easily modify it to my needs. I found a pretty good starting .conkyrc on the Arch forums. I edited it a little, and ended up with this:
background yes
update_interval 0.5
use_spacer none
no_buffers yes

TEXT
< Processor: ${cpu cpu0}% | RAM: ${mem} of ${memmax} | Swap: ${swap} of ${swapmax} | Load: ${execi 5 /usr/shbin/load} | Battery: ${execi 5 /home/barrucadu/battery.sh} >

Here is my /usr/shbin/load script:
#!/bin/bash
uptime | grep -o -E "load average:(.*)" | sed 's/^load average: //'

And here, is my /home/barrucadu/battery.sh script:

#!/bin/bash

echo "#!/usr/bin/python" >> battery.py
echo -ne "print round((" >> battery.py
echo -ne `cat /proc/acpi/battery/BAT1/state | grep "remaining capacity:" | sed "s/remaining capacity: //" | sed "s/ mAh//" && \
cat /proc/acpi/battery/BAT1/info | grep "design capacity:" | sed "s/design capacity: //" | sed "s/ mAh//"` | sed "s/ /.0\//" >> battery.py
echo ".0)*100), \"%\"" >> battery.py
chmod +x battery.py
./battery.py | sed "s/.0 %/%/"
rm battery.py

Not the most elegant of solutions, but it works great. I have a simple status bar showing my CPU usage, RAM, swap, load averages and battery life.

dmenu

For dmenu, I created a series of files - the names of which correspond to actions on the menu. I then created a "commands" file which contains a pairing of menu options to commands. Here is my dmenu.sh file:
#!/bin/bash

cd /home/barrucadu/menu/
dmenu="dmenu -nb #000000 -nf #ffffff -sb #000000 -sf #aaaaff -fn snap"
dmenu_submenu=`$dmenu < Categories`
dmenu_program=`$dmenu < $dmenu_submenu`
dmenu_execute=`cat Commands | grep "$dmenu_program: " | sed "s/$dmenu_program: //"`
$dmenu_execute &

Here is my Categories file:Applications
Games
Places
System

The Applications file:Archive Manager
Calculator
Disc Burner
Document Viewer
File Manager
FTP Client
Image Editor
Messenger
Music Player
Office Suite
Terminal
Text Editor
Video Player
Web Browser

Games:GTK Life
Hunt The Wumpus
Nethack
Zangband
Zork 1
Zork 2
Zork 3

Places:Root
Home
Media

System:GTK Themer
Network Manager
Partitioner
Package Manager

And finally, Commands:--Applications--
Archive Manager: xarchiver
Calculator: galculator
Disc Burner: recorder
Document Viewer: epdfview
File Manager: pcmanfm
FTP Client: filezilla
Image Editor: gimp
Messenger: amsn
Music Player: quodlibet
Office Suite: soffice
Terminal: xakura
Text Editor: emacs
Video Player: vlc
Web Browser: opera

--Games--
GTK Life: gtklife
Hunt The Wumpus: sakura -e wump
Nethack: sakura -e nethack
Zangband: zangband
Zork 1: sakura -e zork1
Zork 2: sakura -e zork2
Zork 3: sakura -e zork3

--Places--
Root: pcmanfm /
Home: pcmanfm /home/barrucadu/
Media: pcmanfm /media/

--System--
GTK Themer: gtk-chtheme
Network Manager: /usr/lib/wicd/gui.py
Partitioner: gksu gparted
Package Manager: shaman

There you have it! I have a nice system monitor and menu all set up. I have created a shortcut with xbindkeys so that pressing the Menu key runs my script, and though I doubt I will use it often, it is a nice thing to have.

Filed in Linux, under , , , , on May 10, 2008

No Comments

Write comment - TrackBack - RSS Comments

Write comment