Browse Source

Add --no-submenu option

Using the --no-submenu option, a submenu that includes all category
menus is not created. All category menus are placed in the top level
menu. Only usable with fluxbox for now.
pull/1/merge
George Vlahavas 13 years ago
parent
commit
4932104981
  1. 22
      src/xdgmenumaker

22
src/xdgmenumaker

@ -11,6 +11,7 @@ from operator import attrgetter
seticon = False seticon = False
desktop = False desktop = False
submenu = True
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')
@ -52,8 +53,9 @@ other_icon = de.getIcon()
def main(argv): def main(argv):
global desktop global desktop
global seticon global seticon
global submenu
try: try:
opts, args = getopt.getopt(argv, "hif:", ["help", "icons" ,"format="]) opts, args = getopt.getopt(argv, "hinf:", ["help", "icons" , "no-submenu", "format="])
except getopt.GetoptError: except getopt.GetoptError:
usage() usage()
sys.exit(2) sys.exit(2)
@ -63,6 +65,8 @@ def main(argv):
sys.exit(0) sys.exit(0)
elif opt in ("-i", "--icons"): elif opt in ("-i", "--icons"):
seticon = True seticon = True
elif opt in ("--no-submenu"):
submenu = False
elif opt in ("-f", "--format"): elif opt in ("-f", "--format"):
desktop = arg desktop = arg
if desktop is False: if desktop is False:
@ -85,6 +89,7 @@ def usage():
print 'OPTIONS:' print 'OPTIONS:'
print ' -f, --format the output format to use. Valid options are fluxbox, icewm and windowmaker' print ' -f, --format the output format to use. Valid options are fluxbox, icewm and windowmaker'
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 ' --no-submenu do not create a submenu. Only works with fluxbox, icewm'
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
@ -259,11 +264,13 @@ def category_icon(category):
def fluxboxmenu(): def fluxboxmenu():
global seticon global seticon
if seticon == True: global submenu
app_icon = icon_full_path(applications_icon) if submenu is True:
print '[submenu] ('+applications+') <'+app_icon+'>' if seticon == True:
else: app_icon = icon_full_path(applications_icon)
print '[submenu] ('+applications+')' print '[submenu] ('+applications+') <'+app_icon+'>'
else:
print '[submenu] ('+applications+')'
for i in menu(): for i in menu():
category = i[0] category = i[0]
if seticon == True: if seticon == True:
@ -284,7 +291,8 @@ def fluxboxmenu():
else: else:
print ' [exec] ('+name+') {'+command+'} <'+icon+'>' print ' [exec] ('+name+') {'+command+'} <'+icon+'>'
print ' [end] # ('+category+')' print ' [end] # ('+category+')'
print '[end] # ('+applications+')' if submenu is True:
print '[end] # ('+applications+')'
def windowmakermenu(): def windowmakermenu():
print '"'+applications+'" MENU' print '"'+applications+'" MENU'

Loading…
Cancel
Save