The Setup
HP EliteBook 745 G6 → USB-C → DisplayPort → 3440×1440 ultrawide monitor.
I wanted to close the lid and keep presenting on the external display. Ubuntu kept suspending. The monitor wasn't offering its native resolution. Here's everything I did, in order.
Step 1 — Connect and Check What's Detected
xrandr --query | grep -E "connected|HDMI|DP|eDP"
My output:
eDP connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
DisplayPort-0 disconnected
DisplayPort-1 disconnected
DisplayPort-2 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 797mm x 334mm
The external monitor is on DisplayPort-2 (USB-C alt mode). Good — DP has enough bandwidth for 3440×1440.
Step 2 — Check Available Resolutions
xrandr --query | grep -A 20 "DisplayPort-2 connected"
This showed 3440×1440 was not in the advertised modes list. The monitor's EDID wasn't exposing it, so the GUI had no option to select it.
Step 3 — Add the Missing Resolution (X11)
Generate the modeline:
cvt 3440 1440 60
Output:
# 3440x1440 59.94 Hz (CVT) hsync: 89.48 kHz; pclk: 419.50 MHz
Modeline "3440x1440_60.00" 419.50 3440 3696 4064 4688 1440 1443 1453 1493 -hsync +vsync
Add and apply:
xrandr --newmode "3440x1440_60.00" 419.50 3440 3696 4064 4688 1440 1443 1453 1493 -hsync +vsync
xrandr --addmode DisplayPort-2 3440x1440_60.00
xrandr --output DisplayPort-2 --mode 3440x1440_60.00
If the screen goes black, wait 10 seconds then type:
xrandr --output DisplayPort-2 --mode 1920x1080
If the full-blanking modeline doesn't work, try reduced blanking (lower bandwidth):
cvt -r 3440 1440 60
Then use that modeline in the same --newmode / --addmode / --mode sequence.
Make It Persist Across Reboots
sudo nano /etc/X11/xorg.conf.d/34-monitor.conf
Section "Monitor"
Identifier "Ultrawide"
Modeline "3440x1440_60.00" 419.50 3440 3696 4064 4688 1440 1443 1453 1493 -hsync +vsync
Option "PreferredMode" "3440x1440_60.00"
EndSection
Wayland users:
xrandrwon't work. Select "Ubuntu on Xorg" at the login screen, or use GNOME Settings which reads DRM modes directly.
Step 4 — Diagnose the Lid Close Issue
Close the lid. Reopen. Check what actually happened:
journalctl --since "2 min ago" | grep -iE "lid|suspend|sleep|logind"
This confirmed the system was suspending.
Check for Inhibitors
systemd-inhibit
The critical line:
kmend 1000 kmend 8753 gsd-power handle-lid-switch External monitor attached or configuration changed recently block
This is the smoking gun. gsd-power is holding a block-mode inhibitor on handle-lid-switch. This means logind's HandleLidSwitch setting is completely bypassed — GNOME is in charge of the lid event, not logind.
Step 5 — Fix the Lid Close (GNOME Settings)
Since GNOME is in charge, you need to fix GNOME's lid settings, not logind's:
gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action 'nothing'
gsettings set org.gnome.settings-daemon.plugins.power lid-close-battery-action 'nothing'
Verify:
gsettings get org.gnome.settings-daemon.plugins.power lid-close-ac-action
gsettings get org.gnome.settings-daemon.plugins.power lid-close-battery-action
Both should return 'nothing'. This takes effect immediately.
Common mistake: setting
sleep-inactive-ac-typeto'nothing'does NOT affect the lid. That controls the idle timeout. The lid-specific keys arelid-close-ac-actionandlid-close-battery-action.
Step 6 — Fix Logind (Defense in Depth)
Create a drop-in:
sudo mkdir -p /etc/systemd/logind.conf.d
sudo nano /etc/systemd/logind.conf.d/99-lid.conf
[Login]
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
The
[Login]header is mandatory. Without it, the file is silently ignored.
Reload and verify:
sudo systemctl reload systemd-logind
busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager HandleLidSwitch
Expected: s "ignore"
Step 7 — Mask Suspend Targets (Optional Nuclear Option)
sudo systemctl mask suspend.target suspend-then-hibernate.target hibernate.target hybrid-sleep.target
Undo later:
sudo systemctl unmask suspend.target suspend-then-hibernate.target hibernate.target hybrid-sleep.target
Step 8 — Reboot and Verify
sudo reboot
After reboot, close the lid, reopen, then:
journalctl --since "2 min ago" | grep -iE "lid|suspend|sleep|logind"
No suspend entries = you're good.
Step 9 — HP BIOS (If It Still Misbehaves)
Some HP EliteBooks have a firmware-level lid handler that fires before the OS. Reboot → F10 → Advanced → Power Management:
- Lid Close Action → Do Nothing
- Smart Standby → Disable
Quick Reference
| Problem | Root Cause | Fix |
|---|---|---|
| Lid closes → suspend |
gsd-power holds block inhibitor; follows lid-close-*-action (defaults to suspend) |
gsettings set ... lid-close-ac-action 'nothing' |
| Lid closes → suspend (no external monitor) | logind default is suspend
|
Drop-in with HandleLidSwitch=ignore
|
| 3440×1440 not in GUI | Monitor EDID doesn't advertise it |
xrandr --newmode + --addmode + --mode
|
| 3440×1440 not working on HDMI | HDMI 1.4 bandwidth limit (~10.2 Gbps) | Use USB-C → DisplayPort instead |
The key insight: when an external monitor is attached, GNOME grabs the lid switch handler and ignores logind entirely. Most guides stop at editing logind.conf and wonder why it doesn't work. The actual fix is the gsettings command.
Top comments (0)