-- omarchy.lua — compatibility shim for the carried Omarchy-style Lua files.---- Omarchy configures Hyprland in Lua on top of Hyprland's own `hl` API and adds-- a few `o.*` conveniences. bindings.lua, lid.lua and caelestia.lua were-- written against those, so the two helpers they use are provided here with-- the same shapes, plus one NixOS addition (o.cmd_or_gone). `o` is also set as-- a global, which is how the carried files reach it.localo= {}
o.bin =os.getenv("HOME") .."/.local/bin"localfunctionto_dispatcher(command)
iftype(command) =="string"thenreturnhl.dsp.exec_cmd(command)
endiftype(command) =="table"andcommand.launch then-- launch = "cmd": run in its own systemd scope (uwsm) like Omarchy's launcher didreturnhl.dsp.exec_cmd("uwsm app -- "..command.launch)
endreturncommand-- a dispatcher (hl.dsp.*) or a Lua functionend-- o.bind(keys, description, command, options)-- command: shell string, { launch = "…" }, hl.dsp.* dispatcher, or function-- options: hl.bind flags (locked, repeating, release, mouse, …)functiono.bind(keys, description, command, options)
localflags= {}
fork, vinpairs(optionsor {}) doflags[k] =vendifdescriptionanddescription~=""thenflags.description =descriptionendreturnhl.bind(keys, to_dispatcher(command), flags)
end-- o.window(match, rules): match is a class regex or a match tablefunctiono.window(match, rules)
localrule= { match=type(match) =="table"andmatchor { class=match } }
fork, vinpairs(rules) dorule[k] =vendreturnhl.window_rule(rule)
end-- o.cmd_or_gone(cmd, description, note): shell string that runs `cmd` when its-- program is on PATH and otherwise shows what the key used to do. For binds-- whose tool is not in the carried toolbox (yet).functiono.cmd_or_gone(cmd, description, note)
localname=cmd:match("^%S+")
returnstring.format(
"sh -c 'command -v %s >/dev/null 2>&1 && exec %s || exec omarchy-not-ported %q %q'",
name, cmd, description, noteor"" )
end_G.o=oreturno