hyprmon icon indicating copy to clipboard operation
hyprmon copied to clipboard

Lua config: Apply with Transform "Normal" leaves a rotated monitor rotated

Open Aklenor opened this issue 3 weeks ago • 0 comments

Describe the bug

With a Lua Hyprland config, after a monitor has been rotated, setting Transform back to "Normal" in the advanced settings (c) and pressing Apply (a) leaves the monitor rotated. Saving (s) does un-rotate it, because save reloads the config.

Cause

generateLuaMonitorRule adds transform only when it is non-zero:

if m.Transform > 0 {
    fields = append(fields, fmt.Sprintf("transform = %d", m.Transform))
}

Apply on a Lua config sends that rule with hyprctl eval (applyMonitorLua). For "Normal" the rule has no transform field, and Hyprland keeps the monitor's current transform for a field the rule leaves out. A config reload starts from defaults, which is why save works.

To reproduce (Hyprland side, without HyprMon)

mon=HDMI-A-1   # any secondary output
rule="hl.monitor({ output = \"$mon\", mode = \"preferred\", position = \"auto\", scale = 1"
tf() { hyprctl -j monitors | jq ".[] | select(.name==\"$mon\").transform"; }

hyprctl eval "$rule, transform = 3 })"; tf   # 3: rotated
hyprctl eval "$rule })"; tf                   # 3: what Apply sends for "Normal"; still rotated
hyprctl eval "$rule, transform = 0 })"; tf   # 0: back to landscape

To reproduce (HyprMon)

  1. Lua config (hyprland.lua with the require("hyprmon") include).
  2. Select a monitor, c, set Transform to 270°, Enter, a: the monitor rotates.
  3. c, set Transform to Normal, Enter, a: the monitor stays rotated.
  4. Quit and start HyprMon again: it reads transform 3 from Hyprland, so a later s saves transform = 3 back into hyprmon.lua.

Expected

Apply with "Normal" returns the monitor to landscape.

Suggested fix

Always emit transform in generateLuaMonitorRule for enabled monitors. 0 is Hyprland's default for transform, so writing it is always correct (unlike vrr, where leaving it out means "use the global misc:vrr"). The hyprlang paths have the same > 0 guard; I have not tested whether hyprctl keyword monitor keeps the old transform there.

Environment

  • Hyprland 0.56.2, Lua config
  • HyprMon built from source; code checked against master at 48e118c (2026-11-02), and the installed binary contains applyMonitorLua

Aklenor avatar Nov 09 '26 12:11 Aklenor