#!/bin/sh

# To monitor install/remove/menu editing:
# Install fsniper http://projects.l3ib.org/trac/fsniper
# fsniper Config file ~/.config/fsniper/config 
#
# watch {
#    ~/.local/share/applications {
#           recurse = true  
#   * {
#           handler = sh -c "xdg-menu > ~/.config/openbox/rootmenu.xml"
#        }}
#   /usr/share/applications { 
#           recurse = true  
#   * {
#           handler = sh -c "xdg-menu > ~/.config/openbox/rootmenu.xml"
#        }}
#       }
#
#
# Maybe add a window menu to xdg-menu?
#print '<menu id="client-list-combined-menu" plugin="client-list-combined-menu"/>'
#print '<item label="Run..."><action name="execute"><command>gmrun</command></action></item>'

# Pull the file that does the magic (needs python-gmenu)

wget -P /tmp http://cvs.fedoraproject.org/viewvc/devel/openbox/xdg-menu?revision=1.3 

cp /tmp/xdg-menu?revision=1.3 ~/bin/xdg-menu

chmod +x ~/bin/xdg-menu

mv ~/.config/openbox/menu.xml ~/.config/openbox/menu_orig.xml 

echo '<?xml version="1.0" encoding="utf-8"?>' >> ~/.config/openbox/menu.xml	
echo '<openbox_menu>' >> ~/.config/openbox/menu.xml
echo '<menu execute="cat ~/.config/openbox/rootmenu.xml" id="root-menu" label=""/>' >> ~/.config/openbox/menu.xml
echo '</openbox_menu>' >> ~/.config/openbox/menu.xml	

# Run this whenever you need to rebuild menu if not using fsniper

~/bin/xdg-menu > ~/.config/openbox/rootmenu.xml

openbox --reconfigure


