Topic: Script to combine a custom menu with an auto-generated menu
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 --reconfigureIt 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)