Default monitor isolation on and make it self-healing

Fresh installs previously started with isolation off until someone
noticed and flipped the switch by hand, since the toggle read raw
file-existence with no persisted intent behind it. Now a small state
file (colocated in Omarchy's toggles dir, which is guaranteed to exist,
avoiding an mkdir-p race a plugin-private directory would hit) records
the user's actual choice, defaulting to isolated-on the first time the
widget ever loads. Every poll reconciles the toggle-flag file against
that intent and against the current isolated-workspace setting, so
external drift (or a workspace-number change) gets corrected within
one poll interval instead of silently sticking.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MLfSWFEMyY85ZDWEYicdaF
This commit is contained in:
2026-09-08 16:19:00 +01:00
parent 0819c2e3ba
commit a90363eeee
3 changed files with 107 additions and 27 deletions

View File

@@ -48,17 +48,21 @@ omarchy pkg drop hypr-rdp-git # or hypr-rdp
- **Service**: start/stop via a `systemd --user` unit
(`~/.config/systemd/user/hypr-rdp.service`). Created automatically on
first start if it doesn't already exist; never overwritten after that.
- **Monitor isolation**: toggling this creates or removes
`~/.local/state/omarchy/toggles/hypr/hypr-rdp-isolation.lua` (Omarchy's
standard toggle-flag convention — the same one `omarchy toggle
window-gaps` uses), which pins an isolated workspace (default 11) to the
`hypr-rdp` headless output via `hl.workspace_rule`, then runs `hyprctl
reload` + `hyprctl configerrors`. On: Hyprland's normal workspace
auto-assignment never reuses that workspace, so starting an RDP session
can't silently steal one of your visible workspaces. Off: the headless
output behaves like a normal display. Workspace-to-monitor binding is
config-file-only in Hyprland (no live `hyprctl keyword` for it), so a
flip takes effect the next time hypr-rdp (re)starts, not mid-session.
- **Monitor isolation**: **on by default**, no setup needed. It works by
creating `~/.local/state/omarchy/toggles/hypr/hypr-rdp-isolation.lua`
(Omarchy's standard toggle-flag convention — the same one `omarchy
toggle window-gaps` uses), which pins an isolated workspace (default 11)
to the `hypr-rdp` headless output via `hl.workspace_rule`, then runs
`hyprctl reload` + `hyprctl configerrors`. On: Hyprland's normal
workspace auto-assignment never reuses that workspace, so starting an
RDP session can't silently steal one of your visible workspaces. Off:
the headless output behaves like a normal display. Workspace-to-monitor
binding is config-file-only in Hyprland (no live `hyprctl keyword` for
it), so a flip takes effect the next time hypr-rdp (re)starts, not
mid-session. Your choice is remembered in a small state file next to the
toggle flag, and every poll cycle re-applies it — so if the toggle file
is ever deleted or edited by something else, the widget puts it back
within a few seconds rather than silently losing the setting.
**If you already have your own `hl.workspace_rule` pinning a workspace to
the `hypr-rdp` output in `monitors.lua` or elsewhere, remove it first** —
a leftover static rule will keep isolation on regardless of what the