awesomewm/rc.lua

121 lines
2.4 KiB
Lua
Executable File

-- AwesomeWM modules
gears = require("gears")
awful = require("awful")
naughty = require("naughty")
beautiful = require("beautiful")
menubar = require("menubar")
wibox = require("wibox")
require("awful.autofocus")
conf_dir = gears.filesystem.get_configuration_dir()
-- 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
-- Quick debug function
debug_message = function(msg)
naughty.notify({title = "Debug message:", text = tostring(msg)})
end
-- Order matters.
config = require("config")
beautiful.init(require("theme"))
-- Load key bindings
local keys = require("core.keybinds")
local buttons = {}
-- 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")
-- Finalize keybinds
root.keys(keys)
root.buttons(buttons)
-- Autostart
for i, v in ipairs(config.core.startup_commands) do
awful.spawn(v)
end
-- Enable hotkeys help widget for VIM and other apps
-- when client with a matching name is opened:
--require("awful.hotkeys_popup.keys")
core.start()
-- Check for errors
dofile(conf_dir .. "errors.lua")
menubar.utils.terminal = config.core.terminal
-- Load client methods
awful.rules.rules = require("clients.rules")
dofile(conf_dir .. "clients/signals.lua")
require("clients.render")