Skip to content

config/lua: allow re-enabling monitors#14447

Merged
vaxerski merged 1 commit into
hyprwm:mainfrom
bizmythy:lua-monitor-disable-handling
May 12, 2026
Merged

config/lua: allow re-enabling monitors#14447
vaxerski merged 1 commit into
hyprwm:mainfrom
bizmythy:lua-monitor-disable-handling

Conversation

@bizmythy

@bizmythy bizmythy commented May 12, 2026

Copy link
Copy Markdown
Contributor

Describe your PR, what does it fix/add?

This PR configures the Lua configuration setting hl.monitor.disabled = false to enable the monitor.

This allows Lua scripts to enable monitors that were previously disabled. Without this change, the only way I could find to re-enable a disabled monitor was to reload the entire configuration.

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

This is not how the original hyprlang configuration worked, so I totally understand if this is not a change that we want to make. However, I think the Lua configuration needs to provide some way to allow a user script to re-enable disabled monitors. Otherwise, I'm not sure how one would write a keybind that toggled a monitor on/off for example.

Is it ready for merging, or does it need work?

Ready for merging, very small change.

@github-actions

Copy link
Copy Markdown

Hello and thank you for making a PR to Hyprland!

Please check the PR Guidelines and make sure your PR follows them.
It will make the entire review process faster. :)

If your code can be tested, please always add tests. See more here.

beep boop, I'm just a bot. A real human will review your PR soon.

@vaxerski vaxerski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@vaxerski
vaxerski merged commit b76a9e0 into hyprwm:main May 12, 2026
9 of 10 checks passed
Aqa-Ib pushed a commit to Aqa-Ib/Hyprland that referenced this pull request May 13, 2026
@alba4k

alba4k commented May 13, 2026

Copy link
Copy Markdown
Contributor

Doesn't seem to work, though?

Furthermore, I don't think reloading your config should always re-enable every single connected monitor (?)

@bizmythy

bizmythy commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

Doesn't seem to work, though?

It does seem to be working for my configuration. I'm curious what isn't working for you.

I got the AI to write a small test script to show the state switching in a basic Lua config: https://gist.github.com/bizmythy/94afea4178eaf2f181d738349ea240fc
Note that the wayland/debugging live session doesn't properly visually show the monitors being disabled, but the log output inspecting hyprctl shows they are disabled/enabled. On real monitors in my config, the actual monitor fully disconnects/reconnects properly.

Furthermore, I don't think reloading your config should always re-enable every single connected monitor (?)

This is not what this does, to my knowledge. Reloading the config resets all configured monitors to their configured state. If a monitor specifies disabled = true, it will be disabled (was the case before). Now, if a monitor specifies disabled = false, it will be enabled.
This is important for things like toggling monitor states with a Lua function (run from a keybind or other event).
Before this change, once the config sets disabled = true for a monitor, there is no way to re-enable it without a full configuration reload.

@bizmythy
bizmythy deleted the lua-monitor-disable-handling branch May 14, 2026 03:58
@alba4k

alba4k commented May 14, 2026

Copy link
Copy Markdown
Contributor

I tested it again. While this works when just trying to re-enabled with hyprctl, things like:

hl.on("monitor.removed", function()
    local layout = DetectScreenLayout()

    if layout == nil then
        hl.monitor({output = "eDP-1", mode = "preferred", position = "auto", disabled = false})
        hl.exec_cmd("hyprctl reload")
    end
end)

fail to re-enable my monitor without the hyprctl reload, same with

hl.bind("switch:off:Lid Switch", function()
        local layout = DetectScreenLayout()
        if layout == nil then -- not a known layout where eDP-1 should stay off
            hl.monitor({output = "eDP-1", mode = "preferred", position = "auto", disabled = false})
            hl.exec_cmd("hyprctl reload")
        end
end, {locked = true})

This is not what this does, to my knowledge
I know it's not related to this mr, was just checking. What I'm saying is that currently, even if I specify disabled = true, all monitors get reset to disabled = false whenever the config is reloaded.

@vaxerski

Copy link
Copy Markdown
Member

@alba4k

local enabledMon = true

hl.bind("ALT + O", function()
    if enabledMon == true then
        hl.monitor({ output = "WAYLAND-2", disabled = true })
        enabledMon = false
    else
        hl.monitor({ output = "WAYLAND-2", mode = "preferred", position = "auto", scale = 1, disabled = false})
        enabledMon = true
    end
end)

works on my end. I can't repro any problems :(

@alba4k

alba4k commented May 14, 2026

Copy link
Copy Markdown
Contributor

You're right, that works. The lid switch bind works too, actually.

However, they both stop working if there is no active monitor, for example in this scenario:

  • eDP-1 disabled, DP-5 and DP-7 enabled
  • disconnect the dock with DP-5 and DP-7
  • hl.on("monitor.removed", ...) doesn't turn eDP-1 back on. That only happens when adding hl.exec_cmd("hyprctl reload") to the lambda

I assumed the bind was also borked because I was trying to use it as a fallback (to turn back eDP-1 after hl.on(...) failed) and it was also failing.

Adding a reload in either of the two works

@vaxerski

Copy link
Copy Markdown
Member

thanks now I can repro. I'll get it fixd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants