# HG changeset patch # User Oleksandr Gavenko # Date 1344901947 -10800 # Node ID 0ab510cb567d187216c78c11b4b5ee4282308e8c # Parent 17e3e6c1ea96f4255f748efd78ce06afa3588252 Add xdg to Fvwm menus converter. diff -r 17e3e6c1ea96 -r 0ab510cb567d .fvwm/config --- a/.fvwm/config Mon Aug 13 15:03:57 2012 +0300 +++ b/.fvwm/config Tue Aug 14 02:52:27 2012 +0300 @@ -48,6 +48,15 @@ ModulePath $[FVWM_USERDIR]:+ ImagePath m4_ICONPATH;.xpm:m4_IMGPATH:+ +# Debian paths. +ImagePath +:/usr/share/icons/gnome/32x32/apps +ImagePath +:/usr/share/icons/locolor/32x32/apps +ImagePath +:/usr/share/icons/hicolor/32x32/apps +ImagePath +:/usr/include/X11/bitmaps/ +# This paths contain large icons for some apps, they make ugly menus look... +# ImagePath +:/usr/share/icons +# ImagePath +:/usr/share/pixmaps + ################################################################ # Set aliases to common values. @@ -391,6 +400,7 @@ + my Popup MenuMy + window Popup MenuWindowOperations + fvwm Popup MenuFvwmRoot ++ "" Nop Key F1 A M Menu MenuMyRoot Root c c Mouse 1 R A Menu MenuMyRoot Nop diff -r 17e3e6c1ea96 -r 0ab510cb567d .fvwm/xdg2fvwm.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.fvwm/xdg2fvwm.py Tue Aug 14 02:52:27 2012 +0300 @@ -0,0 +1,45 @@ + +import sys +import os + +import xdg.Menu +from xdg.DesktopEntry import * + +sys.stdout = codecs.getwriter('utf-8')(sys.stdout) + +# For testing purpose. Uncomment to run this file without args... +# sys.argv.append('debian-menu') + +if len(sys.argv) >= 2: + sys_menu_name = sys.argv[1] +else: + print("You forget pass NAME which is /etc/xdg/NAME.menu") + exit(1) + +# xdg_config_dirs hold possible paths. We use Debian one. +sys_menu_file = "%s/menus/%s.menu" % ("/etc/xdg", sys_menu_name) + +sys_menu = xdg.Menu.parse(sys_menu_file) + +def parse_menu(menu, name): + ''' Parse menu file. ''' + print 'DestroyMenu recreate %s' % name + for entry in menu.getEntries(): + if isinstance(entry, xdg.Menu.Menu): + icon = entry.getIcon() + subname = name+"-"+str(entry) + print u'AddToMenu "%s" "%s%%folder.png%%" Popup "%s"' % (name, entry.getName(), subname) + parse_menu(entry, subname) + elif isinstance(entry, xdg.Menu.MenuEntry): + desktop = DesktopEntry(entry.DesktopEntry.getFileName()) + icon = desktop.getIcon() + ind = icon.rfind('.') + if ind != -1: + icon = icon[0:ind] + cmd = desktop.getExec().rstrip('%FUfu') + print u'AddToMenu "%s" "%s%%%s.png%%" Exec exec %s' % (name, desktop.getName(), os.path.basename(icon), cmd) + else: + pass + +parse_menu(sys_menu, "Menu-"+sys_menu_name) + diff -r 17e3e6c1ea96 -r 0ab510cb567d Makefile --- a/Makefile Mon Aug 13 15:03:57 2012 +0300 +++ b/Makefile Tue Aug 14 02:52:27 2012 +0300 @@ -76,6 +76,13 @@ fi; \ done chmod a+x ~/.fvwm/FvwmKbdd.pl + for f in /etc/xdg/menus/*.menu; do \ + f=$${f%.menu}; \ + f=$${f#/etc/xdg/menus/}; \ + python .fvwm/xdg2fvwm.py $$f >~/.fvwm/$$f.hook; \ + echo "Read $$[HOME]/.fvwm/$$f.hook" >>~/.fvwm/config; \ + echo "AddToMenu MenuMyRoot $$f Popup Menu-$$f" >>~/.fvwm/config; \ + done mkdir -p ~/.screenshot for item in $(IFNONEXIST_ITEMS); do \ if [ -f $$item -a ! -f $(HOME)/$$item ]; then \