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,
})

View File

@@ -1,60 +1,14 @@
local gears = require("gears")
local awful = require("awful") local awful = require("awful")
local wibox = require("wibox")
local beautiful = require("beautiful") local beautiful = require("beautiful")
-- Signal function to execute when a new client appears. -- Signal function to execute when a new client appears.
client.connect_signal("manage", function(c) client.connect_signal("manage", function(c)
-- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master.
-- if not awesome.startup then awful.client.setslave(c) end
if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then
-- Prevent clients from being unreachable after screen count changes. -- Prevent clients from being unreachable after screen count changes.
awful.placement.no_offscreen(c) awful.placement.no_offscreen(c)
end end
end) 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):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)
client.connect_signal("focus", function(c) client.connect_signal("focus", function(c)
c.border_color = beautiful.border_focus c.border_color = beautiful.border_focus
end) end)

8
rc.lua
View File

@@ -10,8 +10,10 @@ require("awful.autofocus")
local main = require("main") local main = require("main")
local bindings = require("bindings") local bindings = require("bindings")
local theme = require("theme")
local deco = require("deco")
beautiful.init(require("theme")) beautiful.init(theme)
RC = {} RC = {}
RC.vars = main.user_vars() RC.vars = main.user_vars()
@@ -20,12 +22,8 @@ RC.tags = main.tags()
awful.spawn.with_shell("picom -b") awful.spawn.with_shell("picom -b")
-- Table of layouts to cover with awful.layout.inc, order matters.
awful.layout.layouts = RC.layouts awful.layout.layouts = RC.layouts
-- Keyboard map indicator and switcher
-- mykeyboardlayout = awful.widget.keyboardlayout()
-- {{{ Wibar -- {{{ Wibar
-- Create a textclock widget -- Create a textclock widget
mytextclock = wibox.widget.textclock() mytextclock = wibox.widget.textclock()

1
theme/wallpaper.lua Normal file
View File

@@ -0,0 +1 @@
return require("gears.filesystem").get_themes_dir() .. "background.png"