awesomewm/rc.lua

138 lines
2.9 KiB
Lua
Raw Normal View History

2022-07-16 17:41:00 -07:00
-- AwesomeWM modules
2021-08-01 07:24:26 -07:00
gears = require("gears")
awful = require("awful")
naughty = require("naughty")
beautiful = require("beautiful")
menubar = require("menubar")
wibox = require("wibox")
require("awful.autofocus")
2023-08-21 19:00:27 -07:00
-- Load configuration
2022-07-16 17:41:00 -07:00
conf_dir = gears.filesystem.get_configuration_dir()
2023-08-21 19:00:27 -07:00
conf_env = os.getenv("AWESOMEWM_CONFIG")
2023-10-10 10:57:39 -07:00
config = require("defaults")
2023-08-21 19:00:27 -07:00
if (conf_env == nil) then
-- Default location: in this directory
dofile(conf_dir .. "/config.lua")
else
dofile(conf_env)
end
2021-08-01 07:24:26 -07:00
2022-07-16 17:41:00 -07:00
-- A "relative require" hack. Does the same thing as `require`,
-- But takes a relative path.
-- Called with req_rel(..., "module")
function req_rel(ddd, modname)
local parent_folder = (ddd):match("(.-)[^%.]+$")
return require(parent_folder .. modname)
end
2021-08-01 07:24:26 -07:00
-- Quick debug function
debug_message = function(msg)
naughty.notify({title = "Debug message:", text = tostring(msg)})
end
beautiful.init(require("theme"))
2022-07-16 17:10:17 -07:00
2022-07-16 17:41:00 -07:00
-- Load key bindings
2022-07-17 21:18:00 -07:00
local keys = require("core.keybinds")
local buttons = {}
2023-09-03 09:26:07 -07:00
-- Preferred client icon size, in pixels.
-- Set this to bar height, since that's the largest icon we'll ever draw.
-- This fixes the icon size given by client.icon. Client.icon give the smallest size by default.
awesome.set_preferred_icon_size(beautiful.dpi(config.core.bar_height))
2022-07-18 11:04:06 -07:00
-- Bind first 5 shortcuts to Mod + #.
local i = 0
for k, v in pairs(config.core.bar_shortcuts) do
i = i + 1
if (i > 5) then
goto done_shortcuts
end
keys = gears.table.join(keys,
awful.key(
{ "Mod4" }, i,
function()
awful.spawn(v[1], false)
end,
{
description = "Launch ".. v[1],
group = "Shortcuts"
}
)
)
end
::done_shortcuts::
-- Load modules
-- Every config table key (except "core") represents a module we should load.
modules = {}
for k, v in pairs(config) do
if (k == "core") then
goto skip_module
elseif (config[k].enabled == false) then
goto skip_module
elseif (config[k].enabled == nil) then
debug_message("Module " .. k .. " is not enabled, skipping.")
goto skip_module
end
modules[k] = require("modules." .. k)
-- If module defines keybinds, load keybinds.
if (modules[k]["keybinds"] ~= nil) then
keys = gears.table.join(
keys,
modules[k]["keybinds"]
)
end
::skip_module::
end
-- Run all module init methods
for _, mod in pairs(modules) do
if (mod["init"] ~= nil) then
mod["init"]()
end
end
core = require("core")
2022-07-16 17:41:00 -07:00
-- Finalize keybinds
root.keys(keys)
root.buttons(buttons)
2021-08-01 07:24:26 -07:00
2022-06-14 07:52:02 -07:00
-- Autostart
for i, v in ipairs(config.core.startup_commands) do
2022-06-14 07:52:02 -07:00
awful.spawn(v)
end
2021-08-01 07:24:26 -07:00
-- Enable hotkeys help widget for VIM and other apps
-- when client with a matching name is opened:
--require("awful.hotkeys_popup.keys")
2022-07-16 17:10:17 -07:00
core.start()
2021-08-01 07:24:26 -07:00
-- Check for errors
2022-07-16 17:41:00 -07:00
dofile(conf_dir .. "errors.lua")
2021-08-01 07:24:26 -07:00
menubar.utils.terminal = config.core.terminal
2021-08-01 07:24:26 -07:00
-- Load client methods
awful.rules.rules = require("clients.rules")
2022-07-16 17:41:00 -07:00
dofile(conf_dir .. "clients/signals.lua")
2021-08-01 07:24:26 -07:00
require("clients.render")