Reworked config, added module autoloader

This commit is contained in:
2022-07-16 19:06:55 -07:00
parent 9da54839fb
commit 2c034c36ed
20 changed files with 256 additions and 292 deletions

View File

@ -7,9 +7,9 @@ local LayoutManager = {}
-- Get group from layout
-- We assume that this layout is in conf.layouts
-- We assume that this layout is in config.core.layouts
function LayoutManager:get_group(layout)
for k, v in pairs(conf.layouts) do
for k, v in pairs(config.core.layouts) do
for l, m in pairs(v) do
if (layout == m) then
return k
@ -19,7 +19,7 @@ function LayoutManager:get_group(layout)
end
function LayoutManager:get_alt(layout)
for k, v in pairs(conf.layouts) do
for k, v in pairs(config.core.layouts) do
for l, m in pairs(v) do
if (layout == m) then
return l
@ -31,7 +31,7 @@ end
function LayoutManager:default_layout()
return conf.layouts[1][1]
return config.core.layouts[1][1]
end
-- Change layout group
@ -44,9 +44,9 @@ function LayoutManager:group(step)
local group = self:get_group(layout) - 1
group = ((group + step) % #conf.layouts) + 1
group = ((group + step) % #config.core.layouts) + 1
awful.layout.set(conf.layouts[group][1], tag)
awful.layout.set(config.core.layouts[group][1], tag)
end
-- Change layout alternate
@ -60,9 +60,9 @@ function LayoutManager:alt(step)
local group = self:get_group(layout)
alt = ((alt + step) % #conf.layouts[group]) + 1
alt = ((alt + step) % #config.core.layouts[group]) + 1
awful.layout.set(conf.layouts[group][alt], tag)
awful.layout.set(config.core.layouts[group][alt], tag)
end
function LayoutManager:next()

View File

@ -1,13 +1,6 @@
local function start()
local desktop = {
widgets = {
tasklist = require("core.tasklist"),
textclock = modules.simple_widgets.textclock,
keymap = modules.ibus.widgets.ibus,
volume = modules.volume.widgets.volume,
launcher = modules.launcher.widgets.launcher,
shortcut = modules.simple_widgets.make_shortcut,
space = function(size)
return wibox.widget {
{
@ -39,6 +32,7 @@ local function start()
}
local tasklist = require("core.tasklist")
-- Manages tag grid and widget
local tagger = require("core.tagger.tagger")
@ -48,19 +42,6 @@ local function start()
local make_layoutbox = require("core.layouts.widget")
-- Load conditional modules
if conf.backlight_enabled then
desktop.widgets.backlight = modules.backlight.widgets.backlight
end
if conf.battery_enabled then
desktop.widgets.battery = modules.battery.widgets.battery
end
if conf.mpc_enabled then
desktop.widgets.mpc = modules.mpc.widgets.mpc
end
-- If timed wallpaper is enabled, load timed manager
if (type(beautiful.wallpaper) == "table") then
desktop.wallpaper = require("desktop.wallpaper")
@ -89,7 +70,7 @@ local function start()
timeout = 2,
call_now = false,
autostart = true,
single_shot = not conf.continuous_tag_updates,
single_shot = not config.core.continuous_tag_updates,
callback = function()
for s in screen do
@ -112,12 +93,12 @@ local function start()
-- Create the bar
s.bar = awful.wibar({
position = conf.bar_position,
position = config.core.bar_position,
screen = s,
--bg = "#00000000",
bg = beautiful.color.bar.color,
border_width = 0,
height = beautiful.dpi(conf.bar_height),
height = beautiful.dpi(config.core.bar_height),
type = "desktop"
})
@ -134,14 +115,14 @@ local function start()
end)
-- Create shortcut list from config value
if (#conf.bar_shortcuts > 0) then
if (#config.core.bar_shortcuts > 0) then
s.shortcuts = {
layout = wibox.layout.fixed.horizontal,
desktop.widgets.separator(2, 5, 3),
desktop.widgets.space(6)
}
for k, v in pairs(conf.bar_shortcuts) do
s.shortcuts[#s.shortcuts + 1] = desktop.widgets.shortcut(v[1], v[2])
for k, v in pairs(config.core.bar_shortcuts) do
s.shortcuts[#s.shortcuts + 1] = modules.simple_widgets.make_shortcut(v[1], v[2])
end
end
@ -169,26 +150,25 @@ local function start()
desktop.widgets.space(10),
})
if (conf.mpc_enabled) then
if (modules.mpc ~= nil) then
rightside = gears.table.join(rightside, {
desktop.widgets.mpc,
modules.mpc.widgets.mpc,
desktop.widgets.space(5),
desktop.widgets.separator(2, 5, 3),
desktop.widgets.space(15),
})
end
rightside = gears.table.join(rightside, {
desktop.widgets.textclock,
modules.simple_widgets.textclock,
desktop.widgets.space(8),
desktop.widgets.battery,
desktop.widgets.backlight,
desktop.widgets.volume,
--modules.battery.widgets.battery,
--modules.backlight.widgets.backlight,
modules.volume.widgets.volume,
desktop.widgets.space(8),
desktop.widgets.keymap,
modules.ibus.widgets.keymap,
desktop.widgets.space(8),
})
@ -197,7 +177,7 @@ local function start()
s.bar:setup {
layout = wibox.container.margin,
margins = beautiful.dpi(conf.bar_margin),
margins = beautiful.dpi(config.core.bar_margin),
{
layout = wibox.layout.align.horizontal,
@ -207,7 +187,7 @@ local function start()
desktop.widgets.space(8),
desktop.widgets.launcher,
modules.launcher.widgets.launcher,
desktop.widgets.space(18),
s.tagger.widget.widget,
@ -218,7 +198,7 @@ local function start()
desktop.widgets.space(6),
desktop.widgets.separator(2, 5, 3),
desktop.widgets.space(18),
desktop.widgets.tasklist(s),
tasklist(s),
},
s.mypromptbox,

View File

@ -26,11 +26,11 @@ local function make(tagger)
}
-- Calculate checkbox size limit
local cbox_maxsize = beautiful.dpi(conf.bar_height)
cbox_maxsize = cbox_maxsize - (2 * beautiful.dpi(conf.bar_margin))
local cbox_maxsize = beautiful.dpi(config.core.bar_height)
cbox_maxsize = cbox_maxsize - (2 * beautiful.dpi(config.core.bar_margin))
cbox_maxsize = cbox_maxsize - (tagger.rows - 1)*(beautiful.dpi(widget.tagindicator.spacing))
if ((conf.bar_position == "bottom") or (conf.bar_position == "top")) then
if ((config.core.bar_position == "bottom") or (config.core.bar_position == "top")) then
cbox_maxsize = cbox_maxsize / tagger.rows
else
cbox_maxsize = cbox_maxsize / tagger.cols

View File

@ -60,7 +60,7 @@ tasklist.make = function(screen)
{
id = "clienticon",
widget = awful.widget.clienticon,
forced_width = conf.clienticon_width
forced_width = config.core.clienticon_width
},
margins = beautiful.dpi(3),
widget = wibox.container.margin