dotfiles-pub/linux/.config/awesome/modules/titlebar.lua

616 lines
16 KiB
Lua

-- luacheck: globals client
local awful = require("awful")
local beautiful = require("beautiful")
local gears = require("gears")
local wibox = require("wibox")
local win9x_l = {
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_bright,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_bright,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_main,
orientation = "vertical",
thickness = 2,
forced_width = 2,
border_width = 0,
}),
forced_width = 4,
layout = wibox.layout.fixed.horizontal,
}
local win9x_r = {
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_main,
orientation = "vertical",
thickness = 2,
forced_width = 2,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_dark,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_dark,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
forced_width = 4,
layout = wibox.layout.fixed.horizontal,
}
local win9x_bl = {
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_bright,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
{
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_bright,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_main,
orientation = "vertical",
thickness = 2,
forced_width = 2,
forced_height = 2,
border_width = 0,
}),
forced_height = 2,
forced_width = 3,
layout = wibox.layout.fixed.horizontal,
},
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_dark,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
forced_height = 3,
forced_width = 3,
layout = wibox.layout.fixed.vertical,
},
forced_height = 3,
forced_width = 4,
layout = wibox.layout.fixed.horizontal,
},
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_dark,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
forced_height = 4,
forced_width = 4,
layout = wibox.layout.fixed.vertical,
}
local win9x_b = {
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_main,
orientation = "horizontal",
thickness = 2,
forced_height = 2,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_dark,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_dark,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
forced_height = 4,
layout = wibox.layout.fixed.vertical,
}
local win9x_br = {
{
{
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_main,
orientation = "vertical",
thickness = 2,
forced_width = 2,
forced_height = 2,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_dark,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
forced_height = 2,
forced_width = 3,
layout = wibox.layout.fixed.horizontal,
},
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_dark,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
forced_height = 3,
forced_width = 3,
layout = wibox.layout.fixed.vertical,
},
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_dark,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
forced_height = 3,
forced_width = 4,
layout = wibox.layout.fixed.horizontal,
},
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_dark,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
forced_height = 4,
forced_width = 4,
layout = wibox.layout.fixed.vertical,
}
local win9x_tl = {
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_bright,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_bright,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_bright,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_bright,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_main,
orientation = "vertical",
thickness = 2,
forced_width = 2,
forced_height = 2,
border_width = 0,
}),
forced_height = 2,
forced_width = 3,
layout = wibox.layout.fixed.horizontal,
},
forced_height = 3,
forced_width = 3,
layout = wibox.layout.fixed.vertical,
},
forced_height = 3,
forced_width = 4,
layout = wibox.layout.fixed.horizontal,
},
forced_height = 4,
forced_width = 4,
layout = wibox.layout.fixed.vertical,
}
local win9x_t = {
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_bright,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_bright,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_main,
orientation = "horizontal",
thickness = 2,
forced_height = 2,
border_width = 0,
}),
forced_height = 4,
layout = wibox.layout.fixed.vertical,
}
local win9x_tr = {
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_bright,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
{
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_bright,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_main,
orientation = "vertical",
thickness = 2,
forced_width = 2,
forced_height = 2,
border_width = 0,
}),
forced_height = 3,
forced_width = 2,
layout = wibox.layout.fixed.vertical,
},
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_dark,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
forced_height = 3,
forced_width = 3,
layout = wibox.layout.fixed.horizontal,
},
forced_height = 4,
forced_width = 3,
layout = wibox.layout.fixed.vertical,
},
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_dark,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
forced_height = 4,
forced_width = 4,
layout = wibox.layout.fixed.horizontal,
}
local win9x_div = {
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_main,
orientation = "horizontal",
thickness = 2,
forced_height = 2,
border_width = 0,
}),
forced_height = 2,
layout = wibox.layout.fixed.vertical,
}
local win9x_btn = {
{
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_bright,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_bright,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_bright,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_bright,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_main,
orientation = "horizontal",
thickness = 10,
forced_height = 10,
border_width = 0,
}),
forced_height = 11,
forced_width = 12,
layout = wibox.layout.fixed.vertical,
},
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_dark,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
forced_height = 11,
forced_width = 14,
layout = wibox.layout.fixed.horizontal,
},
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_dark,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
forced_height = 13,
forced_width = 14,
layout = wibox.layout.fixed.vertical,
},
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_dark,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
forced_height = 13,
forced_width = 16,
layout = wibox.layout.fixed.horizontal,
},
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.win9x_outer_dark,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
forced_height = 14,
forced_width = 16,
layout = wibox.layout.fixed.vertical,
},
forced_height = 16,
forced_width = 16,
top = 1,
bottom = 1,
layout = wibox.container.margin,
}
local function make_win9x_button(child)
return {
win9x_btn,
child,
layout = wibox.layout.stack,
}
end
-- Add a titlebar if titlebars_enabled is set to true in the rules.
client.connect_signal("request::titlebars", function(c)
-- buttons for the titlebar
local buttons = gears.table.join(
awful.button({}, 1, function()
c:emit_signal("request::activate", "titlebar", {raise = true})
awful.mouse.client.move(c)
end),
awful.button({}, 3, function()
c:emit_signal("request::activate", "titlebar", {raise = true})
awful.mouse.client.resize(c)
end)
)
awful.titlebar(c, {
position = "left",
size = 4,
bg_normal = "#00000000",
bg_focus = "#00000000",
}):setup(win9x_l)
awful.titlebar(c, {
position = "right",
size = 4,
bg_normal = "#00000000",
bg_focus = "#00000000",
}):setup(win9x_r)
awful.titlebar(c, {
position = "bottom",
size = 4,
bg_normal = "#00000000",
bg_focus = "#00000000",
}):setup({
win9x_bl,
win9x_b,
win9x_br,
layout = wibox.layout.align.horizontal,
})
local titlebar = awful.titlebar(c, {
size = 24,
fg_normal = beautiful.win9x_unfocus,
fg_focus = beautiful.fg_focus,
bg_normal = beautiful.win9x_dark,
bg_focus = beautiful.win9x_focus,
})
titlebar:setup({
{
win9x_tl,
win9x_t,
win9x_tr,
forced_height = 4,
layout = wibox.layout.align.horizontal,
},
{
win9x_l,
{
{
{ -- Left
{
awful.titlebar.widget.iconwidget(c),
left = 2,
right = 2,
top = 1,
bottom = 1,
layout = wibox.container.margin,
},
{
awful.titlebar.widget.titlewidget(c),
left = 2,
layout = wibox.container.margin,
},
buttons = buttons,
layout = wibox.layout.fixed.horizontal
},
{ -- Middle
buttons = buttons,
layout = wibox.layout.flex.horizontal
},
{ -- Right
{
{
make_win9x_button(awful.titlebar.widget.ontopbutton(c)),
make_win9x_button(awful.titlebar.widget.stickybutton(c)),
make_win9x_button(awful.titlebar.widget.floatingbutton(c)),
layout = wibox.layout.fixed.horizontal,
},
{
make_win9x_button(awful.titlebar.widget.minimizebutton(c)),
make_win9x_button(awful.titlebar.widget.maximizedbutton(c)),
layout = wibox.layout.fixed.horizontal,
},
make_win9x_button(awful.titlebar.widget.closebutton(c)),
spacing = 2,
layout = wibox.layout.fixed.horizontal
},
left = 2,
right = 2,
top = 1,
bottom = 1,
layout = wibox.container.margin,
},
forced_height = 18,
layout = wibox.layout.align.horizontal,
},
win9x_div,
layout = wibox.layout.align.vertical,
},
win9x_r,
layout = wibox.layout.align.horizontal,
},
layout = wibox.layout.align.vertical,
})
end)
-- Enable sloppy focus, so that focus follows mouse.
--[[client.connect_signal("mouse::enter", function(c)
c:emit_signal("request::activate", "mouse_enter", {raise = false})
end)
client.connect_signal("focus", function(c)
c.border_color = beautiful.border_focus
end)
client.connect_signal("unfocus", function(c)
c.border_color = beautiful.border_normal
end)
--]]