From 1ff860454e95930a27c0981e87c634b8823a301d Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 12 Sep 2021 01:37:51 -0700 Subject: [PATCH] theme: Use a SVG wallpaper for the xresources theme. It uses a stylesheet for the colors. This is not "as good" as the old one because it only supports 16:9 aspect ratio. However, the old wallpaper function doesn't fit great in the new model. The widget doesn't know the screen, so it cannot pass it to a function. It's possible to stretch the wallpaper. --- themes/xresources/theme.lua | 35 +++++++++++++++++++++++++++++++-- themes/xresources/wallpaper.svg | 24 ++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 themes/xresources/wallpaper.svg diff --git a/themes/xresources/theme.lua b/themes/xresources/theme.lua index 11edfe7dd..b3be3c46a 100644 --- a/themes/xresources/theme.lua +++ b/themes/xresources/theme.lua @@ -8,6 +8,7 @@ local xresources = require("beautiful.xresources") local rnotification = require("ruled.notification") local dpi = xresources.apply_dpi local xrdb = xresources.get_current_theme() +local gdebug = require("gears.debug") local gfs = require("gears.filesystem") local themes_path = gfs.get_themes_dir() @@ -126,10 +127,40 @@ local wallpaper_alt_fg = xrdb.color12 if not is_dark_bg then wallpaper_bg, wallpaper_fg = wallpaper_fg, wallpaper_bg end -theme.wallpaper = function(s) - return theme_assets.wallpaper(wallpaper_bg, wallpaper_fg, wallpaper_alt_fg, s) + +local rsvg = pcall(function() return require("lgi").Rsvg end) + +if rsvg then + local handle = require("lgi").Rsvg.Handle.new_from_file( + themes_path.."xresources/wallpaper.svg" + ) + + if handle then + handle:set_stylesheet([[ + .normal { + fill: ]]..wallpaper_fg..[[; + } + .background { + fill: ]]..wallpaper_bg..[[; + stroke: ]]..wallpaper_bg..[[; + } + .logo { + fill: ]]..wallpaper_alt_fg..[[; + } + ]]) + + theme.wallpaper = handle + end +else + gdebug.print_warning("Could not load the wallpaper: librsvg is not installed.") end +if not theme.wallpaper then + theme.wallpaper = themes_path.."xresources/wallpaper.svg" +end + +theme.wallpaper_bg = wallpaper_bg + -- Set different colors for urgent notifications. rnotification.connect_signal('request::rules', function() rnotification.append_rule { diff --git a/themes/xresources/wallpaper.svg b/themes/xresources/wallpaper.svg new file mode 100644 index 000000000..5bcbc0b12 --- /dev/null +++ b/themes/xresources/wallpaper.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + +