This script uses the “menuprint_noparse” action, so you need the latest SVN dzen for it to work:
svn checkout http://dzen.googlecode.com/svn/trunk/ dzen
NOTE:
If you are using any dzen formating commands in the description field of the menu file you must supply an application to launch!
Script:
#!/bin/sh
#
# (c) 2008 Robert Manea
#
# creates dzen menus from 9menu input files
#
# * additionaly accepts any dzen formating
# commands in the description field
#
# * replaces /^.--*/ sequences with graphical
# separator lines
#
# Syntax: dz9menu <menufile>
#Position
X=20
Y=0
WIDTH=110
#Font
FONT='-*-fixed-medium-*-*-*-10-*-*-*-*-*-iso10646-*'
# Width of the graphical separator (default 80% of window's width)
SEPARATOR_WIDTH=`expr $WIDTH - \( $WIDTH / 100 \) \* 20`
[ -f "$1" ] && MENUFILE="$1" || exit
# number of visible menu entries (access the others through scrolling up/down)
LINES=`wc -l "$MENUFILE"|sed -e 's/ .*//'`
[ $LINES -gt 20 ] && LINES=20
execute () {
read PROG
while read LINE; do
LBL=;APP=
LBL=$(echo $LINE|sed -e 's/:.*$//' -e 's/^[ \t]*//' -e 's/[ \t]*$//')
APP=$(echo $LINE|sed -e 's/^.*://' -e 's/^[ \t]*//' -e 's/[ \t]*$//')
if [ x"$APP" = x"exit" ]; then
exit
elif [ x"$LBL" = x"$PROG" ]; then
if [ x"$APP" = x"" ]; then
$LBL&
else
$APP&
fi
exit
fi
done < "$MENUFILE"
}
(
echo "^bg(grey40)^fg(black) $0 "
sed -e 's/:.*$//' \
-e 's/^.--*/^r('${SEPARATOR_WIDTH}'x1)/' "$MENUFILE"
) | \
dzen2 -l $LINES -w $WIDTH -x $X -y $Y -fn $FONT -p -m -sa c -e 'onstart=uncollapse,scrollhome;button1=menuprint_noparse,exit;button3=exit;button4=scrollup;button5=scrolldown' | execute
Input file:
Basically an input file must be in this format
description1:application1 to launch description2:application2 to launch description3 . . . descriptionN:applicationN to launch
Example input file:
Internet:firefox ^fg(khaki)Term^fg(green)inal:urxvt Files :mc ^i(~/dzen_bitmaps/music.xbm)^fg(red)Music :mocp Text :vim ---------- Logout :some command Shutdown:dito ---------- Close :exit
Discussion
This script would be more useful if it had an option to create a dzen menufile.
How can I create submenus without creating a new instance of dzen2.?