Lua config writer replaces entire hyprland.lua instead of only adding the managed include
Description
The README states that for Lua configs, HyprMon should only add the managed
include block to hyprland.lua if it isn't already present, leaving the rest
of the file untouched:
HyprMon writes monitor rules to
~/.config/hypr/hyprmon.luaand adds this managed include tohyprland.luaif it is not already present
In practice, on a normal Omarchy Hyprland setup, hyprland.lua was replaced
in its entirety with just the two-line include block, wiping out the
bootstrap/defaults/bindings/monitors/input/looknfeel/autostart requires. This
broke the whole session (no bar/shell autostart, no custom keybindings, etc.)
on next login.
Version
HyprMon v0.0.17 (commit: 3131caf, built: 2026-05-18T21:54:22Z, go: go1.26.3) (hyprmon-bin 0.0.17-1 on Arch/Omarchy)
Evidence
Timestamped backups (HyprMon creates a .bak.<timestamp> before each write)
show the corruption happening between two consecutive saves ~40 seconds apart:
hyprland.lua.bak.<ts1>(08:26:39) — 1107 bytes, full config, include already present and correctly left alonehyprland.lua.bak.<ts2>(08:26:44) — 1107 bytes, same, unchangedhyprland.lua.bak.<ts3>(08:27:19) — 63 bytes, only the include blockhyprland.lua.bak.<ts4>(08:27:33) — 63 bytes, corruption persisted
So two prior saves correctly detected the include was present and left the
file alone, then a subsequent save (likely triggered by pressing S, or by
a profile-apply / lid-switch trigger) fully rewrote the file down to just the
include, and the corruption was then treated as the new correct state on the
next save.
Expected
HyprMon should only insert/update the managed include block, never replace
or truncate the rest of hyprland.lua.
Actual
The entire file was replaced with:
-- hyprmon: managed monitor profile include
require("hyprmon")
Impact
Silent, non-obvious data loss — the file has no error markers, so the user's window manager appeared to boot with "nothing configured" and no indication why.