The LG 27GM950B can run at 5120×2880 and 165 Hz, or 2560×1440 and 330 Hz. Switching between them requires changing the monitor’s Dual Mode setting and GNOME’s display configuration. Launching a 1440p Gamescope window doesn’t handle that hardware switch.
I wanted 5K on my desktop and 330 Hz in games, with my original layout back when the game closed. I also wanted to keep stock Gamescope and my existing Steam launch options. I wrote gamescope-lg-dual-mode as a startup script, with one Lua file handling both the switch and recovery.
Switching the monitor
I used manufacturer-specific VCP feature 0xB1, sent over DDC/CI through ddcutil. The StreamController LG monitor plugin documents the high-refresh values for the 45GX950A, and lg-dual-mode documents the LG Switch command format. These values work on my 27GM950B:
| Operation | VCP feature | Value |
|---|---|---|
| Enable high-refresh Dual Mode | 0xB1 | 0x2100 |
| Return to normal mode | 0xB1 | 0x2200 |
I use separate on/off commands so recovery can repeat a command after an interrupted launch without toggling the monitor back.
The switch briefly blanks the monitor and changes its advertised modes. The watcher waits for Mutter to report 2560×1440 above 300 Hz, then selects it with the saved VRR preference. I use those modes as the state check rather than B1 readback.
Keeping my desktop layout
My gaming LG uses 2× scaling. The other LG runs at 4K60 with 1.5× scaling. When a game closes, I want both displays back at those settings and in the same positions.
I use Mutter’s DisplayConfig interface to read and restore that state through GetCurrentState and ApplyMonitorsConfig. Before the first hardware write, the watcher verifies that Mutter accepts the configuration and saves a recovery snapshot. That includes modes, scaling, positions, transforms, primary display and color-mode settings. There’s no fixed desktop preset to maintain.
The Lua implementation calls GLib/GIO through LuaJIT FFI and stores the snapshot as typed GVariant data, without extra Lua D-Bus or JSON libraries. An exclusive lock prevents two managed Gamescope sessions from changing the monitor at once.
Surviving a Gamescope crash
I couldn’t rely on cleanup inside Gamescope. After SIGKILL, its Lua interpreter is gone too.
The startup script runs the same file under the host LuaJIT interpreter in a transient systemd user service. That watcher owns the saved state and waits on Gamescope’s pidfd, without polling DDC during gameplay.
When Gamescope exits, the watcher switches Dual Mode off if it enabled it, waits for the saved mode to return, and restores the desktop. If the watcher itself is killed, systemd runs the file through ExecStopPost in recovery mode. A failed restore keeps the snapshot for another attempt.
The service exists for the managed session, not as a permanent daemon or login service. Recovery still needs the user session and runtime snapshot; I haven’t tested it across logout, reboot or power loss.
Installing it
My setup is GNOME Wayland with the 27GM950B. The script needs Gamescope with Lua scripting, a separate LuaJIT interpreter, ddcutil with DDC access, and systemd 254 or newer. The README lists the full dependencies.
The installer checks the monitor and enabled layout, Gamescope scripting, systemd user services, pidfds, Mutter access and a DDC brightness read. It refuses mirrored LG layouts. Preflight doesn’t install packages or change monitor settings.
These commands use the v0.1.0 release:
| |
Run it as your desktop user, without sudo. The installer fetches both files from the same pinned release before running them and removes the temporary downloads afterward.
That leaves one file at ~/.config/gamescope/scripts/90-lg-dual-mode.lua, or the equivalent under XDG_CONFIG_HOME. Gamescope’s loader reads it at startup. The fullscreen 1440p launch command stays the same:
| |
The script only manages matching fullscreen 1440p launches; it skips windowed launches and other resolutions. Put GAMESCOPE_LG_DUAL_MODE=0 before gamescope to bypass it for one launch.
I hit one multi-monitor problem: the gaming LG switched modes, but the cube opened on the 4K LG. GNOME still chooses where the window goes.
Leaving the pointer on the gaming LG during launch and reconnection fixed placement in my tests. The script doesn’t force an output.
What I tested
I tested the 27GM950B over DisplayPort on Fedora 45, GNOME/Mutter 51.1 and Gamescope 3.16.29. The validation report has the full setup.
I checked Wayland output names against presentation feedback to verify that Gamescope presented on DP-1 at 1440p330 with VRR selected. I also confirmed that the rotating cube was visible on the gaming LG.
| Exit condition | Saved desktop restored |
|---|---|
| Normal Gamescope exit | Yes |
Gamescope killed with SIGKILL | Yes |
Watcher killed with SIGKILL, followed by systemd cleanup | Yes |
The restored modes, refresh-rate mode, layout, scaling, transforms, primary display and color settings matched the snapshot in all three cases.
The 67 hardware-free tests and linters also passed on Fedora 45 and stock Ubuntu 24.04. They cover rollback, locking, command failures and recovery snapshots. The Ubuntu checks are hardware-free; my desktop testing is on Fedora.
I haven’t live-tested launches starting in Dual Mode, multiple supported LGs or physical hotplug. Those paths have hardware-free coverage only. Gamescope’s documentation calls scripting “currently experimental and subject to change massively.”
Recovery and uninstall
If automatic restoration fails, I can reapply the saved monitor and display settings with the same file. Close managed Gamescope sessions before running it:
| |
The snapshot stays at $XDG_RUNTIME_DIR/gamescope-lg-dual-mode/session.gv if restoration fails. If the connected monitors have changed, the script refuses to replace the layout instead of silently removing a newly connected display.
The watcher logs to my user journal:
| |
To uninstall:
| |
Uninstall removes only its own inactive copy. It refuses symlinks and unrelated files, and keeps recovery snapshots.
FAQ
Will this work on any 5K LG monitor?
I’ve only tested the 27GM950B, and that’s the only enabled profile. The script matches GSM / 0x5cf8, not a generic LG name or my serial. Other models need their own profiles and hardware tests for their modes and firmware.
Does it preserve HDR?
I haven’t tested HDR rendering. The script saves and restores GNOME’s color-mode settings.