From a0a8250d144ca4c82c7911732ee16b3f875ad162 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Wed, 29 Sep 2021 01:48:44 +0200 Subject: [PATCH] =?UTF-8?q?add(wallpaper)=20pizza=20=F0=9F=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.lua | 2 +- slots/init.lua | 39 +++++++++++++++++++++++++++++++++++++++ theme/init.lua | 40 +--------------------------------------- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/init.lua b/init.lua index ee725d7..8ade968 100644 --- a/init.lua +++ b/init.lua @@ -44,7 +44,7 @@ local load_wallpaper = slot { action = slot.actions.CREATE | slot.actions.CONNECT, target = capi.screen, signal = 'request::wallpaper', - slot = slot.slots.screen.wallpaper + slot = my_slots.wallpaper } -- luacheck: ignore unused variable default_layout diff --git a/slots/init.lua b/slots/init.lua index c222b2c..5d7439d 100644 --- a/slots/init.lua +++ b/slots/init.lua @@ -8,6 +8,45 @@ local naughty = require 'naughty' local slots = {} +function slots.wallpaper(screen) + local awallpaper = require 'awful.wallpaper' + local beautiful = require 'beautiful' + local gcolor = require 'gears.color' + local gsurface = require 'gears.surface' + local imagebox = require 'wibox.widget.imagebox' + local cairo = require('lgi').cairo + + local screen_geo = screen.geometry + local source = cairo.ImageSurface(cairo.Format.RGB32, screen_geo.width, screen_geo.height) + local cr = cairo.Context(source) + + -- Load base image + local image_surface = gsurface.load_uncached(beautiful.wallpaper) + local w, h = gsurface.get_size(image_surface) + cr:scale(screen_geo.width / w, screen_geo.height / h) + cr:set_source_surface(image_surface, 0, 0) + cr:paint() + + -- Add color layer + local color_pattern = gcolor.create_linear_pattern { + from = { 0, 0 }, + to = { screen.width, screen.height }, + stops = { + { 0, '#26323840' } + } + } + cr:set_source(color_pattern) + cr:paint() + + awallpaper { + screen = screen, + widget = { + image = source, + widget = imagebox, + } + } +end + function slots.create_tags (screen) local atag = require 'awful.tag' local home_layout = require 'MyTagLayout.home_layout' diff --git a/theme/init.lua b/theme/init.lua index 12a182f..daa0adf 100644 --- a/theme/init.lua +++ b/theme/init.lua @@ -55,44 +55,6 @@ theme.bg_systray = '#455A64' theme.systray_icon_spacing = 3 --- Wallpaper -theme.wallpaper = function (screen) - local cairo = require('lgi').cairo - local surface = require 'gears.surface' - local wallpaper = require 'gears.wallpaper' - - local wallpaper_image_path = assets_dir .. 'wallpapers/pizza.jpg' - - local geom, cr = wallpaper.prepare_context(screen) - -- local surf = cairo.ImageSurface.create(cairo.Format.RGB24, 200, 200) - local surf = surface.load_uncached(wallpaper_image_path) - local w, h = surface.get_size(surf) - local aspect_w = geom.width / w - local aspect_h = geom.height / h - - -- scall the surface to the screen dimenssion ignoring aspect ratio - cr:scale(aspect_w, aspect_h) - cr:set_source_surface(surf, 0, 0) - cr:paint() - - -- Add colored layer - local cm = cairo.LinearPattern(0, 0, w, h) - cm:add_color_stop_rgba(0, 38/256, 50/256, 56/256, 0.2) - cr:set_source(cm) - cr:paint() - - -- Add vignette effect - local linpat = cairo.LinearPattern(0, 0, w, h) - linpat:add_color_stop_rgba(0, 0, 0, 0, 1) - local radpat = cairo.RadialPattern( - w / 2, h / 2, h * 0.5, - w / 2, h / 2, w * 0.5) - for i=0,1,0.1 do - radpat:add_color_stop_rgba(i, 0, 0, 0, i/2) - end - cr:set_source(linpat) - cr:mask(radpat) - - surf:finish() -end +theme.wallpaper = assets_dir .. 'wallpapers/pizza.jpg' return theme