Browse Source

Add support for XDG Path property

This only works with fluxbox, as to the best of my knowledge windowmaker
and icewm don't allow switching to another directory with cd and then
executing the command.

Thanks to Gregor Bollerhey (gregor-b on github) for making the initial
pull request about this issue.
pull/3/head
George Vlahavas 11 years ago
parent
commit
576e4465d4
  1. 20
      src/xdgmenumaker

20
src/xdgmenumaker

@ -98,14 +98,16 @@ def usage():
print ' xdgmenumaker -i -f fluxbox' print ' xdgmenumaker -i -f fluxbox'
class MenuEntry: class MenuEntry:
def __init__(self, category, name, icon, command): def __init__(self, category, name, icon, command, path):
self.category = category self.category = category
self.name = name self.name = name
self.icon = icon self.icon = icon
self.command = command self.command = command
self.path = path
def __repr__(self): def __repr__(self):
return repr((self.category, self.name, self.icon, self.command)) return repr((self.category, self.name, self.icon, self.command,
self.path))
def icon_full_path(icon): def icon_full_path(icon):
# If the icon path is absolute and exists, leave it alone. # If the icon path is absolute and exists, leave it alone.
@ -155,6 +157,10 @@ def get_entry_info(desktopfile):
if terminal is True: if terminal is True:
command = 'xterm -e '+command command = 'xterm -e '+command
path = de.getPath()
if not path:
path = None
#cleaning up categories and keeping only registered freedesktop.org main categories #cleaning up categories and keeping only registered freedesktop.org main categories
categories = de.getCategories() categories = de.getCategories()
if 'AudioVideo' in categories: if 'AudioVideo' in categories:
@ -193,7 +199,7 @@ def get_entry_info(desktopfile):
if desktop in notshowin: if desktop in notshowin:
show = False show = False
if show == True: if show == True:
return [category, name, icon, command] return [category, name, icon, command, path]
else: else:
return None return None
@ -235,7 +241,7 @@ def menu():
try: try:
e = get_entry_info(desktopfile) e = get_entry_info(desktopfile)
if e is not None: if e is not None:
applist.append(MenuEntry(e[0], e[1], e[2], e[3])) applist.append(MenuEntry(e[0], e[1], e[2], e[3], e[4]))
except exc.ParsingError: except exc.ParsingError:
pass pass
@ -246,7 +252,8 @@ def menu():
appsincategory = [] appsincategory = []
for i in sortedapplist: for i in sortedapplist:
if i.category == c: if i.category == c:
appsincategory.append([i.name, i.icon, i.command]) appsincategory.append([i.name, i.icon, i.command,
i.path])
menu.append([c, appsincategory]) menu.append([c, appsincategory])
return menu return menu
@ -309,6 +316,9 @@ def fluxboxmenu():
name = j[0].replace(')', '\)') name = j[0].replace(')', '\)')
icon = j[1] icon = j[1]
command = j[2] command = j[2]
path = j[3]
if path is not None:
command = 'cd '+path+' ; '+command
if icon is None: if icon is None:
print spacing+' [exec] ('+name+') {'+command+'}' print spacing+' [exec] ('+name+') {'+command+'}'
else: else:

Loading…
Cancel
Save