feat: size: prefix, external auto-detection, auto-disable stale monitors

- size:WxH and size:WxH@R resolution for config names
- auto-detection of external monitors when external list is empty (any non-internal display)
- ensureCleanLayout: explicitly disable connected monitors not in target layout
- update docs (README, example.yaml) for all three features
This commit is contained in:
Maksim Totmin
2026-06-24 19:51:18 +07:00
parent ac2bb77113
commit 3fdccadd3c
5 changed files with 223 additions and 54 deletions
+19 -5
View File
@@ -57,6 +57,7 @@ Plugs into your dock — external monitors turn on, built-in turns off. Unplug
| 5 | **Graceful shutdown** — optionally restores portable layout on SIGTERM |
| 6 | **Socket reconnect** — exponential backoff if compositor socket drops |
| 7 | **Atomic config writes (Hyprland)** — temp file + rename prevents config corruption |
| 8 | **Auto-disable stale monitors** — monitors connected but absent from the target layout are explicitly disabled (prevents external displays from staying on after switching to portable mode) |
---
@@ -142,13 +143,17 @@ restore_on_exit: true
# External monitors that trigger docked mode.
# Plain name: matches connector (DP-1, HDMI-A-1).
# desc: prefix: matches by monitor description (survives port rename).
external:
# Optional — if omitted or empty, the daemon auto-detects external monitors:
# any display whose connector is not eDP-/LVDS-/DSI- is treated as external.
external: # optional
- desc:Dell Inc. DELL U2723QE
- DP-9
- DP-10
# Monitor layouts for each mode.
# "portable" and "docked" are required.
# Monitors not listed in a mode are automatically disabled (prevents
# external displays from staying on when switching to portable mode).
modes:
portable:
monitors:
@@ -172,6 +177,11 @@ modes:
scale: 1.0
- name: eDP-1
enabled: false # turn off laptop screen when docked
- name: size:1920x1080@60 # resolve by resolution + refresh rate
enabled: true
mode: preferred
position: auto
scale: 1.0
# Shell commands run after a layout change.
# Commands run concurrently, failures are logged but never crash the daemon.
@@ -185,17 +195,19 @@ hooks:
### Monitor matching
Two match modes, supported in both the `external` list and the `modes` section:
Three match modes for the `modes` section (the `external` list supports plain names and `desc:`):
| Syntax | Matches | Use case |
|---|---|---|
| `DP-1` | Exact connector name | Simple setups, built-in displays |
| `desc:Dell U2723QE` | Substring in monitor description | Survives port rename across different docks |
| `desc:Dell U2723QE` | Substring in monitor description or serial | Survives port rename across different docks |
| `size:2560x1440` | Exact pixel dimensions | Two identical monitors with same resolution |
| `size:2560x1440@165` | Dimensions + refresh rate | Disambiguate identical models |
Sway description format: `make model serial_widthxheight` (with serial omitted if `Unknown`).
Run `hyprctl monitors all` (Hyprland) or `swaymsg -t get_outputs` (Sway) to see your monitor names and descriptions.
**desc: in modes** — when a monitor name in `modes` uses the `desc:` prefix, the daemon resolves it to the actual connector name at runtime. Ambiguous matches (a desc matching multiple monitors) cause an error.
**desc: and size: in modes** — when a monitor name in `modes` uses `desc:` or `size:`, the daemon resolves it to the actual connector name at runtime. Ambiguous matches (a prefix matching multiple monitors with identical resolution) cause an error. For `size:`, add `@R` (refresh rate) to disambiguate monitors with the same resolution. Unresolvable names also cause an error.
### Backend-specific configuration
@@ -337,7 +349,7 @@ Check the hook command works from a terminal first. Hooks run via `sh -c`, so sh
### Monitor names changed after reboot
Use `desc:` prefix matching instead of connector names. This survives port renames across different docks and reboots.
Use `desc:` or `size:` prefix matching instead of connector names. Both survive port renames across different docks and reboots.
**Hyprland:** `hyprctl monitors all` to see descriptions.
**Sway:** `swaymsg -t get_outputs` to see names, make/model, serial, and native resolution.
@@ -351,6 +363,8 @@ modes:
monitors:
- name: desc:Dell Inc. DELL U2723QE # also works here
enabled: true
- name: size:2560x1440@165 # match by dimensions + refresh
enabled: true
```
---