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:
17
Model.js
17
Model.js
@@ -69,7 +69,7 @@ function serializeConfig(originalText, patch) {
|
||||
// hypr-rdp headless output's workspace so Hyprland's normal
|
||||
// auto-assignment never reuses it; deleting the file removes the pin.
|
||||
function isolationLuaContent(workspaceId, outputName) {
|
||||
return "-- Managed by the jandieman.hypr-rdp bar widget's isolation\n" +
|
||||
return "-- Managed by the dotjuice.hypr-rdp bar widget's isolation\n" +
|
||||
"-- toggle. Do not hand-edit -- this file is overwritten or removed\n" +
|
||||
"-- automatically when the toggle is flipped.\n" +
|
||||
"--\n" +
|
||||
@@ -111,6 +111,18 @@ function parseActiveWorkspaceId(raw) {
|
||||
}
|
||||
}
|
||||
|
||||
// Isolation intent is on unless the state file explicitly says otherwise —
|
||||
// covers a fresh install (no file yet, handled by the caller) and a
|
||||
// corrupt/unexpected file the same way: default to the safer "isolated" side.
|
||||
function parseIsolationState(raw) {
|
||||
try {
|
||||
var obj = JSON.parse(String(raw || ""))
|
||||
return { enabled: obj.enabled !== false }
|
||||
} catch (e) {
|
||||
return { enabled: true }
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof module !== "undefined") {
|
||||
module.exports = {
|
||||
escapeTomlString: escapeTomlString,
|
||||
@@ -119,6 +131,7 @@ if (typeof module !== "undefined") {
|
||||
serializeConfig: serializeConfig,
|
||||
isolationLuaContent: isolationLuaContent,
|
||||
parseClients: parseClients,
|
||||
parseActiveWorkspaceId: parseActiveWorkspaceId
|
||||
parseActiveWorkspaceId: parseActiveWorkspaceId,
|
||||
parseIsolationState: parseIsolationState
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user