add river config

This commit is contained in:
Alexander Navarro 2024-10-29 17:00:53 -03:00
parent 6af792a0e9
commit ffa2bac00b
Signed by untrusted user who does not match committer: anavarro
GPG key ID: 6426043E9FA3E3B5
3 changed files with 89 additions and 0 deletions

View file

@ -0,0 +1,22 @@
#! /usr/bin/env lua
-- ╭─────────────────────────────────────────────────────────╮
-- │ Add river config folder to Lua Path │
-- ╰─────────────────────────────────────────────────────────╯
local config_dir = os.getenv("XDG_CONFIG_HOME") or os.getenv("HOME") .. "/.config/"
local river_config_dir = config_dir .. "river/"
package.path = river_config_dir .. '?.lua;' .. river_config_dir .. '?/init.lua;' .. package.path
local River = require('river')
local Logger = require('logger')
local logger = Logger:new()
logger:log("Initializing River configuration from Lua")
local river = River:new()
river:exec([[riverctl spawn "swaybg -i $HOME/Pictures/Minimalist__cron.png"]])
logger:close()

View file

@ -0,0 +1,48 @@
--- Logger interface
---@class Logger
---@field available_outputs table<string, file*> Available outputs to use in the logger
---@field output file* The open file to write to
local Logger = {
available_outputs = {
stdout = io.stdout
},
}
Logger.__index = Logger
--- Create a new logger instance
---@param output? file* io.stdout by default, [see Logger.available_outputs](lua://Logger.available_outputs) for possible values
---@return Logger
function Logger:new(output)
local obj = {
output = output or Logger.available_outputs.stdout
}
setmetatable(obj, self)
self.__index = self
self:open()
return obj
end
function Logger:open()
self:log("\n\n\n")
self:log("Opening logger...")
end
function Logger:close()
self:log("Closing logger...")
self:log("\n\n\n")
self.output:close()
end
--- Write data to ouput, it passes the arguments directly to file:write(...)
---@param ... string|number the data to write
function Logger:log(...)
self.output:write(arg)
self.output:write("\n")
self.output:flush()
end
return Logger

View file

@ -0,0 +1,19 @@
local River = {}
River.__index = River
function River:new(new)
local obj = new or {}
setmetatable(obj, self)
self.__index = self
return obj
end
function River:exec(args)
print("Executing: " .. args)
os.execute(args)
end
return River