From 69c4136adaa5a915d5525484db91e809bfe560e2 Mon Sep 17 00:00:00 2001 From: gapan Date: Sun, 12 Feb 2012 22:19:01 +0000 Subject: [PATCH] Lookup in all directories specified by xdg specs --- src/xdgmenumaker | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/xdgmenumaker b/src/xdgmenumaker index e36c858..6098a01 100755 --- a/src/xdgmenumaker +++ b/src/xdgmenumaker @@ -6,9 +6,9 @@ import getopt import gtk import xdg.DesktopEntry as dentry import xdg.Exceptions as exc +import xdg.BaseDirectory as bd from operator import attrgetter -dirlist = os.listdir('/usr/share/applications') seticon = False desktop = False @@ -192,13 +192,14 @@ def sortedcategories(applist): return categories def desktopfilelist(): - systemdir = '/usr/share/applications' - localdir = os.path.expanduser('~/.local/share/applications') + dirs = bd.xdg_data_dirs filelist = [] - for i in os.listdir(systemdir): - filelist.append(systemdir+'/'+i) - for i in os.listdir(localdir): - filelist.append(localdir+'/'+i) + for d in dirs: + xdgdir = d+'/applications' + if os.path.isdir(xdgdir): + for i in os.listdir(xdgdir): + if i.endswith('.desktop'): + filelist.append(xdgdir+'/'+i) return filelist def menu():