|
@ -13,6 +13,7 @@ from operator import attrgetter |
|
|
seticon = False |
|
|
seticon = False |
|
|
desktop = False |
|
|
desktop = False |
|
|
submenu = True |
|
|
submenu = True |
|
|
|
|
|
pekwmdynamic = False |
|
|
|
|
|
|
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-applications.directory') |
|
|
de = dentry.DesktopEntry(filename = '/usr/share/desktop-directories/xdgmenumaker-applications.directory') |
|
|
applications = de.getName().encode('utf-8') |
|
|
applications = de.getName().encode('utf-8') |
|
@ -70,8 +71,10 @@ def main(argv): |
|
|
global desktop |
|
|
global desktop |
|
|
global seticon |
|
|
global seticon |
|
|
global submenu |
|
|
global submenu |
|
|
|
|
|
global pekwmdynamic |
|
|
try: |
|
|
try: |
|
|
opts, args = getopt.getopt(argv, "hinf:", ["help", "icons" , "no-submenu", "format="]) |
|
|
opts, args = getopt.getopt(argv, "hinf:", ["help", "icons" , |
|
|
|
|
|
"no-submenu", "pekwm-dynamic", "format="]) |
|
|
except getopt.GetoptError: |
|
|
except getopt.GetoptError: |
|
|
usage() |
|
|
usage() |
|
|
sys.exit(2) |
|
|
sys.exit(2) |
|
@ -83,6 +86,8 @@ def main(argv): |
|
|
seticon = True |
|
|
seticon = True |
|
|
elif opt in ("-n", "--no-submenu"): |
|
|
elif opt in ("-n", "--no-submenu"): |
|
|
submenu = False |
|
|
submenu = False |
|
|
|
|
|
elif opt in ("--pekwm-dynamic"): |
|
|
|
|
|
pekwmdynamic = True |
|
|
elif opt in ("-f", "--format"): |
|
|
elif opt in ("-f", "--format"): |
|
|
desktop = arg |
|
|
desktop = arg |
|
|
if desktop is False: |
|
|
if desktop is False: |
|
@ -107,7 +112,8 @@ def usage(): |
|
|
print 'OPTIONS:' |
|
|
print 'OPTIONS:' |
|
|
print ' -f, --format the output format to use. Valid options are fluxbox, icewm, windowmaker and pekwm' |
|
|
print ' -f, --format the output format to use. Valid options are fluxbox, icewm, windowmaker and pekwm' |
|
|
print ' -i, --icons enable support for icons in the menus. Only works with fluxbox, icewm' |
|
|
print ' -i, --icons enable support for icons in the menus. Only works with fluxbox, icewm' |
|
|
print ' -n, --no-submenu do not create a submenu. Only works with fluxbox, icewm' |
|
|
print ' -n, --no-submenu do not create a submenu. Does not work with windowmaker' |
|
|
|
|
|
print ' --pekwm-dynamic generate dynamic menus for pekwm' |
|
|
print ' -h, --help show this help message' |
|
|
print ' -h, --help show this help message' |
|
|
print ' You have to specify the output format using the -f switch.' |
|
|
print ' You have to specify the output format using the -f switch.' |
|
|
print |
|
|
print |
|
@ -394,13 +400,19 @@ def icewmmenu(): |
|
|
def pekwmmenu(): |
|
|
def pekwmmenu(): |
|
|
global seticon |
|
|
global seticon |
|
|
global submenu |
|
|
global submenu |
|
|
|
|
|
global pekwmdynamic |
|
|
|
|
|
if pekwmdynamic is True: |
|
|
|
|
|
print "Dynamic {" |
|
|
|
|
|
dspacing = ' ' |
|
|
|
|
|
else: |
|
|
|
|
|
dspacing = '' |
|
|
if submenu is True: |
|
|
if submenu is True: |
|
|
spacing = ' ' |
|
|
spacing = ' ' |
|
|
if seticon == True: |
|
|
if seticon == True: |
|
|
app_icon = icon_full_path(applications_icon) |
|
|
app_icon = icon_full_path(applications_icon) |
|
|
print 'Submenu = "'+applications+'" { Icon = "'+app_icon+'"' |
|
|
print dspacing+'Submenu = "'+applications+'" { Icon = "'+app_icon+'"' |
|
|
else: |
|
|
else: |
|
|
print 'Submenu = "'+applications+'" {' |
|
|
print dspacing+'Submenu = "'+applications+'" {' |
|
|
else: |
|
|
else: |
|
|
spacing = '' |
|
|
spacing = '' |
|
|
for i in menu(): |
|
|
for i in menu(): |
|
@ -408,9 +420,9 @@ def pekwmmenu(): |
|
|
cat_icon = category_icon(category) |
|
|
cat_icon = category_icon(category) |
|
|
cat_icon = icon_full_path(cat_icon) |
|
|
cat_icon = icon_full_path(cat_icon) |
|
|
if seticon is True and cat_icon is not None: |
|
|
if seticon is True and cat_icon is not None: |
|
|
print spacing+'Submenu = "'+category+'" { Icon = "'+cat_icon+'"' |
|
|
print dspacing+spacing+'Submenu = "'+category+'" { Icon = "'+cat_icon+'"' |
|
|
else: |
|
|
else: |
|
|
print spacing+'Submenu = "'+category+'" {' |
|
|
print dspacing+spacing+'Submenu = "'+category+'" {' |
|
|
for j in i[1]: |
|
|
for j in i[1]: |
|
|
name = j[0] |
|
|
name = j[0] |
|
|
icon = j[1] |
|
|
icon = j[1] |
|
@ -426,12 +438,14 @@ def pekwmmenu(): |
|
|
# path does not exist |
|
|
# path does not exist |
|
|
command = 'cd '+path+' && '+command+' || '+command |
|
|
command = 'cd '+path+' && '+command+' || '+command |
|
|
if seticon is True and icon is not None: |
|
|
if seticon is True and icon is not None: |
|
|
print spacing+' Entry = "'+name+'" { Icon = "'+icon+'"; Actions = "Exec '+command+' &" }' |
|
|
print dspacing+spacing+' Entry = "'+name+'" { Icon = "'+icon+'"; Actions = "Exec '+command+' &" }' |
|
|
else: |
|
|
else: |
|
|
print spacing+' Entry = "'+name+'" { Actions = "Exec '+command+' &" }' |
|
|
print dspacing+spacing+' Entry = "'+name+'" { Actions = "Exec '+command+' &" }' |
|
|
print spacing+'}' |
|
|
print dspacing+spacing+'}' |
|
|
if submenu is True: |
|
|
if submenu is True: |
|
|
print '}' |
|
|
print dspacing+'}' |
|
|
|
|
|
if pekwmdynamic is True: |
|
|
|
|
|
print "}" |
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
if __name__ == "__main__": |
|
|
main(sys.argv[1:]) |
|
|
main(sys.argv[1:]) |
|
|