From c702c354c83736538f4712ef178f45633a496421 Mon Sep 17 00:00:00 2001 From: George Vlahavas Date: Tue, 18 Jun 2013 20:45:09 +0300 Subject: [PATCH] Don't use duplicate .desktop file entries If a .desktop file is present in more than one locations, use only the .desktop file that should take precedence (e.g. the one in ~/.local/share/applications/ over the one in /usr/share/applications/. --- src/xdgmenumaker | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/xdgmenumaker b/src/xdgmenumaker index 1b5cb19..6b5cd46 100755 --- a/src/xdgmenumaker +++ b/src/xdgmenumaker @@ -203,15 +203,24 @@ def desktopfilelist(): # some directories are mentioned twice in bd.xdg_data_dirs, once # with and once without a trailing / for i in bd.xdg_data_dirs: - dirs.append(i.rstrip('/')) - dirs = set(dirs) + i = i.rstrip('/') + if i not in dirs: + dirs.append(i) filelist = [] + df_temp = [] 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) + # for duplicate .desktop files that exist in more + # than one locations, only keep the first occurence. + # That one should have precedence anyway (e.g. + # ~/.local/share/applications has precedence over + # /usr/share/applications + if i not in df_temp: + df_temp.append(i) + filelist.append(xdgdir+'/'+i) return filelist def menu():