diff --git a/lib/naughty.lua.in b/lib/naughty.lua.in
index 722b838a6..e00c047b1 100644
--- a/lib/naughty.lua.in
+++ b/lib/naughty.lua.in
@@ -356,16 +356,22 @@ function notify(args)
marginbox:set_widget(textbox)
textbox.valign = "middle"
- local function setText(pattern, replacements)
+ local function setMarkup(pattern, replacements)
textbox:set_markup(string.format('%s%s', font, title, text:gsub(pattern, replacements)))
end
+ local function setText()
+ textbox:set_text(string.format('%s %s', title, text)
+ end
-- First try to set the text while only interpreting
.
-- (Setting a textbox' .text to an invalid pattern throws a lua error)
- if not pcall(setText, "", "\n") then
+ if not pcall(setMarkup, "", "\n") then
-- That failed, escape everything which might cause an error from pango
- if not pcall(setText, "[<>&]", { ['<'] = "<", ['>'] = ">", ['&'] = "&" }) then
- textbox:set_markup("<Invalid markup, cannot display message>")
+ if not pcall(setMarkup, "[<>&]", { ['<'] = "<", ['>'] = ">", ['&'] = "&" }) then
+ -- Ok, just ignore all pango markup. If this fails, we got some invalid utf8
+ if not pcall(setText) then
+ textbox:set_markup("<Invalid markup or UTF8, cannot display message>")
+ end
end
end