Signed-off-by: Julien Danjou <[email protected]>
---
 freedesktop/menu.lua  |    8 ++++----
 freedesktop/utils.lua |    8 ++++++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/freedesktop/menu.lua b/freedesktop/menu.lua
index ee99e5d..290c125 100644
--- a/freedesktop/menu.lua
+++ b/freedesktop/menu.lua
@@ -1,7 +1,7 @@
 -- Grab environment
 local utils = require("freedesktop.utils")
 local io = io
-local string = string
+local ipairs = ipairs
 local table = table
 local os = os
 
@@ -30,10 +30,11 @@ for i, program in 
ipairs(utils.parse_dir('/usr/share/applications/')) do
     -- check whether to include in the menu
     if program.show and program.Name and program.cmdline then
         local target_category = nil
-        if program.Categories then
-            for category in string.gfind(program.Categories, '[^;]+') do
+        if program.categories then
+            for _, category in ipairs(program.categories) do
                 if programs[category] then
                     target_category = category
+                    break
                 end
             end
         else
@@ -59,4 +60,3 @@ applications_menu = {
     { "Settings", programs["Settings"], utils.lookup_icon({ icon = 
'applications-utilities.png' }) },
     { "System Tools", programs["System"], utils.lookup_icon({ icon = 
'applications-system.png' }) },
 }
-
diff --git a/freedesktop/utils.lua b/freedesktop/utils.lua
index 7a67a3f..e515bdb 100644
--- a/freedesktop/utils.lua
+++ b/freedesktop/utils.lua
@@ -83,6 +83,14 @@ function parse(file, icons_sizes)
         program.icon_path = lookup_icon({ icon = program.Icon, icon_sizes = 
all_icon_sizes })
     end
 
+    -- Split categories into a table.
+    if program.Categories then
+        program.categories = {}
+        for category in program.Categories:gfind('[^;]+') do
+            table.insert(program.categories, category)
+        end
+    end
+
     if program.Exec then
         local cmdline = program.Exec:gsub('%%c', program.Name)
         cmdline = cmdline:gsub('%%[fuFU]', '')
-- 
1.6.1.3


-- 
To unsubscribe, send mail to [email protected].

Reply via email to