Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions default/hypr/qconsole.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ local CONSOLE = "special:qconsole"
-- from while misc.initial_workspace_tracking is on, and looknfeel turns it off.
-- Omarchy ships without a default agent, and omarchy-agent exits without
-- opening anything when none is set, so until one is picked this just opens an
-- empty console.
local seed = "[workspace " .. CONSOLE .. " silent] omarchy-agent"
-- empty console. A console created by moving a window onto it is not empty, and
-- is left alone.
hl.on("workspace.created", function(ws)
if ws and ws.name == CONSOLE and ws.is_empty then
hl.exec_cmd("omarchy-agent", { workspace = CONSOLE .. " silent" })
end
end)

-- Dimming only applies while a special workspace is open, so the console gets
-- its separation from the workspace underneath without costing anything the
Expand Down Expand Up @@ -56,8 +61,6 @@ local function cover(side, bottom)
-- open, and the active border reads as a stray frame around a panel that
-- is already set apart by the dimming behind it.
no_border = true,

on_created_empty = seed,
})

return true
Expand Down
19 changes: 13 additions & 6 deletions test/shell.d/hyprland-qconsole-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require_command lua
# base-test.sh does not set -e, so the assertions have to fail the file
# themselves rather than leaving the pass below to run regardless.
OMARCHY_PATH="$ROOT" lua - <<'LUA' || fail "the console is a centered panel until a second app joins it"
local rules, handlers = {}, {}
local rules, handlers, spawned = {}, {}, {}
local monitor = nil
local workspace = nil

Expand All @@ -31,6 +31,7 @@ hl = {
return list
end,
exec_scheduled_prop_refresh_immediately = function() end,
exec_cmd = function(cmd, rules) table.insert(spawned, { cmd = cmd, rules = rules }) end,
}

dofile(os.getenv("OMARCHY_PATH") .. "/default/hypr/bootstrap.lua")
Expand All @@ -46,13 +47,20 @@ local function gaps()
end

-- Config loads before the outputs are up, so the first pass has no monitor to
-- read. It still has to leave a rule behind, or the console would open unseeded.
-- read. It still has to leave a rule behind, or the console would open unplaced.
assert(#rules > 0, "console is ruled even before a monitor can be read")
assert(current().on_created_empty:find("omarchy%-agent"), "console is seeded with the default agent")
assert(current().on_created_empty:find("^%[workspace special:qconsole silent%]"),
"the seed is pinned to the console rather than trusting the spawn to inherit it")
assert(current().workspace == "special:qconsole")

-- Only an empty console is seeded: one created by moving a window onto it
-- already has its app, and other workspaces are none of its business.
handlers["workspace.created"]({ name = "special:qconsole", is_empty = false })
handlers["workspace.created"]({ name = "special:scratchpad", is_empty = true })
assert(#spawned == 0, "only an empty console is seeded")
handlers["workspace.created"]({ name = "special:qconsole", is_empty = true })
assert(#spawned == 1 and spawned[1].cmd == "omarchy-agent", "console is seeded with the default agent")
assert(spawned[1].rules.workspace == "special:qconsole silent",
"the seed is pinned to the console rather than trusting the spawn to inherit it")

local function rescale(height, scale, bar)
monitor = { width = 1920, height = height, scale = scale, transform = 0, reserved = { top = bar, bottom = 0, left = 0, right = 0 } }
handlers["monitor.layout_changed"]()
Expand All @@ -71,7 +79,6 @@ assert(rescale(1440, 1, 0) == 720, "a monitor with nothing reserved")
local final = current()
assert(final.gaps_out.top == 0, "the console stays flush with the top, the way a drop-down arrives")
assert(final.gaps_out.left == final.gaps_out.right, "the panel is centered")
assert(final.on_created_empty:find("omarchy%-agent"), "refitting keeps the console seeded")
assert(final.no_border == true, "the console drops the active window border")

-- A monitor that cannot be read must not wipe the last good rule.
Expand Down