convert everything to metatables and added rules

This commit is contained in:
Noella
2024-03-04 18:38:56 -07:00
parent 497a6bd76c
commit 1e248a903d
7 changed files with 212 additions and 158 deletions

View File

@@ -1,24 +1,40 @@
local naughty = require("naughty")
-- 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 })
local _M = {}
function _M.get()
-- 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
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
return setmetatable({}, {
__call = function(_, ...)
return _M.get(...)
end,
})

9
main/init.lua Normal file
View File

@@ -0,0 +1,9 @@
local _M = {
error_handling = require("main.error_handling"),
rules = require("main.rules"),
layouts = require("main.layouts"),
taglist = require("main.taglist"),
user_vars = require("main.user_vars"),
}
return _M

View File

@@ -1,12 +1,22 @@
local awful = require("awful")
local _L = {}
local _M = {}
_L = {
awful.layout.suit.tile,
awful.layout.suit.fair,
awful.layout.suit.max,
awful.layout.suit.floating,
}
function _M.get()
local _L = {}
return _L
_L = {
awful.layout.suit.tile,
awful.layout.suit.fair,
awful.layout.suit.max,
awful.layout.suit.floating,
}
return _L
end
return setmetatable({}, {
__call = function(_, ...)
return _M.get(...)
end,
})

93
main/rules.lua Normal file
View File

@@ -0,0 +1,93 @@
local awful = require("awful")
local beautiful = require("beautiful")
local _M = {}
function _M.get(clientkeys, clientbuttons)
local _R = {
{
rule = {},
properties = {
border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
titlebars_enabled = false,
keys = clientkeys,
buttons = clientbuttons,
screen = awful.screen.preferred,
placement = awful.placement.no_overlap + awful.placement.no_offscreen,
},
},
-- Floating clients.
{
rule_any = {
instance = {
"DTA",
"copyq",
"pinentry",
},
class = {
"Arandr",
"Blueman-manager",
"Gpick",
"Kruler",
"MessageWin",
"Sxiv",
"Tor Browser",
"Wpa_gui",
"veromix",
"xtightvncviewer",
},
name = {
"Event Tester",
},
role = {
"AlarmWindow",
"ConfigManager",
"pop-up",
},
},
properties = {
floating = true,
},
},
-- Add titlebars to normal clients and dialogs
{
rule_any = {
type = { "normal", "dialog" },
},
properties = {
titlebars_enabled = true,
},
},
{
rule = { class = "Firefox" },
properties = {
screen = 1,
tag = RC.tags[2],
titlebars_enabled = false,
},
},
{
rule = { class = "Discord" },
properties = {
screen = 1,
tag = RC.tags[6],
titlebars_enabled = false,
},
},
}
return _R
end
return setmetatable({}, {
__call = function(_, ...)
return _M.get(...)
end,
})

View File

@@ -1,27 +1,37 @@
local awful = require("awful")
local _T = {}
local _M = {}
local tags = {
"󰎤 Terminal",
"󰎧 Web",
"󰎪 Code",
"󰎭 Junk",
"󰎱 Music",
"󰎳 Chat",
}
function _M.get()
local _T = {}
local layouts = {
RC.layouts[0],
RC.layouts[1],
RC.layouts[2],
RC.layouts[3],
RC.layouts[3],
RC.layouts[3],
}
local tags = {
"󰎤 Terminal",
"󰎧 Web",
"󰎪 Code",
"󰎭 Junk",
"󰎱 Music",
"󰎳 Chat",
}
awful.screen.connect_for_each_screen(function(s)
_T[s] = awful.tag(tags, s, layouts)
end)
local layouts = {
RC.layouts[0],
RC.layouts[1],
RC.layouts[2],
RC.layouts[3],
RC.layouts[3],
RC.layouts[3],
}
return _T
awful.screen.connect_for_each_screen(function(s)
_T[s] = awful.tag(tags, s, layouts)
end)
return _T
end
return setmetatable({}, {
__call = function(_, ...)
return _M.get(...)
end,
})

View File

@@ -1,11 +1,21 @@
local _V = {}
local _M = {}
_V = {
terminal = "alacritty",
editor = os.getenv("EDITOR") or "nvim",
modkey = "Mod4",
wallpaper = os.getenv("HOME") .. "/.config/awesome/theme/background.jpg",
}
_V.editor_cmd = _V.terminal .. " -e " .. _V.editor
function _M.get()
local _V = {}
return _V
_V = {
terminal = "alacritty",
editor = os.getenv("EDITOR") or "nvim",
modkey = "Mod4",
wallpaper = os.getenv("HOME") .. "/.config/awesome/theme/background.jpg",
}
_V.editor_cmd = _V.terminal .. " -e " .. _V.editor
return _V
end
return setmetatable({}, {
__call = function(_, ...)
return _M.get(...)
end,
})