update river config
This commit is contained in:
parent
ffa2bac00b
commit
a3804e67a5
4 changed files with 117 additions and 27 deletions
|
|
@ -1,7 +1,36 @@
|
|||
local River = {}
|
||||
---@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 {}
|
||||
|
||||
|
|
@ -11,9 +40,41 @@ function River:new(new)
|
|||
return obj
|
||||
end
|
||||
|
||||
function River:exec(args)
|
||||
print("Executing: " .. args)
|
||||
os.execute(args)
|
||||
--- 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue