Rather than describing a solution that you can't find, how about describing the problem you are trying to solve. Not the little piece you are having trouble with, but the whole thing.
Well, OK. Since I might run into problems at the far end of it as well, I guess it makes sense to do that.
I'm trying to grab a list of all apps registered in the GNOME applications list and convert it to a menu format used by several other window managers. The first format, or at least the parts of it that mean anything, you've already seen (and used in your script); the second one looks like this:
menu Applications folder {
menu Editors folder {
prog vim vim vim
prog Lyx emacs lyx
}
menu "Mail Agents" folder {
prog Mutt mutt xterm -e mutt
}
menu "WWW Browsers" folder {
prog Mozilla mozilla mozilla
prog Firefox /usr/share/pixmaps/firefox.png firefox
prog Seamonkey /usr/share/pixmaps/firefox.png seamonkey
prog w3m lynx xterm -e w3m
prog Links lynx xterm -e links
}
menu Graphics folder {
prog Gimp gimp gimp
}
menu Development folder {
prog ddd ddd ddd
}
prog "Acrobat Reader" pdf acroread
prog "DVI Previewer" xdvi xdvi
}
menu Games folder {
prog "Koules for X" koules xkoules -f
prog Xboing xboing xboing
prog Xboard xboard xboard
prog XGalaga xgalaga xgal
prog XDemineur xdemineur xdemineur
prog ppracer /usr/share/pixmaps/ppracer.xpm /usr/games/ppracer
prog Arena arena openarena
}
...
Please note that folders (e.g., Applications) can contain other folders (e.g., Editors). Any folder can also contain program entries, which are structured as
prog "Program name" icon.ext executable_name
where the program name must be quoted if it contains whitespace, the icon name must be either a filename or a dash (i.e., no icon), and the executable name can be a PATHed program, an absolute path to a program, or a shell construct to be executed. The menu can contain a few other things, but I'm not concerned with any of those at the moment.
The overall problem I'm having is creating the folder/program structure that I want reflected in the menus. That's a chain of categories that terminates in one or more programs belonging in that category - i.e.
menu "Games" folder {
menu "GNOME" folder {
menu "Action" folder {
prog "Arena" arena.png openarena
prog "ppracer" /usr/share/pixmaps/ppracer.xpm /usr/game
+s/ppracer
}
}
menu "KDE" {
...
If you can help with the overall problem, I'd appreciate it.