Skip to content

Conversation

@markstos
Copy link
Contributor

Output toggling is part of the Sway IPC.

In a multi-monitor setup, it can be useful to bind a key
to toggle a secondary monitor and off to temporary increase focus or save energy.

Context about the change

Unlike the on and off commands, the toggle option has to first read the state, so a bit of refactoring was needed. This required for some code to be re-indented, which makes the diff look larger than it is.

QA Log

  • Tested that docs appear in CLI
  • Tested manually toggling a monitor on and off.

@markstos markstos force-pushed the add-output-toggle-to-ipc branch from 14b6650 to 719fa5f Compare November 30, 2025 00:05
@averageluadev
Copy link

would this allow me to bind a key to turn off my laptop screen ? cant seem to find another way to do this as lid switch does not work

@markstos
Copy link
Contributor Author

@averageluadev I believe you can already bind a key to turn off your laptop screen and bind a second key to turn it back on. This patch would allow the same keybind to toggle it:

Mod+Shift+m { spawn-sh "niri msg output 'eDP-1' toggle" }

One IPC design question I have though is why does niri msg output exist at all, because all it contains are actions, which is inconsistent with putting all the other actions under niri msg action?

I can guess the reason why is that perhaps it was expected that people would not want to bind keys to change their outputs, as that's normally down by something like Kanshi at startup and not changed at run time.

That's generally true, I think perhaps except perhaps for a toggling a display on and off.

It's true that even if this patch were accepted, it seems like a binding a key to toggle the display would still require a spawn call to niri msg because the function is not considered an "action" under niri msg action.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants