add base setup with dotter

This commit is contained in:
Alexander Navarro 2024-11-08 22:53:56 +00:00 committed by aleidk
parent 6b0da868bb
commit 42e6595b60
177 changed files with 1062 additions and 70 deletions

View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Wrapper for launching the configuration from lua. This will add the river
# directory to the LUA_PATH global variable so the configuration can be
# splitted into multiple files
config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/river"
export LUA_PATH="$config_dir/?.lua;$config_dir/?/init.lua;$LUA_PATH"
lua "$config_dir"/init.lua

40
config/river/init.lua Normal file
View file

@ -0,0 +1,40 @@
local River = require('river')
local Logger = require('logger')
local logger = Logger:new()
logger:log(
[[
+---------------------------------------------------------+
| Initializing River... |
+---------------------------------------------------------+
]]
)
local config = {
}
local river = River:new()
print(type(river))
river:set_bg("$HOME/Pictures/Minimalist__cron.png")
-- ╭─────────────────────────────────────────────────────────╮
-- │ Keymaps │
-- ╰─────────────────────────────────────────────────────────╯
local mods = river.keys.modifiers
river:map { mods.super, "Return", "spawn kitty" }
river:map { mods.super_shift, "q", "exit" }
-- river:exec("rivertile -view-padding 2 -outer-padding 2 -main-ratio 0.5 -main-count 1 &")
local cmds = {
"waybar",
}
for _, cmd in ipairs(cmds) do
river:spawn(cmd)
end
logger:close()

49
config/river/logger.lua Normal file
View file

@ -0,0 +1,49 @@
--- 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
},
output = 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")
self:log("Opening logger...\n")
end
function Logger:close()
self:log("Closing logger...")
self:log("\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(...)
self.output:write("\n")
self.output:flush()
end
return Logger

80
config/river/river.lua Normal file
View file

@ -0,0 +1,80 @@
---@enum Modifiers
local modifiers = {
super = "Super ",
ctrl = "Control ",
shift = "Shift ",
alt = "Alt ",
super_shift = "Super+Shift ",
super_ctrl = "Super+Control ",
super_ctrl_shift = "Super+Control+Shift ",
ctrl_shift = "Control+Shift ",
none = "None ",
}
--- Wrapper around the riverctl cmd
---@class River
local River = {
cmds = {
background = "swaybg -i %s"
},
keys = {
modifiers = modifiers
}
}
River.__index = River
--- River class constructor
---@param new? River to override properties
---@return River
function River:new(new)
local obj = new or {}
setmetatable(obj, self)
self.__index = self
return obj
end
--- Exec an arbitrary system command
---@param cmd string the command to execute
---@private
---@return string?
function River:exec(cmd)
os.execute(cmd)
end
--- Execute the given command with riverctl spawn
---@param cmd string the command to execute
function River:spawn(cmd)
self:exec(string.format([[riverctl spawn "%s"]], cmd))
end
--- Set a new wallpaper with the default cmds.background
---@param path string The path to the image
function River:set_bg(path)
self:spawn(string.format(self.cmds.background, path))
end
---@class MapArgs
---@field [1] Modifiers The modifier to use
---@field [2] string
---@field [3] string
---@field mode? ("normal"|"locked")[], }
--- Create a new mapping
--- @param args MapArgs
function River:map(args)
local modes = args.mode or { "normal" }
for _, mode in ipairs(modes) do
local map = string.format([[riverctl map %s %s %s %s]], mode, args[1], args[2], args[3])
self:exec(map)
end
end
return River