Sway: Closing the laptop lid does not disable the output

Created on 16 Nov 2018  路  16Comments  路  Source: swaywm/sway

Steps to reproduce:

  1. connect a monitor to your laptop
  2. start sway
  3. close your laptop lid.

-> screen is turned off but sway does not disable the output

sway version 1.0-beta.1-108-gb90af335 (Oct 30 2018, branch 'master')
log: https://gist.github.com/philipflohr/91246ffb7f5f2610abd210fe543ed97f

enhancement

Most helpful comment

@RedSoxFan just FYI I copy and pasted this but there's a typo - perhaps rectify it?

set $laptop <laptop-output-name-or-id>
bindswitch --locked lid:off output $laptop disable
bindswitch --locked lid:on output $laptop enable

(switch vs swtich).

I can confirm this works, however for some reason I had to have the opposite and 'wrong' configuration to get this working as expected:

set $laptop eDP-1
bindswitch lid:on output $laptop disable
bindswitch lid:off output $laptop enable

I'll have a look at my system events first to figure out if this is just my laptop having weird events, and secondly I'll put a PR in to document this feature.

All 16 comments

I'm not sure how we should handle this (and how we _can_ handle this).

I think https://github.com/swaywm/wlroots/pull/1377 is a step towards this.

Indeed. I didn't realize laptop lids were exposed as libinput switches.

If by "_screen is turned off but sway does not disable the output_" you mean that upon opening the lid and the screen coming back on, swaylock does _not_ get called and prompt for the password, I also experience this issue.

No, this issue is different, although related.

See #3198 for related issue.

As soon as #3340 is working and merged, you should be able to bind the lid switch event to toggling the associated output.

Since #3340 is merged, this can be accomplished with:

set $laptop <laptop-output-name-or-id>
bindswitch lid:on output $laptop disable
bindswtich lid:off output $laptop enable

Or if you want it to also trigger while locked, just add the --locked flag to bindswitch:

set $laptop <laptop-output-name-or-id>
bindswtich --locked lid:on output $laptop disable
bindswtich --locked lid:off output $laptop enable

@RedSoxFan just FYI I copy and pasted this but there's a typo - perhaps rectify it?

set $laptop <laptop-output-name-or-id>
bindswitch --locked lid:off output $laptop disable
bindswitch --locked lid:on output $laptop enable

(switch vs swtich).

I can confirm this works, however for some reason I had to have the opposite and 'wrong' configuration to get this working as expected:

set $laptop eDP-1
bindswitch lid:on output $laptop disable
bindswitch lid:off output $laptop enable

I'll have a look at my system events first to figure out if this is just my laptop having weird events, and secondly I'll put a PR in to document this feature.

It wasn't working for me either, so I just flipped it as you did. It worked so I didn't really think much more about the semantics. But yes, it does seem backwards.

On June 6, 2019 10:27:16 PM UTC, Tristan Watson notifications@github.com wrote:

@RedSoxFan just FYI I copy and pasted this but there's a typo - perhaps
rectify it?

set $laptop <laptop-output-name-or-id>
bindswitch --locked lid:off output $laptop disable
bindswitch --locked lid:on output $laptop enable

(switch vs swtich).

I can confirm this works, however for some reason I had to have the
opposite and 'wrong' configuration to get this working as expected:

set $laptop eDP-1
bindswitch lid:on output $laptop disable
bindswitch lid:off output $laptop enable

I'll have a look at my system events first to figure out if this is
just my laptop having weird events, and secondly I'll put a PR in to
document this feature.

--
Best regards,
Matt Snider

FYI I copy and pasted this but there's a typo - perhaps rectify it?

Oops. Sorry, yes that was indeed a typo and I had it backwards. I edited my previous comment.

secondly I'll put a PR in to document this

In man 5 sway, it does say switches are on when the device lid is shut under bindswitch so it is documented correctly

From man 5 sway:

These switches are on when the device lid is shut and when tablet mode is active respectively.

From libinput (upstream Wayland input library) libinput.h:

* The laptop lid was closed when the switch state is @ref
* LIBINPUT_SWITCH_STATE_ON, or was opened when it is @ref
* LIBINPUT_SWITCH_STATE_OFF.

Ultimately I think it's an evdev curio:

From https://www.kernel.org/doc/Documentation/input/event-codes.txt:

EV_SW:
----------
EV_SW events describe stateful binary switches. For example, the SW_LID code is
used to denote when a laptop lid is closed.

So it's possibly counter-intuitive but correct as @RedSoxFan suggests.

Makes more sense this way! Thanks a lot fo the input guys and for rectifying it. By documentation, I meant on the wiki side of things rather than man as I'm sure there's more users that are interested in the clamshell mode. I'll put a PR in later for this and see what happens.

I've documented this behaviour within the wiki as promised: https://github.com/swaywm/sway/wiki

Maybe there could be closed and open aliases for on and off?

Maybe there could be closed and open aliases for on and off?

Not a fan of this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

WhyNotHugo picture WhyNotHugo  路  3Comments

marcoms picture marcoms  路  3Comments

cauebs picture cauebs  路  3Comments

dnkl picture dnkl  路  4Comments

mcmfb picture mcmfb  路  3Comments