dotfiles/config/awesome/rc.lua

114 lines
3.4 KiB
Lua
Raw Normal View History

2023-03-16 05:12:44 -04:00
-- {{{ Modules
2022-01-18 19:11:06 -05:00
-- If LuaRocks is installed, make sure that packages installed through it are
-- found (e.g. lgi). If LuaRocks is not installed, do nothing.
pcall(require, "luarocks.loader")
local gears = require("gears")
local awful = require("awful")
require("awful.autofocus")
local beautiful = require("beautiful")
local naughty = require("naughty")
local hotkeys_popup = require("awful.hotkeys_popup")
-- Enable hotkeys help widget for VIM and other apps
-- when client with a matching name is opened:
require("awful.hotkeys_popup.keys")
2023-03-16 05:12:44 -04:00
local options = require("options")
2022-01-18 19:11:06 -05:00
-- Load Debian menu entries
2022-01-23 09:23:31 -05:00
local is_deb, debian = pcall(require, "debian.menu")
2022-01-18 19:11:06 -05:00
local has_fdo, freedesktop = pcall(require, "freedesktop")
2023-03-16 05:12:44 -04:00
-- }}}
2022-01-18 19:11:06 -05:00
-- {{{ Error handling
-- Check if awesome encountered an error during startup and fell back to
-- another config (This code will only ever execute for the fallback config)
if awesome.startup_errors then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors })
end
-- Handle runtime errors after startup
do
local in_error = false
awesome.connect_signal("debug::error", function (err)
-- Make sure we don't go into an endless error loop
if in_error then return end
in_error = true
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = tostring(err) })
in_error = false
end)
end
-- }}}
2023-03-16 05:12:44 -04:00
-- {{{ Initialization
-- Run apps on startup
require("custom.applications")
2022-01-19 19:15:26 -05:00
2023-03-16 05:12:44 -04:00
-- Initialize theme
if not beautiful.init(options.theme) then
2022-01-19 19:15:26 -05:00
naughty.notify({ preset = naughty.config.presets.critical,
title = string.format("Couldn't load custom theme at %s! Falling back to the default one.", theme),
text = awesome.startup_errors })
beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua") -- Fallback to default themes
end
2022-01-18 19:11:06 -05:00
-- Table of layouts to cover with awful.layout.inc, order matters.
awful.layout.layouts = {
awful.layout.suit.floating,
awful.layout.suit.tile,
2022-01-24 12:06:29 -05:00
awful.layout.suit.max
2022-01-18 19:11:06 -05:00
}
-- Create a launcher widget and a main menu
myawesomemenu = {
{ "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
2023-03-16 05:12:44 -04:00
{ "manual", options.terminal .. " -e man awesome" },
{ "edit config", options.editor_cmd .. " " .. awesome.conffile },
2022-01-18 19:11:06 -05:00
{ "restart", awesome.restart },
{ "quit", function() awesome.quit() end },
}
local menu_awesome = { "awesome", myawesomemenu, beautiful.awesome_icon }
local menu_terminal = { "open terminal", terminal }
if has_fdo then
mymainmenu = freedesktop.menu.build({
before = { menu_awesome },
after = { menu_terminal }
})
2022-01-23 09:23:31 -05:00
elseif is_deb then
2022-01-18 19:11:06 -05:00
mymainmenu = awful.menu({
items = {
menu_awesome,
{ "Debian", debian.menu.Debian_menu.Debian },
menu_terminal,
}
})
2022-01-23 09:23:31 -05:00
else
mymainmenu = awful.menu({
items = {
menu_awesome,
menu_terminal,
}
})
2022-01-18 19:11:06 -05:00
end
2023-03-16 05:12:44 -04:00
-- Initialize screens
require("custom.screen")
2022-01-18 19:11:06 -05:00
2023-03-16 05:12:44 -04:00
-- Set keybindings
require("custom.bindings")
2022-01-18 19:11:06 -05:00
2023-03-16 05:12:44 -04:00
-- Load client rules
require("custom.rules")
2022-01-18 19:11:06 -05:00
2023-03-16 05:12:44 -04:00
-- Load client signals
require("custom.signals")
2022-01-18 19:11:06 -05:00
-- }}}