niri icon indicating copy to clipboard operation
niri copied to clipboard

Main laptop monitor disabled after closing lid

Open ViddeM opened this issue 11 months ago • 15 comments

When I close the lid of my laptop and then open it up again, niri won't start up. After switching to another tty and back I can (after a while) get back to the login screen (GDM3) but when I log in the main monitor is just blank.

Even more strange, if I plug in (or re-plug in case I already had one plugged in) an external monitor that one usually starts working and if I then remove the cable, my main screen starts working again but if I once again plugin the external monitor the laptop screen gets disabled. (I basically get an xor between my external monitor and my laptop screen).

When running niri msg outputs it lists "Disabled" under my main laptop monitor output when the external monitor is plugged in.

I considered adding my notes to issue #837 as it sounds similar but as it is not quite the same I decided to create my own.

System Information

  • niri version: 0.1.10-1 (self-compiled from commit 75c79116a7e40cbc0e110ce0cdd500e896458679, tag v0.1.10.1)
  • Distro: Ubuntu 24.04.1 LTS
  • GPU: NVIDIA RTX A2000 Mobile
  • CPU: 11th Gen Intel i7-11850H (16) @ 4.800GHz

(Laptop: HP ZBook Fury 15.6 inch G8 Mobile Workstation PC)

Sidenote: Thanks for building this otherwise amazing piece of software 🥇

ViddeM avatar Jan 17 '25 09:01 ViddeM

Hmm, could you post journalctl --user-unit=niri -b when reproducing the issue? Let's see if there's anything weird regarding libinput lid events.

Also try if keep-laptop-panel-on-when-lid-is-closed fixes it for you.

YaLTeR avatar Jan 17 '25 09:01 YaLTeR

Was just about to add that 😅

It's a work laptop so I had to censor my username and hostname but here is the log. It seems to spam "device is inactive" after closing/reopening the lid.

niri_error_log.txt

I'll try that one! :)

ViddeM avatar Jan 17 '25 09:01 ViddeM

Huh, this is strange. Could you by chance try cosmic-comp or anvil to see if they suspend/unsuspend properly?

YaLTeR avatar Jan 17 '25 09:01 YaLTeR

I added the keep-laptop-panel... option to my config and my main monitor instantly turned on. I tried closing the lid and opened it up again and after a while (say 1-2 minutes) it opened up a very borked version of my swaylock config. Things seem to be working but my swaybg seems to have given up and several of my windows look a bit weird.

ViddeM avatar Jan 17 '25 09:01 ViddeM

Huh, this is strange. Could you by chance try cosmic-comp or anvil to see if they suspend/unsuspend properly?

Never heard of either 😅 I'm guessing it's this one? https://github.com/pop-os/cosmic-comp

ViddeM avatar Jan 17 '25 09:01 ViddeM

Yeah. And anvil is https://github.com/Smithay/smithay/tree/master/anvil

YaLTeR avatar Jan 17 '25 09:01 YaLTeR

I'll take a look and get back to you! (Thanks for the quick replies btw!)

ViddeM avatar Jan 17 '25 09:01 ViddeM

I got a bit distracted (gotta get some work done too 😅). I'm not too familiar with the relation between WMs and Compositors, should I try installing / running cosmic-comp together with Niri (if so how?) or that I should run the entire cosmic WM?

ViddeM avatar Jan 17 '25 13:01 ViddeM

On Wayland the compositor and the WM are one and the same. You can run cosmic-comp on a TTY, open some window there (not sure what their default binds are), then try to suspend/unsuspend and see if you can reproduce the issue. Or you could install and run the entire cosmic if that's easier.

YaLTeR avatar Jan 17 '25 13:01 YaLTeR

So, I sort of got cosmic-comp to work (didn't really find any installation instructions).

However, there I just ended up directly on the GDM3 login screen after opening the lid and all monitors were active after logging in again.

ViddeM avatar Jan 17 '25 16:01 ViddeM

Hm. And this was the same session, as in it didn't just crash upon opening the lid?

YaLTeR avatar Jan 17 '25 17:01 YaLTeR

I tried to do some more testing to confirm weather it was or wasn't but now it doesn't work at all, my waybar doesn't load and the mouse won't move. Seems like it breaks quite badly. I also tried anvil and that too seemed to break completely when closing the lid. :/

ViddeM avatar Jan 18 '25 17:01 ViddeM

I also tried anvil and that too seemed to break completely when closing the lid

Hmm, might be a Smithay issue then. Really not sure. Do other compositors work fine? Like GNOME or KDE or sway.

YaLTeR avatar Jan 18 '25 17:01 YaLTeR

Gnome has worked great for x11 and mostly in wayland mode, I have noticed some windows looking a little bit weird at times after sleep mode but moving them around usually solved that.

ViddeM avatar Jan 18 '25 21:01 ViddeM

If it reproduces on anvil (or better on cosmic), it's probably better to open an issue on Smithay or on cosmic-comp. They have much more experience (and funding) dealing with strange problems like this.

YaLTeR avatar Jan 19 '25 05:01 YaLTeR

@ViddeM you still affected by this issue? Happens for me as well. Journalctl logs below

Jun 30 10:50:26 katana systemd[1560]: Starting A scrollable-tiling Wayland compositor...
Jun 30 10:50:26 katana niri[1822]: 2025-06-30T07:50:26.377972Z  INFO niri: starting version 25.05.1 (8ba57fc)
Jun 30 10:50:26 katana niri[1822]: 2025-06-30T07:50:26.395924Z DEBUG niri_config: loaded config from "/home/ev3/.config/niri/config.kdl"
Jun 30 10:50:26 katana niri[1822]: 2025-06-30T07:50:26.517275Z  INFO niri::backend::tty: using as the render node: "/dev/dri/renderD129"
Jun 30 10:50:26 katana niri[1822]: Fontconfig warning: using without calling FcInit()
Jun 30 10:50:26 katana niri[1822]: 2025-06-30T07:50:26.548767Z DEBUG niri::backend::tty: device added: 57857 "/dev/dri/card1"
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.087102Z DEBUG niri::backend::tty: this is the primary node
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.087115Z DEBUG niri::backend::tty: this is the primary render node
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.136890Z DEBUG niri::backend::tty: device changed: 57857
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.592341Z DEBUG niri::backend::tty: new connector: eDP-1 "AU Optronics 0x978F Unknown"
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.592443Z DEBUG niri::backend::tty: connecting connector: eDP-1
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.592504Z DEBUG niri::backend::tty: picking mode: Mode { name: "1920x1080", clock: 368140, size: (1920, 1080), hsync: (1968, 2000, 2102), vsync: (1090, 1095, 1216), hskew: 0, vscan: 0, vrefresh: 144, m>
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.592702Z DEBUG niri::backend::tty: set max bpc to 8
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.595586Z DEBUG niri::niri: putting output eDP-1 at x=1280 y=0
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.595603Z DEBUG niri::backend::tty: device added: 57856 "/dev/dri/card0"
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.622045Z DEBUG niri::backend::tty: device changed: 57856
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.718520Z DEBUG niri::backend::tty: new connector: HDMI-A-1 "PNP(TSU) TS3200-T16 Unknown"
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.718527Z DEBUG niri::backend::tty: connecting connector: HDMI-A-1
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.718533Z DEBUG niri::backend::tty: picking mode: Mode { name: "2560x1440", clock: 580080, size: (2560, 1440), hsync: (2608, 2640, 2720), vsync: (1443, 1448, 1481), hskew: 0, vscan: 0, vrefresh: 144, m>
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.718541Z DEBUG niri::backend::tty: error setting max bpc: couldn't find max bpc property
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.807543Z DEBUG niri::niri: putting output HDMI-A-1 at x=3200 y=0
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.807593Z  INFO niri: listening on Wayland socket: wayland-1
Jun 30 10:50:27 katana niri[1822]: 2025-06-30T07:50:27.807595Z  INFO niri: IPC listening on: /run/user/1002/niri.wayland-1.1822.sock
Jun 30 10:50:27 katana systemd[1560]: Started A scrollable-tiling Wayland compositor.
Jun 30 10:50:40 katana niri[1822]: libinput error: event9  - 2.4G Mouse: client bug: event processing lagging behind by 25ms, your system is too slow
Jun 30 10:50:47 katana niri[1822]: libinput error: event9  - 2.4G Mouse: client bug: event processing lagging behind by 25ms, your system is too slow
Jun 30 10:50:49 katana niri[1822]: libinput error: event9  - 2.4G Mouse: client bug: event processing lagging behind by 23ms, your system is too slow
Jun 30 10:51:06 katana niri[1822]: libinput error: event7  - DaKai 2.4G Dongle: client bug: event processing lagging behind by 21ms, your system is too slow
Jun 30 10:52:08 katana niri[1822]: libinput error: event9  - 2.4G Mouse: client bug: event processing lagging behind by 24ms, your system is too slow
Jun 30 10:52:08 katana niri[1822]: libinput error: event9  - 2.4G Mouse: client bug: event processing lagging behind by 21ms, your system is too slow
Jun 30 10:52:08 katana niri[1822]: libinput error: event9  - 2.4G Mouse: WARNING: log rate limit exceeded (5 msgs per 60min). Discarding future messages.
Jun 30 10:53:53 katana niri[1822]: libinput error: event7  - DaKai 2.4G Dongle: client bug: event processing lagging behind by 48ms, your system is too slow
Jun 30 10:55:37 katana niri[1822]: libinput error: event7  - DaKai 2.4G Dongle: client bug: event processing lagging behind by 45ms, your system is too slow
Jun 30 10:56:14 katana niri[1822]: 2025-06-30T07:56:14.412449Z DEBUG niri::input: lid switch closed
Jun 30 10:56:14 katana niri[1822]: 2025-06-30T07:56:14.412474Z DEBUG niri::backend::tty: disconnecting connector: "eDP-1"
Jun 30 10:56:14 katana niri[1822]: 2025-06-30T07:56:14.412503Z DEBUG niri::niri: putting output HDMI-A-1 at x=0 y=0
Jun 30 10:56:15 katana niri[1822]: 2025-06-30T07:56:15.853723Z DEBUG niri::backend::tty: pausing session
Jun 30 10:56:15 katana niri[1822]: 2025-06-30T07:56:15.853823Z  WARN niri::backend::tty: device is inactive
Jun 30 10:56:15 katana niri[1822]: 2025-06-30T07:56:15.859035Z  WARN niri::backend::tty: device is inactive
Jun 30 10:56:21 katana niri[1822]: 2025-06-30T07:56:21.545287Z  WARN niri::backend::tty: device is inactive
Jun 30 10:56:21 katana niri[1822]: 2025-06-30T07:56:21.757565Z DEBUG niri::backend::tty: resuming session
Jun 30 10:56:22 katana niri[1822]: 2025-06-30T07:56:22.117471Z DEBUG niri::backend::tty: device changed: 57857
Jun 30 10:56:22 katana niri[1822]: 2025-06-30T07:56:22.947019Z DEBUG niri::backend::tty: device changed: 57856

dolzenko avatar Jun 30 '25 07:06 dolzenko

I'm also having this issue. I've used cosmic in the past (before niri) on this same laptop and I didn't experience this or anything similar.

I'm also experiencing another strange behavior which might be related: my laptop is an Asus with a secondary display. Initially, both displays are on. When I open my lid is that the main display is disabled, but the secondary display remains on. But when I disable the secondary display with echo 4 | sudo tee /sys/class/backlight/asus_screenpad/bl_power, the main display turns on. Then when I enable the secondary display again with echo 0 | sudo tee /sys/class/backlight/asus_screenpad/bl_power, the main display turns off. I've also noticed that when the main display is off, it is still listed under niri msg outputs but Disabled. When I power off the secondary display though, it is not present in the outputs list.

I also notice this only happens when I have configured systemd-logind to suspend on lid close. When I set the option to ignore this does not occur.

Suspending first (systemctl suspend), waiting for both displays to power off, and then closing the lid does not cause this issue. Upon opening both displays are on.

Setting keep-laptop-panel-on-when-lid-is-closed fixes it, as noted above. Actually, I've also noticed that enabling this option at runtime, after the main display has already been powered off, also fixes the issue. Removing it again brings back the issue and turns off the main display.

The main display is eDP-1 and the secondary display is DP-1.

Logs with logind set to suspend on lid close, closing and opening:
Jul 04 19:52:49 laptop niri[1927]: 2025-07-05T02:52:49.802630Z DEBUG niri::backend::tty: device changed: 57857
Jul 04 19:52:49 laptop niri[1927]: 2025-07-05T02:52:49.816675Z DEBUG niri::backend::tty: disconnecting connector: "DP-1"
Jul 04 19:52:51 laptop niri[1927]: 2025-07-05T02:52:51.142182Z DEBUG niri::input: lid switch closed
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.466074Z DEBUG niri::backend::tty: device changed: 57857
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.484678Z DEBUG niri::backend::tty: new connector: DP-1 "BOE 0x0A8D Unknown"
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.484697Z DEBUG niri::backend::tty: disconnecting connector: "eDP-1"
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.484896Z DEBUG niri::backend::tty: connecting connector: DP-1
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.484910Z DEBUG niri::backend::tty: picking mode: Mode { name: "2880x864", clock: 167100, size: (2880, 864), hsync: (2928, 2960, 3040), vsync: (867, 873, 916), hskew: 0, vscan: 0, vrefresh: 60, mode_type: ModeTypeFlags(DRIVER) }
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.484934Z DEBUG niri::backend::tty: set max bpc to 8
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.910351Z  WARN niri::backend::tty: error creating DRM compositor, will try with invalid modifier: DrmError(Access(AccessError { errmsg: "Error testing state", dev: Some("/dev/dri/card1"), source: Os { code: 22, kind: InvalidInput, message: "Invalid argument" } }))
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.916291Z  WARN niri::backend::tty: error connecting connector: error creating DRM compositor
Jul 04 19:52:59 laptop niri[1927]: Caused by:
Jul 04 19:52:59 laptop niri[1927]:     0: The underlying drm surface encountered an error: DRM access error: Error testing state on device `Some("/dev/dri/card1")` (Invalid argument (os error 22))
Jul 04 19:52:59 laptop niri[1927]:     1: DRM access error: Error testing state on device `Some("/dev/dri/card1")` (Invalid argument (os error 22))
Jul 04 19:52:59 laptop niri[1927]:     2: Invalid argument (os error 22)
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.916553Z DEBUG niri::backend::tty: pausing session
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.917242Z DEBUG niri::backend::tty: resuming session
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.976034Z DEBUG niri::backend::tty: device changed: 57856
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.976660Z DEBUG niri::backend::tty: connecting connector: DP-1
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.976675Z DEBUG niri::backend::tty: picking mode: Mode { name: "2880x864", clock: 167100, size: (2880, 864), hsync: (2928, 2960, 3040), vsync: (867, 873, 916), hskew: 0, vscan: 0, vrefresh: 60, mode_type: ModeTypeFlags(DRIVER) }
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.976687Z DEBUG niri::backend::tty: set max bpc to 8
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.976728Z  WARN niri::backend::tty: error connecting connector: Device is currently paused, operation rejected
Jul 04 19:52:59 laptop niri[1927]: 2025-07-05T02:52:59.985615Z DEBUG niri::backend::tty: device changed: 57857
Jul 04 19:53:00 laptop niri[1927]: 2025-07-05T02:53:00.678216Z DEBUG niri::backend::tty: connecting connector: DP-1
Jul 04 19:53:00 laptop niri[1927]: 2025-07-05T02:53:00.678263Z DEBUG niri::backend::tty: picking mode: Mode { name: "2880x864", clock: 167100, size: (2880, 864), hsync: (2928, 2960, 3040), vsync: (867, 873, 916), hskew: 0, vscan: 0, vrefresh: 60, mode_type: ModeTypeFlags(DRIVER) }
Jul 04 19:53:00 laptop niri[1927]: 2025-07-05T02:53:00.678281Z DEBUG niri::backend::tty: set max bpc to 8
Jul 04 19:53:00 laptop niri[1927]: 2025-07-05T02:53:00.680723Z DEBUG niri::niri: putting output DP-1 at x=0 y=1440
Logs when I manually power off the secondary display after the above:
Jul 04 19:54:51 laptop niri[1927]: 2025-07-05T02:54:51.965868Z DEBUG niri::backend::tty: device changed: 57857
Jul 04 19:54:52 laptop niri[1927]: 2025-07-05T02:54:52.185950Z DEBUG niri::backend::tty: disconnecting connector: "DP-1"
Jul 04 19:54:52 laptop niri[1927]: 2025-07-05T02:54:52.365434Z DEBUG niri::backend::tty: connecting connector: eDP-1
Jul 04 19:54:52 laptop niri[1927]: 2025-07-05T02:54:52.365467Z  WARN niri::backend::tty: configured mode [email protected] could not be found, falling back to preferred
Jul 04 19:54:52 laptop niri[1927]: 2025-07-05T02:54:52.365470Z DEBUG niri::backend::tty: picking mode: Mode { name: "2880x1800", clock: 653370, size: (2880, 1800), hsync: (2900, 2932, 2972), vsync: (1816, 1824, 1832), hskew: 0, vscan: 0, vrefresh: 120, mode_type: ModeTypeFlags(PREFERRED | DRIVER) }
Jul 04 19:54:52 laptop niri[1927]: 2025-07-05T02:54:52.365492Z DEBUG niri::backend::tty: set max bpc to 8
Jul 04 19:54:52 laptop niri[1927]: 2025-07-05T02:54:52.369780Z DEBUG niri::niri: putting output eDP-1 at x=0 y=0
Logs with logind set to ignore lid close, closing then opening:
Jul 04 20:02:18 laptop niri[1917]: 2025-07-05T03:02:18.558400Z DEBUG niri::backend::tty: device changed: 57857
Jul 04 20:02:18 laptop niri[1917]: 2025-07-05T03:02:18.573432Z DEBUG niri::backend::tty: disconnecting connector: "DP-1"
Jul 04 20:02:19 laptop niri[1917]: 2025-07-05T03:02:19.896686Z DEBUG niri::input: lid switch closed
Jul 04 20:02:26 laptop niri[1917]: 2025-07-05T03:02:26.706461Z DEBUG niri::input: lid switch opened
Jul 04 20:02:26 laptop niri[1917]: 2025-07-05T03:02:26.798007Z DEBUG niri::backend::tty: device changed: 57857
Jul 04 20:02:26 laptop niri[1917]: 2025-07-05T03:02:26.823310Z DEBUG niri::backend::tty: new connector: DP-1 "BOE 0x0A8D Unknown"
Jul 04 20:02:26 laptop niri[1917]: 2025-07-05T03:02:26.823331Z DEBUG niri::backend::tty: connecting connector: DP-1
Jul 04 20:02:26 laptop niri[1917]: 2025-07-05T03:02:26.823350Z DEBUG niri::backend::tty: picking mode: Mode { name: "2880x864", clock: 167100, size: (2880, 864), hsync: (2928, 2960, 3040), vsync: (867, 873, 916), hskew: 0, vscan: 0, vrefresh: 60, mode_type: ModeTypeFlags(DRIVER) }
Jul 04 20:02:26 laptop niri[1917]: 2025-07-05T03:02:26.823375Z DEBUG niri::backend::tty: set max bpc to 8
Jul 04 20:02:26 laptop niri[1917]: 2025-07-05T03:02:26.826680Z DEBUG niri::niri: putting output DP-1 at x=0 y=1440

stefanboca avatar Jul 05 '25 02:07 stefanboca

Setting keep-laptop-panel-on-when-lid-is-closed fixes it, as noted above. Actually, I've also noticed that enabling this option at runtime, after the main display has already been powered off, also fixes the issue. Removing it again brings back the issue and turns off the main display.

i was having the same issue from a while, i can confirm that keep-laptop-panel-on-when-lid-is-closed helps. Only caveat is that it doesn't get deactivated so you can move to the other display (which honestly is better than having to restart laptop every time i wake it up from sleep to get both displays working)

felix-kyun avatar Sep 14 '25 19:09 felix-kyun

Please try niri after https://github.com/YaLTeR/niri/commit/8c8447918f4fd7bc6c86a8622b1db52417fbbbbd to see if this is fixed

YaLTeR avatar Oct 18 '25 06:10 YaLTeR

It's fixed for me!

stefanboca avatar Oct 18 '25 07:10 stefanboca

Perfect, thanks

YaLTeR avatar Oct 18 '25 07:10 YaLTeR