naughty: Handle icon paths with file:// in them.

This commit is contained in:
Emmanuel Lepage Vallee 2020-03-15 06:10:32 -04:00
parent 32fd11a220
commit c75203ac03
1 changed files with 18 additions and 2 deletions

View File

@ -652,6 +652,20 @@ local function request_filter(self, _, _)
if self._private.icon then return true end if self._private.icon then return true end
end end
-- Convert encoded local URI to Unix paths.
local function check_path(input)
if type(input) ~= "string" then return nil end
if input:sub(1,7) == "file://" then
input = input:sub(8)
end
-- urldecode
input = input:gsub("%%(%x%x)", function(x) return string.char(tonumber(x, 16)) end )
return gfs.file_readable(input) and input or nil
end
function notification.get_icon(self) function notification.get_icon(self)
-- Honor all overrides. -- Honor all overrides.
if self._private.icon then if self._private.icon then
@ -674,9 +688,11 @@ function notification.get_icon(self)
end end
-- Second level of fallback, icon paths. -- Second level of fallback, icon paths.
if self._private.app_icon and gfs.file_readable(self._private.app_icon) then local path = check_path(self._private.app_icon)
if path then
naughty._emit_signal_if("request::icon", request_filter, self, "path", { naughty._emit_signal_if("request::icon", request_filter, self, "path", {
path = self._private.app_icon path = path
}) })
end end