NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor
git clone https://git.daemon-sec.xyz/NixDaemon.git
Log | Files | Refs | README

omarchy.lua (2106B)


      1 -- omarchy.lua — compatibility shim for the carried Omarchy-style Lua files.
      2 --
      3 -- Omarchy configures Hyprland in Lua on top of Hyprland's own `hl` API and adds
      4 -- a few `o.*` conveniences. bindings.lua, lid.lua and caelestia.lua were
      5 -- written against those, so the two helpers they use are provided here with
      6 -- the same shapes, plus one NixOS addition (o.cmd_or_gone). `o` is also set as
      7 -- a global, which is how the carried files reach it.
      8 local o = {}
      9 
     10 o.bin = os.getenv("HOME") .. "/.local/bin"
     11 
     12 local function to_dispatcher(command)
     13   if type(command) == "string" then
     14     return hl.dsp.exec_cmd(command)
     15   end
     16   if type(command) == "table" and command.launch then
     17     -- launch = "cmd": run in its own systemd scope (uwsm) like Omarchy's launcher did
     18     return hl.dsp.exec_cmd("uwsm app -- " .. command.launch)
     19   end
     20   return command -- a dispatcher (hl.dsp.*) or a Lua function
     21 end
     22 
     23 -- o.bind(keys, description, command, options)
     24 --   command: shell string, { launch = "…" }, hl.dsp.* dispatcher, or function
     25 --   options: hl.bind flags (locked, repeating, release, mouse, …)
     26 function o.bind(keys, description, command, options)
     27   local flags = {}
     28   for k, v in pairs(options or {}) do
     29     flags[k] = v
     30   end
     31   if description and description ~= "" then
     32     flags.description = description
     33   end
     34   return hl.bind(keys, to_dispatcher(command), flags)
     35 end
     36 
     37 -- o.window(match, rules): match is a class regex or a match table
     38 function o.window(match, rules)
     39   local rule = { match = type(match) == "table" and match or { class = match } }
     40   for k, v in pairs(rules) do
     41     rule[k] = v
     42   end
     43   return hl.window_rule(rule)
     44 end
     45 
     46 -- o.cmd_or_gone(cmd, description, note): shell string that runs `cmd` when its
     47 -- program is on PATH and otherwise shows what the key used to do. For binds
     48 -- whose tool is not in the carried toolbox (yet).
     49 function o.cmd_or_gone(cmd, description, note)
     50   local name = cmd:match("^%S+")
     51   return string.format(
     52     "sh -c 'command -v %s >/dev/null 2>&1 && exec %s || exec omarchy-not-ported %q %q'",
     53     name, cmd, description, note or ""
     54   )
     55 end
     56 
     57 _G.o = o
     58 return o