On Sun, 28 Apr 2002, [EMAIL PROTECTED] wrote:
>> On Sun, Apr28,02 20:12, Sean 'Shaleh' Perry wrote:
> Has anyone written a program to read the .desktop files that GNOME and
> KDE use to generate their menu from?
>
> GNOME -> blackbox menu program would be nice to have and help out new
> converts.
> Should take about an hour of python/perl/tcl coding.
I pulled the following shell script off the internet a few years back, only
does the gnome bits (and I see that it has small problems with some
entries)
Robert
#!/bin/sh
# gnomebbmenu v1.0
# wes hopkins - [EMAIL PROTECTED]
#
# As always, use at your own risk.
#
# gnomebbmenu generates a blackbox-comptaible
# menu file which you can use in your existing
# blackbox menu. Simply edit the parameters
# below as desired and run gnomebbmenu. It
# will generate the required code that you can
# either place in your exisitng menu, or use
# a [include] statement in your menu and include
# ~/.gnomebbmenu
#
# I'm aware that I could have wrote it much sexier
# in perl, except I don't know perl yet.
#
# Please send all comments to [EMAIL PROTECTED]
# good, bad, or ugly. Enjoy!
GNOME_MENUDIR="/usr/share/gnome/apps"
BB_MENUFILE="$HOME/.gnomebbmenu"
TERMNAME="rxvt"
TERMFLAG=""
TERMEXEC="-e"
# parseitem (.desktop filename)
parseitem()
{
if [ ! -f "$1" ]; then
return 0
fi
NAME=`cat $1 | grep "^Name=" | sed 's+.*=++'`
TERM=`cat $1 | grep "^Terminal=" | sed 's+.*=++'`
EXEC=`cat $1 | grep "^Exec=" | sed 's+.*=++'`
if [ $TERM -eq 1 ]; then
CMD="$TERMNAME $TERMFLAG $TERMEXEC $EXEC"
else
CMD="$EXEC"
fi
echo "Adding application: $NAME"
echo "[exec] ($NAME) {$CMD}" >> "$BB_MENUFILE"
}
if [ "$1" = "rcrs" ]; then
echo "[submenu] ($2)" >> "$BB_MENUFILE"
else
echo "" > "$BB_MENUFILE"
fi
if [ -z $3 ]; then
MENUDIR="$GNOME_MENUDIR"
else
MENUDIR="$3"
fi
SUBDIRS=`ls -p -1 "$MENUDIR" | grep /$ | sed s+/$++ |sort`
for SUBDIR in $SUBDIRS
do
$0 "rcrs" "$SUBDIR" "$MENUDIR/$SUBDIR"
done
ITEMS=`ls -1 --color=no "$MENUDIR" | sort | grep 'desktop$'`
for ITEM in $ITEMS
do
parseitem "$MENUDIR/$ITEM"
done
if [ "$1" = "rcrs" ]; then
echo "[end] " >> "$BB_MENUFILE"
fi
--
Robert Marshall