Added Deco Module

This commit is contained in:
Noella
2024-03-04 22:32:18 -07:00
parent 9410017416
commit 5babd2e2bc
9 changed files with 216 additions and 51 deletions

30
deco/layoutbox.lua Normal file
View File

@@ -0,0 +1,30 @@
local awful = require("awful")
local gears = require("gears")
local _M = {}
function _M.get(s)
local layoutbox = awful.widget.layoutbox(s)
layoutbox:buttons(gears.table.join(
awful.button({}, 1, function()
awful.layout.inc(1)
end),
awful.button({}, 3, function()
awful.layout.inc(-1)
end),
awful.button({}, 4, function()
awful.layout.inc(1)
end),
awful.button({}, 5, function()
awful.layout.inc(-1)
end)
))
return layoutbox
end
return setmetatable({}, {
__call = function(_, ...)
return _M.get(...)
end,
})

41
deco/statusbar.lua Normal file
View File

@@ -0,0 +1,41 @@
local gears = require("gears")
local awful = require("awful")
local wibox = require("wibox")
local wallpaper = require("deco.wallpaper")
local taglist = require("deco.taglist")
local tasklist = require("deco.tasklist")
local layoutbox = require("deco.layoutbox")
awful.screen.connect_for_each_screen(function(s)
wallpaper(s)
-- Create a promptbox for each screen
s.promptbox = awful.widget.prompt()
s.layoutbox = layoutbox(s)
s.taglist = taglist(s)
s.tasklist = tasklist(s)
-- Create the wibox
s.wibox = awful.wibar({ position = "bottom", screen = s })
-- Add widgets to the wibox
s.wibox:setup({
layout = wibox.layout.align.horizontal,
{ -- Left widgets
layout = wibox.layout.fixed.horizontal,
s.taglist,
s.promptbox,
},
s.tasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
wibox.widget.systray(),
mytextclock,
s.layoutbox,
},
})
end)

41
deco/taglist.lua Normal file
View File

@@ -0,0 +1,41 @@
local awful = require("awful")
local gears = require("gears")
local _M = {}
function _M.get(s)
local taglist_buttons = gears.table.join(
awful.button({}, 1, function(t)
t:view_only()
end),
awful.button({ RC.vars.modkey }, 1, function(t)
if client.focus then
client.focus:move_to_tag(t)
end
end),
awful.button({}, 3, awful.tag.viewtoggle),
awful.button({ RC.vars.modkey }, 3, function(t)
if client.focus then
client.focus:toggle_tag(t)
end
end),
awful.button({}, 4, function(t)
awful.tag.viewnext(t.screen)
end),
awful.button({}, 5, function(t)
awful.tag.viewprev(t.screen)
end)
)
return awful.widget.taglist({
screen = s,
filter = awful.widget.taglist.filter.all,
buttons = taglist_buttons,
})
end
return setmetatable({}, {
__call = function(_, ...)
return _M.get(...)
end,
})

36
deco/tasklist.lua Normal file
View File

@@ -0,0 +1,36 @@
local awful = require("awful")
local gears = require("gears")
local _M = {}
function _M.get(s)
local tasklist_buttons = gears.table.join(
awful.button({}, 1, function(c)
if c == client.focus then
c.minimized = true
else
c:emit_signal("request::activate", "tasklist", { raise = true })
end
end),
awful.button({}, 3, function()
awful.menu.client_list({ theme = { width = 250 } })
end),
awful.button({}, 4, function()
awful.client.focus.byidx(1)
end),
awful.button({}, 5, function()
awful.client.focus.byidx(-1)
end)
)
return awful.widget.tasklist({
screen = s,
filter = awful.widget.tasklist.filter.currenttags,
buttons = tasklist_buttons,
})
end
return setmetatable({}, {
__call = function(_, ...)
return _M.get(...)
end,
})

43
deco/titlebar.lua Normal file
View File

@@ -0,0 +1,43 @@
local awful = require("awful")
local gears = require("gears")
local wibox = require("wibox")
-- 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):setup({
{ -- Left
awful.titlebar.widget.iconwidget(c),
buttons = buttons,
layout = wibox.layout.fixed.horizontal,
},
{ -- Middle
{ -- Title
align = "center",
widget = awful.titlebar.widget.titlewidget(c),
},
buttons = buttons,
layout = wibox.layout.flex.horizontal,
},
{ -- Right
awful.titlebar.widget.floatingbutton(c),
awful.titlebar.widget.maximizedbutton(c),
awful.titlebar.widget.stickybutton(c),
awful.titlebar.widget.ontopbutton(c),
awful.titlebar.widget.closebutton(c),
layout = wibox.layout.fixed.horizontal(),
},
layout = wibox.layout.align.horizontal,
})
end)

21
deco/wallpaper.lua Normal file
View File

@@ -0,0 +1,21 @@
local awful = require("awful")
local gears = require("gears")
local _W = {}
function _W.set_wallpaper(s)
local wallpaper = require("theme.wallpaper")
if type(wallpaper) == "function" then
wallpaper = wallpaper(s)
end
gears.wallpaper.maximized(wallpaper, s, true)
end
screen.connect_signal("property::geometry", _W.set_wallpaper)
return setmetatable({}, {
__call = function(_, ...)
return _W.set_wallpaper(...)
end,
})