From ddccddb6dc38f80863855d394c03798f8aaea982 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sat, 11 Sep 2021 16:27:44 -0700 Subject: [PATCH] imagebox: Allow to load SVG data without saving it. --- lib/wibox/widget/imagebox.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/wibox/widget/imagebox.lua b/lib/wibox/widget/imagebox.lua index 5daf8001..3117b897 100644 --- a/lib/wibox/widget/imagebox.lua +++ b/lib/wibox/widget/imagebox.lua @@ -57,11 +57,19 @@ local function load_rsvg_handle(file) if not Rsvg then return end local cache = rsvg_handle_cache[file] + if cache then return cache end - local handle, err = Rsvg.Handle.new_from_file(file) + local handle, err = nil, nil + + if file:match("<[?]?xml") then + handle, err = Rsvg.Handle.new_from_data(file) + else + handle, err = Rsvg.Handle.new_from_file(file) + end + if not err then rsvg_handle_cache[file] = handle return handle