Skip to content

Commit

Permalink
Add support for pekwm
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gapan committed Jan 18, 2014
1 parent 89a90be commit 51f0191
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/xdgmenumaker
Expand Up @@ -95,6 +95,8 @@ def main(argv):
windowmakermenu()
elif desktop == "icewm":
icewmmenu()
elif desktop == "pekwm":
pekwmmenu()
else:
usage()
sys.exit(2)
Expand All @@ -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'
Expand Down Expand Up @@ -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:])

0 comments on commit 51f0191

Please sign in to comment.