fixing #35; lain: new commit

This commit is contained in:
luke bonham 2014-03-30 12:35:03 +02:00
parent ce017a2deb
commit bc166ade29
2 changed files with 5 additions and 31 deletions

View File

@ -160,38 +160,12 @@ end
-- @param requested_icon_sizes A list of icon sizes (optional). If this list is given, it will be used as a priority list for icon sizes when looking up for icons. If you want large icons, for example, you can put '128x128' as the first item in the list. -- @param requested_icon_sizes A list of icon sizes (optional). If this list is given, it will be used as a priority list for icon sizes when looking up for icons. If you want large icons, for example, you can put '128x128' as the first item in the list.
-- @return A table with file entries. -- @return A table with file entries.
function parse_desktop_file(arg) function parse_desktop_file(arg)
local program = { show = true, file = arg.file }
local function check_nil(f, v) for line in io.lines(arg.file) do
-- Almost the same as
-- return f and f or v
-- but it will return false if f = false
if f == nil then return v else return f end
end
--- Parses .desktop file considering groups.
-- @param file Path to file
-- @return A table with group enries. Each group entry is table with file entries.
local function parse_file(file)
local result = {}
local group = nil
for line in io.lines(file) do
group = line:match("^%[([^%[%]%c]+)%]*(.-)%s*$") or group
if group then
result[group] = check_nil(result[group], {})
for key, value in line:gmatch("(%w+)=(.+)") do for key, value in line:gmatch("(%w+)=(.+)") do
result[group][key] = value program[key] = value
end end
end end
end
return result
end
-- Using only 'Desktop Entry' group.
local program = parse_file(arg.file)['Desktop Entry']
program.show = check_nil(program.show, true)
program.file = arg.file
-- Don't show the program if NoDisplay is true -- Don't show the program if NoDisplay is true
-- Only show the program if there is not OnlyShowIn attribute -- Only show the program if there is not OnlyShowIn attribute

2
lain

@ -1 +1 @@
Subproject commit 67865e6426dfe0d74d0d9fff7a7c29c729823684 Subproject commit a0bd2798accb561db079aebbdd3ee8d4d9c65465