mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-02 04:37:49 +02:00
Evaluate NVIDIA session env vars from default/hypr/nvidia.lua during Hyprland startup instead of appending them to each user's envs.lua during setup. This removes the per-user NVIDIA setup script execution while preserving the GSP/non-GSP detection.
115 lines
2.6 KiB
Lua
115 lines
2.6 KiB
Lua
-- Shared helpers for Hyprland Lua configuration.
|
|
|
|
o = o or {}
|
|
|
|
local function shell_quote(value)
|
|
return "'" .. tostring(value):gsub("'", "'\\''") .. "'"
|
|
end
|
|
|
|
o.shell_quote = shell_quote
|
|
|
|
function o.shell_succeeds(command)
|
|
local ok, _, code = os.execute(command .. " >/dev/null 2>&1")
|
|
return ok == true or ok == 0 or code == 0
|
|
end
|
|
|
|
function o.cmd_present(command)
|
|
return o.shell_succeeds("command -v " .. shell_quote(command))
|
|
end
|
|
|
|
function o.cmd_missing(command)
|
|
return not o.cmd_present(command)
|
|
end
|
|
|
|
local function command_from(value, description)
|
|
if type(value) ~= "table" then
|
|
return value
|
|
end
|
|
|
|
if value.omarchy then
|
|
return "omarchy-launch-" .. value.omarchy
|
|
elseif value.focus and value.launch then
|
|
return o.launch_sole(value.focus, value.launch)
|
|
elseif value.launch then
|
|
return o.launch(value.launch)
|
|
elseif value.webapp then
|
|
if value.focus then
|
|
return o.launch_webapp_sole(description, value.webapp)
|
|
else
|
|
return o.launch_webapp(value.webapp)
|
|
end
|
|
elseif value.tui then
|
|
if value.focus then
|
|
return "omarchy-launch-or-focus-tui " .. shell_quote(value.tui)
|
|
else
|
|
return "omarchy-launch-tui " .. shell_quote(value.tui)
|
|
end
|
|
end
|
|
|
|
return value
|
|
end
|
|
|
|
function o.bind(keys, description, dispatcher, options)
|
|
local opts = options or {}
|
|
|
|
if description then
|
|
opts.description = description
|
|
end
|
|
|
|
dispatcher = command_from(dispatcher, description)
|
|
|
|
if type(dispatcher) == "string" then
|
|
dispatcher = hl.dsp.exec_cmd(dispatcher)
|
|
end
|
|
|
|
hl.bind(keys, dispatcher, opts)
|
|
end
|
|
|
|
function o.launch(command)
|
|
return "uwsm-app -- " .. command
|
|
end
|
|
|
|
function o.exec_on_start(command)
|
|
hl.on("hyprland.start", function()
|
|
hl.exec_cmd(command)
|
|
end)
|
|
end
|
|
|
|
function o.launch_on_start(command)
|
|
o.exec_on_start(o.launch(command))
|
|
end
|
|
|
|
function o.launch_webapp(url)
|
|
return "omarchy-launch-webapp " .. shell_quote(url)
|
|
end
|
|
|
|
function o.launch_webapp_sole(name, url)
|
|
return "omarchy-launch-or-focus-webapp " .. shell_quote(name) .. " " .. shell_quote(url)
|
|
end
|
|
|
|
function o.launch_sole(match, command)
|
|
return "omarchy-launch-or-focus " .. shell_quote(match) .. " " .. shell_quote(o.launch(command))
|
|
end
|
|
|
|
function o.bind_toggle(keys, description, toggle, options)
|
|
o.bind(keys, description, "omarchy-toggle-" .. toggle, options)
|
|
end
|
|
|
|
function o.notify(message)
|
|
return "notify-send -u low " .. shell_quote(message)
|
|
end
|
|
|
|
function o.window(match, rules)
|
|
rules.match = rules.match or {}
|
|
|
|
if type(match) == "string" then
|
|
rules.match.class = match
|
|
else
|
|
for key, value in pairs(match) do
|
|
rules.match[key] = value
|
|
end
|
|
end
|
|
|
|
hl.window_rule(rules)
|
|
end
|