config/lua: allow re-enabling monitors#14447
Conversation
|
Hello and thank you for making a PR to Hyprland! Please check the PR Guidelines and make sure your PR follows them. 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. |
|
Doesn't seem to work, though? Furthermore, I don't think reloading your config should always re-enable every single connected monitor (?) |
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
This is not what this does, to my knowledge. Reloading the config resets all configured monitors to their configured state. If a monitor specifies |
|
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 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})
|
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 :( |
|
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:
I assumed the bind was also borked because I was trying to use it as a fallback (to turn back eDP-1 after Adding a reload in either of the two works |
|
thanks now I can repro. I'll get it fixd |
Describe your PR, what does it fix/add?
This PR configures the Lua configuration setting
hl.monitor.disabled = falseto 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
hyprlangconfiguration 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.