I've been using mmaker to generate a menu listing all the applications installed on my system for a while, meaning to create a custom menu eventually. I've realised that a custom menu really won't cut it, as I try out new software frequently and occasionally have to really dig around to find the command to execute certain apps, so I've come to rely on my automatic menu quite a lot. I do however like having a few links right in the root of the menu where I need them, so I started wondering how easy it was to create a custom menu and combine it with my mmaker menu.
I tried an xdg-open pipe menu, which I found to be quite slow when I opened the sub-menu. It also put all of my applications in the wrong categories - mmaker occasionally throws a few games into the "other" category, but that's as bad as it gets. As I use Arch, I haven't tried a debian-menu pipe.
So, half a day later, I have my first ever useful bash script. I also have a folder (~/bin/update-menu) with my custom menu (custom.xml) which is the root of my menu, without the final </menu> or </openbox_menu> which the menu file requires to run.
So this file runs mmaker, pipes the automatic menu into ~/bin/update-menu/generated.xml, pipes my custom menu into a menu.xml in the same directory, pipes the automatic menu into a submenu called "all", closes </menu> and </openbox_menu>, copies the new menu.xml to ~/.config/openbox/menu.xml and then reconfigures blackbox.
I can run it after I install new packages, or I can put it in my .xinitrc to have an up to date menu when I log in
Here it is, if it's any use to you.
#!/bin/bash mmaker -vfic OpenBox3 > ~/bin/update-menu/generated.xml && cat ~/bin/update-menu/custom.xml > ~/bin/update-menu/menu.xml && cat ~/bin/update-menu/generated.xml >> ~/bin/update-menu/menu.xml && echo -e '</menu>\n\n</menu>\n\n</openbox_menu>' >> ~/bin/update-menu/menu.xml && cp ~/bin/update-menu/menu.xml ~/.config/openbox/menu.xml && openbox --reconfigure
It would be quite easy to add another sub-menu at the end (for reconfigure, exit, or anything else you like at the bottom of your menus), by creating another xml file with some other menu entries, duplicating one of the cat lines in this script and putting it before the echo line.
I hope it's useful to someone! Or I hope someone can show me a better way of doing this
Last edited by vis (2010-06-15 21:14:45)
I think you could use obmenugen to do this.
Create the dynamic menu with obmenugen -p then edit the /home/user/.config/obmenugen/obmenugen.schema file to add any static parts you want.
BTW if you wish to contact me, send me an e-mail instead of a PM.
I should have checked these forums earlier! I'm quite happy with my system though, I can edit the files with a text editor, using a system I'm familiar with, and then just glue the rest on the end with the script.
Incase anyone wants it, here is my example custom.xml, to which the generated.xml is appended.
<openbox_menu> <menu id="root-menu" label="root-menu"> <item label="pcmanfm"> <action name="execute"><execute>pcmanfm</execute></action> </item> <item label="chrome"> <action name="execute"><execute>google-chrome</execute></action> </item> <item label="zim"> <action name="execute"><execute>zim</execute></action> </item> <menu id="graphics" label="graphics"> <item label="shotwell"> <action name="execute"><execute>shotwell</execute></action> </item> <item label="photoshop"> <action name="execute"><execute>photoshop</execute></action> </item> <item label="inkscape"> <action name="execute"><execute>inkscape</execute></action> </item> </menu> <menu id="all" label="all">