awesomerc/slots/init.lua

117 lines
3.2 KiB
Lua
Raw Normal View History

2021-11-29 18:53:23 +01:00
local abutton = require "awful.button"
local atitlebar = require "awful.titlebar"
local beautiful = require "beautiful"
local lalign = require "wibox.layout.align"
local lfixed = require "wibox.layout.fixed"
local lflex = require "wibox.layout.flex"
local naughty = require "naughty"
2021-05-25 17:37:29 +02:00
local slots = {}
2021-09-29 01:48:44 +02:00
function slots.wallpaper(screen)
2021-11-29 18:53:23 +01:00
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
2021-09-29 01:48:44 +02:00
local screen_geo = screen.geometry
2021-11-29 18:53:23 +01:00
local source = cairo.ImageSurface(
cairo.Format.RGB32,
screen_geo.width,
screen_geo.height
)
2021-09-29 01:48:44 +02:00
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 = {
2021-11-29 18:53:23 +01:00
{ 0, "#26323840" },
},
2021-09-29 01:48:44 +02:00
}
cr:set_source(color_pattern)
cr:paint()
awallpaper {
screen = screen,
widget = {
image = source,
widget = imagebox,
2021-11-29 18:53:23 +01:00
},
2021-09-29 01:48:44 +02:00
}
end
2021-11-29 18:53:23 +01:00
function slots.create_tags(screen)
local atag = require "awful.tag"
local home_layout = require "MyTagLayout.home_layout"
2021-06-28 19:05:22 +02:00
2021-11-29 18:53:23 +01:00
local first_tag = atag.add("home", {
2021-06-28 19:05:22 +02:00
screen = screen,
icon = beautiful.icon_hometag,
layout = home_layout,
2021-11-29 18:53:23 +01:00
master_width_factor = beautiful.hometag_master_width_factor,
2021-06-28 19:05:22 +02:00
})
first_tag:view_only()
2021-05-25 17:37:29 +02:00
end
2021-11-29 18:53:23 +01:00
function slots.build_desktop_decoration(screen)
local desktop_bar = require "rc.ui.desktop_decoration.bar"
2021-05-25 17:37:29 +02:00
desktop_bar(screen)
end
2021-11-29 18:53:23 +01:00
function slots.build_client_titlebars(client)
2021-05-25 17:37:29 +02:00
-- Mouse buttons bindings for the titlebar
local buttons = {
2021-11-29 18:53:23 +01:00
abutton({}, 1, function()
client:activate { context = "titlebar", action = "mouse_move" }
end),
abutton({}, 3, function()
client:activate { context = "titlebar", action = "mouse_resize" }
end),
2021-05-25 17:37:29 +02:00
}
-- Titlebar UI
atitlebar(client).widget = {
{ -- Left
atitlebar.widget.iconwidget(client),
buttons = buttons,
2021-11-29 18:53:23 +01:00
layout = lfixed.horizontal,
2021-05-25 17:37:29 +02:00
},
{ -- Middle
{ -- Title
2021-11-29 18:53:23 +01:00
align = "center",
widget = atitlebar.widget.titlewidget(client),
2021-05-25 17:37:29 +02:00
},
buttons = buttons,
2021-11-29 18:53:23 +01:00
layout = lflex.horizontal,
2021-05-25 17:37:29 +02:00
},
{ -- Right
atitlebar.widget.floatingbutton(client),
atitlebar.widget.maximizedbutton(client),
atitlebar.widget.stickybutton(client),
atitlebar.widget.ontopbutton(client),
atitlebar.widget.closebutton(client),
2021-11-29 18:53:23 +01:00
layout = lfixed.horizontal(),
2021-05-25 17:37:29 +02:00
},
2021-11-29 18:53:23 +01:00
layout = lalign.horizontal,
2021-05-25 17:37:29 +02:00
}
end
2021-11-29 18:53:23 +01:00
function slots.naughty_display(notification)
2021-05-25 17:37:29 +02:00
naughty.layout.box { notification = notification }
end
return slots