mirror of
https://github.com/AlexMacocian/quick-visor.git
synced 2026-07-15 15:09:32 +00:00
Dpms on when enabling a screen
This commit is contained in:
@@ -62,3 +62,20 @@ comments and reloads while quick-visor is running.
|
||||
"radius": 12
|
||||
}
|
||||
```
|
||||
|
||||
## Persisting the layout
|
||||
|
||||
Applying a layout runs `hyprctl keyword monitor` for each display, which takes
|
||||
effect immediately but is lost when Hyprland restarts.
|
||||
|
||||
To make changes survive a restart, quick-visor also rewrites
|
||||
`~/.config/hypr/monitors.conf` **only if that file already exists** (the same
|
||||
file generated by tools like nwg-displays and typically sourced from
|
||||
`hyprland.conf`). If the file is absent, quick-visor leaves it alone and applies
|
||||
the layout at runtime only. Add the following to your `hyprland.conf` to enable
|
||||
persistence:
|
||||
|
||||
```conf
|
||||
source = ~/.config/hypr/monitors.conf
|
||||
```
|
||||
|
||||
|
||||
+40
-6
@@ -320,26 +320,60 @@ QtObject {
|
||||
return "'" + String(value).replace(/'/g, "'\\''") + "'";
|
||||
}
|
||||
|
||||
readonly property string monitorConfPath: "${XDG_CONFIG_HOME:-$HOME/.config}/hypr/monitors.conf"
|
||||
|
||||
function monitorSpec(m) {
|
||||
if (monitorEnabled(m)) {
|
||||
return m.name + "," + modeForHyprland(monitorMode(m)) + ","
|
||||
+ monitorX(m) + "x" + monitorY(m) + "," + monitorScale(m);
|
||||
}
|
||||
return m.name + ",disable";
|
||||
}
|
||||
|
||||
function pad2(value) {
|
||||
return value < 10 ? "0" + value : String(value);
|
||||
}
|
||||
|
||||
function monitorConfContent() {
|
||||
const now = new Date();
|
||||
const stamp = now.getFullYear() + "-" + pad2(now.getMonth() + 1) + "-" + pad2(now.getDate())
|
||||
+ " at " + pad2(now.getHours()) + ":" + pad2(now.getMinutes()) + ":" + pad2(now.getSeconds());
|
||||
let body = "# Generated by quick-visor on " + stamp + ". Do not edit manually.\n\n";
|
||||
for (let i = 0; i < monitors.length; i++) {
|
||||
body += "monitor=" + monitorSpec(monitors[i]) + "\n";
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
function applyLayout() {
|
||||
if (!dirty || monitors.length === 0) return;
|
||||
|
||||
const enableCommands = [];
|
||||
const disableCommands = [];
|
||||
const dpmsCommands = [];
|
||||
for (let i = 0; i < monitors.length; i++) {
|
||||
const m = monitors[i];
|
||||
const command = "hyprctl keyword monitor " + shQuote(monitorSpec(m));
|
||||
if (monitorEnabled(m)) {
|
||||
const spec = m.name + "," + modeForHyprland(monitorMode(m)) + ","
|
||||
+ monitorX(m) + "x" + monitorY(m) + "," + monitorScale(m);
|
||||
enableCommands.push("hyprctl keyword monitor " + shQuote(spec));
|
||||
enableCommands.push(command);
|
||||
// Enabling a monitor that was previously off leaves DPMS off
|
||||
// (blank/grey panel, invisible cursor), so force it on.
|
||||
dpmsCommands.push("hyprctl dispatch dpms on " + shQuote(m.name));
|
||||
} else {
|
||||
disableCommands.push("hyprctl keyword monitor " + shQuote(m.name + ",disable"));
|
||||
disableCommands.push(command);
|
||||
}
|
||||
}
|
||||
|
||||
const commands = enableCommands.concat(disableCommands);
|
||||
const commands = enableCommands.concat(disableCommands).concat(dpmsCommands);
|
||||
if (commands.length === 0) return;
|
||||
|
||||
// Persist to the Hyprland-sourced monitors.conf, but only if it already exists.
|
||||
const persist = "CONF=\"" + monitorConfPath + "\"; "
|
||||
+ "if [ -f \"$CONF\" ]; then printf '%s' " + shQuote(monitorConfContent()) + " > \"$CONF\"; fi";
|
||||
const script = commands.join(" && ") + " && { " + persist + "; }";
|
||||
|
||||
status = "Applying layout...";
|
||||
applyProc.command = ["sh", "-c", commands.join(" && ")];
|
||||
applyProc.command = ["sh", "-c", script];
|
||||
applyProc.running = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user