From 8c5f07f01163e86e437db2d46d2144a22ef8949d Mon Sep 17 00:00:00 2001 From: George Vlahavas Date: Wed, 2 Sep 2015 23:18:14 +0300 Subject: [PATCH] Don't process desktop entries if they won't show If for any reason the desktop entry won't be shown (for example if NoDisplay is set), then don't process the desktop entry any further as there is no need to. Should make processing a tiny bit faster. --- src/xdgmenumaker | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/xdgmenumaker b/src/xdgmenumaker index 7c99068..cd08b65 100755 --- a/src/xdgmenumaker +++ b/src/xdgmenumaker @@ -232,6 +232,21 @@ def icon_full_path(icon): def get_entry_info(desktopfile): show = True de = dentry.DesktopEntry(filename=desktopfile) + + # skip processing the rest of the desktop entry if the item is to not be + # displayed anyway + onlyshowin = de.getOnlyShowIn() + notshowin = de.getNotShowIn() + hidden = de.getHidden() + nodisplay = de.getNoDisplay() + # none of the freedesktop registered environments are supported by + # OnlyShowIn anyway: + # http://standards.freedesktop.org/menu-spec/latest/apb.html + # So if OnlyShowIn is set, it certainly isn't for any of the WMs + # xdgmenumaker supports. + if (onlyshowin != []) or (desktop in notshowin) or hidden or nodisplay: + return None + name = de.getName().encode('utf-8') if seticon: @@ -241,12 +256,6 @@ def get_entry_info(desktopfile): else: icon = None - hidden = de.getHidden() - if hidden: - show = False - nodisplay = de.getNoDisplay() - if nodisplay: - show = False # removing any %U or %F from the exec line command = de.getExec().partition('%')[0] @@ -289,20 +298,9 @@ def get_entry_info(desktopfile): else: category = other - onlyshowin = de.getOnlyShowIn() - notshowin = de.getNotShowIn() - # none of the freedesktop registered environments are supported by this anyway - # http://standards.freedesktop.org/menu-spec/latest/apb.html - if onlyshowin != []: - show = False - if desktop in notshowin: - show = False - if show: - app = App(name, icon, command, path) - mentry = MenuEntry(category, app) - return mentry - else: - return None + app = App(name, icon, command, path) + mentry = MenuEntry(category, app) + return mentry def sortedcategories(applist):