I first started using Linux and FreeBSD on laptops in the late 1990s. Back then, there were all sorts of hassles and problems, from hangs on suspend to pure failure to boot. I still worry a bit about suspend on unknown hardware, but by and large, the picture of Linux on laptops has dramatically improved over the last years. So much so that now I can complain about what would once have been a minor nit: dealing with external monitors.
I have a USB-C dock that provides both power and a Thunderbolt display output over the single cable to the laptop. I think I am similar to most people in wanting the following behavior from the laptop:
- When the lid is closed, suspend if no external monitor is connected. If an external monitor is connected, shut off the built-in display and use the external one exclusively, but do not suspend.
- Lock the screen automatically after a period of inactivity.
- While locked, all connected displays should be powered down.
- When an external display is connected, begin using it automatically.
- When an external display is disconnected, stop using it. If the lid is closed when the external display is disconnected, go into suspend mode.
This sounds so simple. But somehow on Linux we’ve split up these things into a dozen tiny bits:
- In /etc/systemd/logind.conf, there are settings about what to do when the lid is opened or closed.
- Various desktop environments have overlapping settings covering the same things.
- Then there are the display managers (gdm3, lightdm, etc) that also get in on the act, and frequently have DIFFERENT settings, set in different places, from the desktop environments. And, what’s more, they tend to be involved with locking these days.
- Then there are screensavers (gnome-screensaver, xscreensaver, etc.) that also enter the picture, and also have settings in these areas.
Problems I’ve Seen
My problems don’t even begin with laptops, but with my desktop, running XFCE with xmonad and lightdm. My desktop is hooked to a display that has multiple inputs. This scenario (reproducible in both buster and bullseye) causes the display to be unusable until a reboot on the desktop:
- Be logged in and using the desktop
- Without locking the desktop screen, switch the display input to another device
- Keep the display input on another device long enough for the desktop screen to auto-lock
- At this point, it is impossible to re-awaken the desktop screen.
I should not here that the problems aren’t limited to Debian, but also extend to Ubuntu and various hardware.
Lightdm: which greeter?
At some point while troubleshooting things after upgrading my laptop to bullseye, I noticed that while both were running lightdm, I had different settings and a different appearance between the two. Upon further investigation, I realized that one hat slick-greeter and lightdm-settings installed, while the other had lightdm-gtk-greeter and lightdm-gtk-greeter-settings installed. Very strange.
XFCE: giving up
I eventually gave up on making lightdm work. No combination of settings or greeters would make things work reliably when changing screen configurations. I installed xscreensaver. It doesn’t hang, but it does sometimes take a few tries before it figures out what device to display on.
Worse, since updating from buster to bullseye, XFCE no longer automatically switches audio output when the docking station is plugged in, and there seems to be no easy way to convince Pulseaudio to do this.
X-Based Gnome and derivatives… sigh.
I also tried Gnome, Mate, and Cinnamon, and all of them had various inabilities to configure things to act the way I laid out above.
I’ve long not been a fan of Gnome’s way of hiding things from the user. It now has a Windows-like situation of three distinct settings programs (settings, tweaks, and dconf editor), which overlap in strange ways and interact with systemd in even stranger ways. Gnome 3 make it quite non-intuitive to make app icons from various programs work, and so forth.
Trying Wayland
I recently decided to set up an older laptop that I hadn’t used in awhile. After reading up on Wayland, I decided to try Gnome 3 under Wayland. Both the Debian and Arch wikis note that KDE is buggy on Wayland. Gnome is the only desktop environment that supports it then, unless I want to go with Sway. There’s some appeal to Sway to this xmonad user, but I’ve read of incompatibilities of Wayland software when Gnome’s not available, so I opted to try Gnome.
Well, it’s better. Not perfect, but better. After finding settings buried in a ton of different Settings and Tweaks boxes, I had it mostly working, except gdm3 would never shut off power to the external display. Eventually I found /etc/gdm3/greeter.dconf-defaults, and aadded:
sleep-inactive-ac-timeout=60 sleep-inactive-ac-type='blank' sleep-inactive-battery-timeout=120 sleep-inactive-battery-type='suspend'
Of course, these overlap with but are distinct from the same kinds of things in Gnome settings.
Sway?
Running without Gnome seems like a challenge; Gnome is switching audio output appropriately, for instance. I am looking at some of the Gnome Shell tiling window manager extensions and hope that some of them may work for me.
For what it’s worth: I spent some time earlier this year improving my desktop setup, and I ended up with a Sway-on-Wayland configuration. I have a similar situation: laptop with an external monitor, ex-XMonad / i3 /ion3 / … user. An additional factor in my case was that the external factor was 4K, and support for that is a bit spotty (in particular, X doesn’t have good support for using two monitors with vastly different DPI).
I’ve been pretty happy with my new setup. It was fiddly to get it working, but in the way that old-school Linux was fiddly — it didn’t magically do what I wanted, but once I tracked down the right software to use, the configuration options I needed were documented, and I was able to set it up the way I wanted (including screen blanking/locking and handling hotplugging). And it shows every sign of remaining set-up. Now I just need Emacs to support dpi scaling so it’s not all fuzzy…
Reviewing the notes I kept and summarizing:
– I set up kanshi to handle multiple output configuration. This auto-adjusts DPI factors so that my laptop screen is magnified when connected to my monitor, to account for it being on a stand a couple feet farther from my eyes than usual.
– Since you mentioned audio: I route audio through the monitor when it’s plugged in. This mostly works for me, but I have had occasional cases of audio not switching over properly. I’ve also had some issues with the external camera (routed via the monitor) getting “lost” sometimes. It usually seems to work, so I have been assuming that it’s a driver problem rather than missing desktop infrastructure. It hasn’t been annoying enough for me to track down yet.
– I set up sawyidle and swaylock to set up locking on demand and when idle.
– Getting Firefox to scale required custom configuration: https://wiki.archlinux.org/title/Firefox#Wayland
– The default terminal in sway is “foot”, but that had a bunch of issues for me, so I went back to gnome-terminal, which I’ve been fairly happy with over the years.
– I’m using the Cinnamon config GUIs (cinnamon-settings) for things that don’t have a clear path via lower level tools. Don’t know if this is recommended, but it works OK for printers, audio, etc.
– I haven’t bothered to set up a working polkit daemon. Just the other day I figured out that I can run “lxpolkit” in a terminal. Probably I’ll eventually configure it to run on startup, like swayidle.
– Typing this comment inspired me to figure out how to get battery status into my status bar. There doesn’t seem to be anything out of the box for it, but it was pretty easy to get basic info up there. Getting colors and handling my laptop’s multiple batteries required cobbling together a simple bash script, probably about half an hour.
As Daniel, I have switched from i3 to sway, in three out of four computers (the fourth one is the one I use to give my classes, and I’m wary of breaking a setup that has finally worked fine for me after trying many different combinations). I am very satisfied with Sway. Granted, I don’t do much desktop-environmenty stuff, but I have not had software break for me because of not having a Gnome sesion.
Yes, I like controlling the bits by myself, so I find it perfectly acceptable to write «for_window [title=”Firefox – Sharing Indicator”] floating enable» to avoid the sharing indicator of Firefox to occupy a full window tile.
I originally hesitated, and made the switch because my ARM laptop (Lenovo Yoga C630) was too slow under X and i3. But the ease of converting the i3 setup to Sway was a strong reason for me to be willing to do the leap, and I am absolutely happy with it!
Wow really cool! Hows the battery performance for your ARM laptop? Does it suspend too?
Last year I’ve got to use an ASUS FX505D TUF, one of those gamer notebooks with dual video card. With a little gotcha: it featured both an AMD/ATi and an NVidia card.
The AMD one was the default and the less power-hungry of both, hooked to the notebook’s display. The NVidia was of course the “gaming” one… and the one hooked to the external HDMI port.
When a user wants to use both displays one video card does the rendering and writes the final image into a buffer accessible by the other card, which will only put that buffer in the necessary port. The problem is that NVidia and AMD uses some “kernel big pages” feature differently, and so they weren’t able to cooperate between them: you can only use one display at a time.
I had to return the notebook, so I don’t know if the situation improved or not.
It really felt like being back in the old days of configuring a CRT by hand :-)
I have to use a Dell laptop in my job. Working from home, I’d rather use my larger but lower-resolution monitor and my cheap USB keyboard than the laptop’s own screen and horrid laptop keyboard. However, running Fedora on the laptop, which I guess is semi-supported, has produced all sorts of weird display-related issues.
Perhaps the worst thing has been the interaction between the laptop and the monitor. I have to open up the laptop, which is like an unergonomic metal brick, and press the rubberised power button on the rubberised surface that will presumably be sticky in twenty years (although with “technological progress” on overdrive, it will be e-waste long before then). The idea is then to close the laptop and let everything happen on the monitor, like using the laptop as a small form factor machine.
Using the monitor alone did work once upon a time, but then I started to have problems with the login screen. The absolute worst was the way that somehow both the laptop and monitor outputs (in a virtual sense) became superimposed on each other. Clicking on the navigation menus on the login screen caused a kind of pulsating blur effect as if one’s eyeballs were being subjected to vibration, and it became difficult to select the now-important reboot option.
I now log in with the laptop screen open and then close it when GNOME shows up. At various points, I would get windows opening with the wrong dimensions but with the buttons in their correct places. So I have to point at the place where I think the maximise icon is and hope I am not clicking on something else. This was a problem with a previous Fedora version, then not, then it is once again.
It is all really rather unpleasant.
This is a really odd post for me to see, because I run Ubuntu and Kubuntu full time on both my Thinkpad laptops and the behavior you describe is precisely what I get without any manual configuration.
Please proof-read your posts. You have ‘one hat slick-greeter’ (*sic*).
@jgoerzen I guess I avoid most of those triggers, although somewhat to avoid the issues not that they don’t affect me.The issue of tiling window managers makes it a bad deal though :(
I recently wrote that managing an external display on Linux shouldn’t be this hard. I went down a path of trying out some different options before finally landing at an unexpected place: KDE. I say “unexpected” because I find tiling window managers are just about a necessity.
Background: xmonad
Until a few months ago, I’d been using xmonad for well over a decade. Configurable, minimal, and very nice; it suited me well.
However, xmonad is getting somewhat long in the tooth. xmobar, which is commonly used with it, barely supports many modern desktop environments. I prefer DEs for the useful integrations they bring: everything from handling mount of USB sticks to display auto-switching and sound switching. xmonad itself can’t run with modern Gnome (whether or not it runs well under KDE 5 seems to be a complicated question, according to wikis, but in any case, there is no log applet for KDE 5). So I was left with XFCE and such, but the isues I identified in the “shouldn’t be this hard” article were bad enough that I just could not keep going that way.
An attempt: Gnome and PaperWM
So I tried Gnome under Wayland, reasoning that Wayland might stand a chance of doing things well where X couldn’t. There are several tiling window extensions available for the Gnome 3 shell. Most seemed to be rather low-quality, but an exception was PaperWM and I eventually decided on it. I never quite decided if I liked its horizontal tape of windows or not; it certainly is unique in any case.
I was willing to tolerate my usual list of Gnome problems for the sake of things working. For instance:
The Windows-like “settings are spread out in three different programs and some of them require editing the registry[dconf]”. Finding all the options for keybindings and power settings was a real chore, but done.
Some file dialog boxes (such as with the screenshot-taking tool) just do not let me type in a path to save a file, insisting that I first navigate to a directory and then type in a name.
General lack of available settings or hiding settings from people.
True focus-follows-mouse was incompatible with keyboard window switching (PaperWM or no); with any focus-follows-mouse enabled, using Alt-Tab or any other method to switch to other windows would instantly have focus returned to whatever the mouse was over.
Under Wayland, I found a disturbing lack of logs. There was nothing like /var/log/Xorg.0.log, nothing like ~/.xsession-errors, just nothing. Searching for answers on this revealed a lot of Wayland people saying “it’s a Gnome issue” and the trail going cold at that point.
And there was a weird problem that I just could not solve. After the laptop was suspended and we-awakened, I would be at a lock screen. I could type in my password, but when hitting Enter, the thing would then tend to freeze. Why, I don’t know. It seemed related to Gnome shell; when I switched Gnome from Wayland to X11, it would freeze but eventually return to the unlock screen, at which point I’d type in my password and it would freeze again. I spent a long time tracking down logs to see what was happening, but I couldn’t figure it out. All those hard resets were getting annoying.
Enter KDE
So I tried KDE. I had seen mentions of kwin-tiling, a KDE extension for tiling windows. I thought I’d try this setup.
I was really impressed by KDE’s quality. Not only did it handle absolutely every display-related interaction correctly by default, with no hangs ever, all relevant settings were clearly presented in one place. The KDE settings screens were a breath of fresh air – lots of settings available, all at one place, and tons of features I hadn’t seen elsewhere.
Here are some of the things I was pleasantly surprised by with KDE:
Applications can declare classes of notifications. These can be managed Android-style in settings. Moreover, you can associate a shell command to run with a notification in any class. People use this to do things like run commands when a display locks and so forth.
KDE Connect is a seriously impressive piece of software. It integrates desktops with Android devices in a way that’s reminiscent of non-free operating systems – and with 100% Free Software (the phone app is even in F-Droid!). Notifications from the phone can appear on the desktop, and their state is synchronized; dismiss it on the desktop and it dismisses on the phone, too. Get a SMS or Signal message on the phone? You can reply directly from the desktop. Share files in both directions, mount a directory tree from the phone on the desktop, “find my phone”, use the phone as a presentation remote for the desktop, shared clipboard, sending links between devices, control the phone media player from the desktop… Really, really impressive.
The shortcut settings in KDE really work and are impressive. Unlike Gnome, if you try to assign the same shortcut to multiple things, you are warned and prevented from doing this. As with Gnome, you can also bind shorcuts to arbitrary actions.
This shouldn’t be exciting, but I was just using Gnome, so… The panel! I can put things wherever I want them! I can put it at the top of the screen, the bottom, or even the sides! It lets all my regular programs (eg, Nextcloud) put their icons up there without having to install two different extensions, each of which handles a different set of apps! I shouldn’t be excited about all this, because Gnome actually used to have these features years ago… [gripe gripe]
Initially I was annoyed that Firefox notifications weren’t showing up in the notification history as they did in Gnome… but that was, of course, a setting, easily fixed!
There is a Plasma Integration plugin for Firefox (and other browsers including Chrome). It integrates audio and video playback, download status, etc. with the rest of KDE and KDE Connect. Result: if you like, when a call comes in to your phone, Youtube is paused. Or, you can right-click to share a link to your phone via KDE Connect, and so forth. You can right click on a link, and share via Bluetooth, Nextcloud (it must have somehow registered with KDE), KDE Connect, email, etc.
Tiling
So how about the tiling system, kwin-tiling? The out of the box experience is pretty nice. There are fewer built-in layouts than with xmonad, but the ones that are there are doing a decent job for me, and in some cases are more configurable (those that have a large window pane are configurable on its location, not forcing it to be on the left as with many systems.) What’s more, thanks to the flexibility in the KDE shortcut settings, I can configure it to be nearly keystroke-identical to xmonad!
Issues Encountered
I encountered a few minor issues:
There appears to be no way to tell it to “power down the display immediately after it is locked, every time” instead of waiting for some timeout to elapse. This is useful when I want to switch monitor inputs to something else.
Firefox ESR seems to have some rendering issues under KDE for some reason, but switching to the latest stable release direct from Mozilla seems to fix that.
In short, I’m very impressed.
Two years ago, I wrote Managing an External Display on Linux Shouldn’t Be This Hard. Happily, since I wrote that post, most of those issues…