From c75203ac03ff8711ecddf679bd00973baa114998 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 15 Mar 2020 06:10:32 -0400 Subject: [PATCH] naughty: Handle icon paths with file:// in them. --- lib/naughty/notification.lua | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/naughty/notification.lua b/lib/naughty/notification.lua index fe6f2a1c..4f5acccc 100644 --- a/lib/naughty/notification.lua +++ b/lib/naughty/notification.lua @@ -652,6 +652,20 @@ local function request_filter(self, _, _) if self._private.icon then return true 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) -- Honor all overrides. if self._private.icon then @@ -674,9 +688,11 @@ function notification.get_icon(self) end -- 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", { - path = self._private.app_icon + path = path }) end