awesomerc/slots/init.lua

115 lines
3.2 KiB
Lua

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'
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'
local first_tag = atag.add('home', {
screen = screen,
icon = beautiful.icon_hometag,
layout = home_layout,
master_width_factor = beautiful.hometag_master_width_factor
})
first_tag:view_only()
end
function slots.build_desktop_decoration (screen)
local desktop_bar = require 'rc.ui.desktop_decoration.bar'
desktop_bar(screen)
end
function slots.build_client_titlebars (client)
-- Mouse buttons bindings for the titlebar
local buttons = {
abutton({}, 1,
function ()
client:activate { context = 'titlebar', action = 'mouse_move' }
end),
abutton({}, 3,
function ()
client:activate { context = 'titlebar', action = 'mouse_resize' }
end),
}
-- Titlebar UI
atitlebar(client).widget = {
{ -- Left
atitlebar.widget.iconwidget(client),
buttons = buttons,
layout = lfixed.horizontal
},
{ -- Middle
{ -- Title
align = 'center',
widget = atitlebar.widget.titlewidget(client)
},
buttons = buttons,
layout = lflex.horizontal
},
{ -- Right
atitlebar.widget.floatingbutton(client),
atitlebar.widget.maximizedbutton(client),
atitlebar.widget.stickybutton(client),
atitlebar.widget.ontopbutton(client),
atitlebar.widget.closebutton(client),
layout = lfixed.horizontal()
},
layout = lalign.horizontal
}
end
function slots.naughty_display (notification)
naughty.layout.box { notification = notification }
end
return slots