awesome: win9x titlebar/borders

This commit is contained in:
Cynthia Foxwell 2022-12-17 11:57:39 -07:00
parent e065a8d86f
commit 46906bd0fb
1 changed files with 663 additions and 63 deletions

View File

@ -1,3 +1,5 @@
-- luacheck: globals awesome root globalkeys client screen debug_print
-- If LuaRocks is installed, make sure that packages installed through it are
-- found (e.g. lgi). If LuaRocks is not installed, do nothing.
pcall(require, "luarocks.loader")
@ -70,13 +72,12 @@ local terminal = config.terminal or "xterm"
local terminal_separator = config.terminal_separator or "-e"
local editor = config.editor or os.getenv("EDITOR") or "nano"
local editor_cmd = terminal .. " " .. terminal_separator .. " " .. editor
local screenshot = config.screenshot
local modkey = config.modkey or "Mod4"
local altkey = config.altkey or "Mod1"
cyclefocus.move_mouse_pointer = false
cyclefocus.cycle_filters = {
function(c, source_c) return true end,
function() return true end,
}
-- Themes define colours, icons, font and wallpapers.
@ -105,7 +106,7 @@ do
theme.wibar_height = 20
theme = beautiful.theme_assets.recolor_titlebar(theme, theme.fg_normal, "normal")
theme = beautiful.theme_assets.recolor_titlebar(theme, theme.__colors.color8, "normal")
theme = beautiful.theme_assets.recolor_titlebar(theme, theme.fg_focus, "focus")
theme = beautiful.theme_assets.recolor_layout(theme, theme.layout_fg)
@ -336,7 +337,7 @@ end
local clock_icon = makeBarIcon("clock")
local uclock = wibox.widget.textclock(markup(beautiful.widget_clock or beautiful.wibar_fg, "(UTC: %H) "), 1, "UTC")
local clock = wibox.widget.textclock(markup(beautiful.widget_clock or beautiful.wibar_fg, "%H:%M:%S"), 1)
local calendar = lain.widget.cal({
lain.widget.cal({
attach_to = {clock},
week_start = 1,
week_number = "left",
@ -462,7 +463,7 @@ awful.widget.watch(
packages
)
local function gm_round(num, idp)
--[[local function gm_round(num, idp)
local mult = 10 ^ (idp or 0)
return math.floor(num * mult + 0.5) / mult
end
@ -477,7 +478,7 @@ local function format_size(size)
return gm_round(size / (1024 * 1024 * 1024), 2) .. " GB"
end
--[[local net_up_icon = makeBarIcon("net_up")
local net_up_icon = makeBarIcon("net_up")
local net_down_icon = makeBarIcon("net_down")
local net_down = wibox.widget.textbox()
local net_up = lain.widget.net({
@ -518,7 +519,7 @@ local music_wrapper = wibox.widget({
awful.widget.watch(
'bash -c "~/.config/awesome/scripts/cmus-wrapper.sh"',
1,
function(widget, stdout, stderr, reason, code)
function(widget, stdout, _, _, code)
if code ~= 0 then
music_wrapper.visible = false
@ -526,7 +527,7 @@ awful.widget.watch(
else
music_wrapper.visible = true
local nowplaying = ""
local nowplaying
local status = stdout:match("status (.-)\n")
local duration = tonumber(stdout:match("duration (.-)\n"))
@ -856,20 +857,20 @@ globalkeys = gears.table.join(
function()
awful.spawn.with_line_callback("screenie-min", {
stdout = function(path)
awful.menu({
{
"Upload Image",
function()
awful.spawn('elixiremanager.sh "' .. path .. '"')
end,
},
{
"Copy Image",
function()
awful.spawn('xclip -selection clipboard -target image/png "' .. path .. '"')
end,
}
}):show()
awful.menu({
{
"Upload Image",
function()
awful.spawn('elixiremanager.sh "' .. path .. '"')
end,
},
{
"Copy Image",
function()
awful.spawn('xclip -selection clipboard -target image/png "' .. path .. '"')
end,
}
}):show()
end,
})
end,
@ -942,10 +943,10 @@ globalkeys = gears.table.join(
}
),--]]
cyclefocus.key(
{altkey}, Tab
{altkey}, "Tab"
),
cyclefocus.key(
{altkey, "Shift"}, Tab
{altkey, "Shift"}, "Tab"
),
-- layout
@ -1063,7 +1064,7 @@ globalkeys = gears.table.join(
)
)
clientkeys = gears.table.join(
local clientkeys = gears.table.join(
awful.key(
{modkey, "Shift"}, "f",
function(c)
@ -1167,6 +1168,19 @@ clientkeys = gears.table.join(
description = "resize to 1600x900",
group = "client",
}
),
awful.key(
{modkey}, "i",
function(c)
naughty.notify({
title = c.name,
text = "class: " .. c.class .. "\ninstance: " .. c.instance .. "\nrole: " .. (c.role or "<none>") .. "\ntype: " .. c.type,
})
end,
{
description = "dump client info",
group = "client",
}
)
)
@ -1214,7 +1228,7 @@ for i = 1, 9 do
if tag then
client.focus:move_to_tag(tag)
end
end
end
end,
{
description = "move focused client to tag #"..i,
@ -1240,7 +1254,8 @@ for i = 1, 9 do
)
end
clientbuttons = gears.table.join(
local titlebar_positions = {"top", "bottom", "left", "right"}
local clientbuttons = gears.table.join(
awful.button({}, 1, function(c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
end),
@ -1251,6 +1266,16 @@ clientbuttons = gears.table.join(
awful.button({modkey}, 3, function(c)
c:emit_signal("request::activate", "mouse_click", {raise = true})
awful.mouse.client.resize(c)
end),
awful.button({modkey, "Shift"}, 1, function(c)
for _, pos in ipairs(titlebar_positions) do
awful.titlebar.hide(c, pos)
end
end),
awful.button({modkey, "Shift"}, 3, function(c)
for _, pos in ipairs(titlebar_positions) do
awful.titlebar.show(c, pos)
end
end)
)
@ -1265,7 +1290,7 @@ awful.rules.rules = {
{
rule = {},
properties = {
border_width = beautiful.border_width,
border_width = 0, --beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
@ -1306,6 +1331,8 @@ awful.rules.rules = {
"AlarmWindow", -- Thunderbird's calendar.
"ConfigManager", -- Thunderbird's about:config.
"pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
"devtools",
"toolbox",
}
},
properties = {
@ -1325,6 +1352,30 @@ awful.rules.rules = {
titlebars_enabled = true
},
},
-- steam windows float + no titlebar
{
rule = {
instance = "Steam",
},
properties = {
floating = true,
titlebars_enabled = false,
},
},
-- tg media preview fullscreen
{
rule = {
name = "Media viewer",
instance = "telegram-desktop",
},
properties = {
titlebars_enabled = false,
floating = true,
fullscreen = true,
},
},
}
-- }}}
@ -1345,6 +1396,487 @@ client.connect_signal("manage", function (c)
end
end)
local win9x_l = {
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.secondary,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.color8,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.background,
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.__colors.background,
orientation = "vertical",
thickness = 2,
forced_width = 2,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.color0,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.tertiary,
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.__colors.secondary,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
{
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.color8,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.background,
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.__colors.color0,
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.__colors.tertiary,
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.__colors.background,
orientation = "horizontal",
thickness = 2,
forced_height = 2,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.color0,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.tertiary,
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.__colors.background,
orientation = "vertical",
thickness = 2,
forced_width = 2,
forced_height = 2,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.color0,
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.__colors.color0,
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.__colors.tertiary,
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.__colors.tertiary,
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.__colors.secondary,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.secondary,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.color8,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.color8,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.background,
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.__colors.secondary,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.color8,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.background,
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.__colors.secondary,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
{
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.color8,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.background,
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.__colors.color0,
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.__colors.tertiary,
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.__colors.background,
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.__colors.color8,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.color8,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.secondary,
orientation = "vertical",
thickness = 1,
forced_width = 1,
border_width = 0,
}),
{
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.secondary,
orientation = "horizontal",
thickness = 1,
forced_height = 1,
border_width = 0,
}),
wibox.widget({
widget = wibox.widget.separator,
color = beautiful.__colors.background,
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.__colors.color0,
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.__colors.color0,
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.__colors.tertiary,
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.__colors.tertiary,
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 win9xButton(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
@ -1359,40 +1891,104 @@ client.connect_signal("request::titlebars", function(c)
end)
)
awful.titlebar(c):setup({
{ -- Left
{
awful.titlebar.widget.iconwidget(c),
margins = 2,
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
{
awful.titlebar.widget.ontopbutton(c),
awful.titlebar.widget.stickybutton(c),
awful.titlebar.widget.floatingbutton(c),
awful.titlebar.widget.minimizebutton(c),
awful.titlebar.widget.maximizedbutton(c),
awful.titlebar.widget.closebutton(c),
layout = wibox.layout.fixed.horizontal
},
margins = 2,
layout = wibox.container.margin,
},
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.__colors.color8,
bg_focus = beautiful.__colors.accent,
})
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
{
{
win9xButton(awful.titlebar.widget.ontopbutton(c)),
win9xButton(awful.titlebar.widget.stickybutton(c)),
win9xButton(awful.titlebar.widget.floatingbutton(c)),
layout = wibox.layout.fixed.horizontal,
},
{
win9xButton(awful.titlebar.widget.minimizebutton(c)),
win9xButton(awful.titlebar.widget.maximizedbutton(c)),
layout = wibox.layout.fixed.horizontal,
},
win9xButton(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.
@ -1400,14 +1996,18 @@ end)
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)
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)
-- }}}
--{{{ Autostart
-- taken from: https://gitlab.com/luna/til/-/blob/main/awesome/rc.lua
awful.spawn.with_line_callback(HOME .. "/.local/bin/autostart.sh", {
stdout = function(line)
stdout = function()
--[[naughty.notify({
title = "autostart",
text = "pid: "..line.." already started",