aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/quarrel/const.lua
diff options
context:
space:
mode:
authordelta <darkussdelta@gmail.com>2025-07-04 00:38:29 +0200
committerdelta <darkussdelta@gmail.com>2025-07-04 00:38:29 +0200
commitb3530d7c4a102935fa26498a160ee1dc6c1e9c03 (patch)
treed7751206a694bc5de2d6b34b0c077cfcd1855798 /.config/awesome/quarrel/const.lua
parentdf75ec5ed5e3848c497f0439acb43ec9246ad3e7 (diff)
:3
Diffstat (limited to '.config/awesome/quarrel/const.lua')
-rw-r--r--.config/awesome/quarrel/const.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/.config/awesome/quarrel/const.lua b/.config/awesome/quarrel/const.lua
new file mode 100644
index 0000000..342ae41
--- /dev/null
+++ b/.config/awesome/quarrel/const.lua
@@ -0,0 +1,22 @@
+local M = {}
+
+---@param protected (fun(): table) | table
+function M.protect(protected)
+ ---@type table
+ local tbl
+ if type(protected) == "table" then
+ tbl = protected
+ elseif type(protected) == "function" then
+ tbl = protected()
+ else
+ error("expected a table or a function that returns a table, got " .. type(protected), 2)
+ end
+ return setmetatable({}, {
+ __index = tbl,
+ __newindex = function(_, k, v)
+ error("attempted to change constant " .. tostring(k) .. " to " .. tostring(v), 2)
+ end,
+ })
+end
+
+return M