Pass full path to menu file. Also pass Fvwm menu entry name.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Tue, 28 Aug 2012 18:24:57 +0300
changeset 518 3dd43161fc0e
parent 517 de05fae3311f
child 519 11e26495ad85
Pass full path to menu file. Also pass Fvwm menu entry name.
.fvwm/xdg2fvwm.py
Makefile
--- a/.fvwm/xdg2fvwm.py	Tue Aug 28 17:23:55 2012 +0300
+++ b/.fvwm/xdg2fvwm.py	Tue Aug 28 18:24:57 2012 +0300
@@ -10,15 +10,14 @@
 # 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]
+if len(sys.argv) >= 3:
+    # xdg_config_dirs hold possible paths. We use Debian one.
+    fvwm_menu_name = sys.argv[1]
+    sys_menu_file = sys.argv[2]
 else:
-    print("You forget pass NAME which is /etc/xdg/NAME.menu")
+    print("You forget pass NAME which is like /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):
@@ -41,5 +40,5 @@
         else:
             pass
 
-parse_menu(sys_menu, "Menu-"+sys_menu_name)
+parse_menu(sys_menu, fvwm_menu_name)
 
--- a/Makefile	Tue Aug 28 17:23:55 2012 +0300
+++ b/Makefile	Tue Aug 28 18:24:57 2012 +0300
@@ -77,11 +77,12 @@
 	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; \
+		[ -f "$$f" ] || continue; \
+		fname=$${f%.menu}; \
+		fname=$${fname##*/}; \
+		python .fvwm/xdg2fvwm.py Menu-$$fname $$f >~/.fvwm/$$fname.hook; \
+		echo "Read $$[HOME]/.fvwm/$$fname.hook" >>~/.fvwm/config; \
+		echo "AddToMenu MenuMyRoot $$fname Popup Menu-$$fname" >>~/.fvwm/config; \
 	done
 	mkdir -p ~/.screenshot
 	for item in $(IFNONEXIST_ITEMS); do \