Browse Source

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/.
pull/1/merge
George Vlahavas 12 years ago
parent
commit
c702c354c8
  1. 13
      src/xdgmenumaker

13
src/xdgmenumaker

@ -203,14 +203,23 @@ def desktopfilelist():
# some directories are mentioned twice in bd.xdg_data_dirs, once # some directories are mentioned twice in bd.xdg_data_dirs, once
# with and once without a trailing / # with and once without a trailing /
for i in bd.xdg_data_dirs: for i in bd.xdg_data_dirs:
dirs.append(i.rstrip('/')) i = i.rstrip('/')
dirs = set(dirs) if i not in dirs:
dirs.append(i)
filelist = [] filelist = []
df_temp = []
for d in dirs: for d in dirs:
xdgdir = d+'/applications' xdgdir = d+'/applications'
if os.path.isdir(xdgdir): if os.path.isdir(xdgdir):
for i in os.listdir(xdgdir): for i in os.listdir(xdgdir):
if i.endswith('.desktop'): if i.endswith('.desktop'):
# 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) filelist.append(xdgdir+'/'+i)
return filelist return filelist

Loading…
Cancel
Save