DEV Community

Mendy Kevin
Mendy Kevin

Posted on

Connecting an External Ultrawide to Ubuntu — Lid Close, Resolution, and Scaling Fixes.

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"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
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
Enter fullscreen mode Exit fullscreen mode

Wayland users: xrandr won'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"
Enter fullscreen mode Exit fullscreen mode

This confirmed the system was suspending.

Check for Inhibitors

systemd-inhibit
Enter fullscreen mode Exit fullscreen mode

The critical line:

kmend  1000  kmend  8753  gsd-power  handle-lid-switch  External monitor attached or configuration changed recently  block
Enter fullscreen mode Exit fullscreen mode

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'
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Both should return 'nothing'. This takes effect immediately.

Common mistake: setting sleep-inactive-ac-type to 'nothing' does NOT affect the lid. That controls the idle timeout. The lid-specific keys are lid-close-ac-action and lid-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
Enter fullscreen mode Exit fullscreen mode
[Login]
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Undo later:

sudo systemctl unmask suspend.target suspend-then-hibernate.target hibernate.target hybrid-sleep.target
Enter fullscreen mode Exit fullscreen mode

Step 8 — Reboot and Verify

sudo reboot
Enter fullscreen mode Exit fullscreen mode

After reboot, close the lid, reopen, then:

journalctl --since "2 min ago" | grep -iE "lid|suspend|sleep|logind"
Enter fullscreen mode Exit fullscreen mode

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)