Browse Source

Add support for pekwm

Add support for creating pekwm menus. The application menus can be
placed in a submenu or not, have icons or not and the XDG Path attribute
works.
The menus can be either static or dynamically generated.
pull/3/head
George Vlahavas 11 years ago
parent
commit
51f0191ec7
  1. 46
      src/xdgmenumaker

46
src/xdgmenumaker

@ -95,6 +95,8 @@ def main(argv):
windowmakermenu()
elif desktop == "icewm":
icewmmenu()
elif desktop == "pekwm":
pekwmmenu()
else:
usage()
sys.exit(2)
@ -103,7 +105,7 @@ def usage():
print 'USAGE:', os.path.basename(sys.argv[0]), '[OPTIONS]'
print
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, windowmaker and pekwm'
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 ' -h, --help show this help message'
@ -389,5 +391,47 @@ def icewmmenu():
if submenu is True:
print '}'
def pekwmmenu():
global seticon
global submenu
if submenu is True:
spacing = ' '
if seticon == True:
app_icon = icon_full_path(applications_icon)
print 'Submenu = "'+applications+'" { Icon = "'+app_icon+'"'
else:
print 'Submenu = "'+applications+'" {'
else:
spacing = ''
for i in menu():
category = i[0]
cat_icon = category_icon(category)
cat_icon = icon_full_path(cat_icon)
if seticon is True and cat_icon is not None:
print spacing+'Submenu = "'+category+'" { Icon = "'+cat_icon+'"'
else:
print spacing+'Submenu = "'+category+'" {'
for j in i[1]:
name = j[0]
icon = j[1]
# for some apps (like netbeans) the command is launched with
# /bin/sh "command"
# and the quotes get mixed up with the quotes pekwm puts
# around Actions, so we're just stripping the quotes
command = j[2].replace('"', '')
path = j[3]
if path is not None:
# pekwm doesn't like "cd path ; command", but it works
# with "&&" and "||", so we'll launch the command even if the
# path does not exist
command = 'cd '+path+' && '+command+' || '+command
if seticon is True and icon is not None:
print spacing+' Entry = "'+name+'" { Icon = "'+icon+'"; Actions = "Exec '+command+' &" }'
else:
print spacing+' Entry = "'+name+'" { Actions = "Exec '+command+' &" }'
print spacing+'}'
if submenu is True:
print '}'
if __name__ == "__main__":
main(sys.argv[1:])

Loading…
Cancel
Save