XDG Menu

Mikael Eriksson <[email protected]> Sat, 22 Oct 2005 04:09:00 +0200
Newsgroups gmane.compw.window-managers.windowmaker.user
Message-ID <[email protected]>
If anyone is interested, i have written a python script which parses the XDG
menus that Gnome & KDE uses and outputs a windowmaker compatible menu.
It requires pyxdg which can be found at
http://freedesktop.org/wiki/Software_2fpyxdg

Mikael Eriksson

_______________________________________________
INFO: https://windowmaker.org/lists/listinfo/wm-user
ARCHIVE: https://windowmaker.org/lists/archive/wm-user/
FAQ: http://windowmaker.org/faq.html
wmaker-xdg-menu.py (text/x-python, 545 B)
#!/usr/bin/env python
import xdg.Menu

def print_menu( menu ):
	print '"' + menu.getName() + '" MENU'
	for child in menu.getEntries():
		if isinstance( child, xdg.Menu.Menu ):
			print_menu( child )
		elif isinstance( child, xdg.Menu.MenuEntry ):
			print_entry( child )
	print '"' + menu.getName() + '" END'

def print_entry( entry ):
	cmd = ""
	for c in entry.DesktopEntry.getExec().split():
		if not c.startswith( "%" ): cmd += c + " "
	print '"' + entry.DesktopEntry.getName() + '" EXEC %s' % cmd

root = xdg.Menu.parse()
print_menu( root )