Files
desktop/modules/hdmi-relink/default.nix
T
illustris 3fcf3c9c57 add Hyprland desktop with XMonad-style layouts
Manage the desktop through native Lua and UWSM with Grid, Monocle, Tabs and Scrolling layouts. Add workspace-local navigation, bounded scrolling focus and a runtime Grid ratio defaulting to 1.20.

Configure the HDR OLED and portrait LG, HDMI recovery, NVIDIA suspend handling, independent locking and Plasma fallback. Fix Waybar workspace IPC and provide immediate per-output layout status.

Include desktop controls, screenshots, usage documentation and controller/panel regression tests. Use the authorized local illustris flake input.
2026-10-04 09:43:45 +05:30

53 lines
2.5 KiB
Nix

# Re-initialise the HDMI-0 TMDS link after every wake.
#
# A DPMS off/on cycle on its own leaves the LG's link untrained: the CRTC stays
# programmed and the panel keeps HPD asserted, so the driver never retries and
# the panel sits at "no signal" until the cable is replugged. Nothing queryable
# distinguishes that from a healthy link -- xrandr, the driver's display masks
# and /sys/class/drm all report fine either way, and X reports the target mode
# whether or not the panel actually locked -- so the link is re-initialised
# unconditionally on wake, and the only real check is looking at the panel.
#
# Recovery is an ascending pixel-clock ladder, not a single hop. The transmitter
# will not train straight to 4K60 (594MHz, against this port's 600MHz maximum);
# the panel lights up and drops again. It will climb: disable the CRTC, then
# 1080p @148.5MHz, then 4K30 @297MHz, then 4K60 @594MHz. The middle rung must be
# the slowest mode at the target resolution -- picking the fastest one below the
# target selects 593.41MHz, the 59.94Hz near-twin, and the climb does nothing.
#
# Wake is detected from the X screensaver idle counter, NOT a DPMS Off->On edge:
# user input resets the idle counter but not the power level, and whoever blanked
# the screen may restore the level before the next poll, so testing it on the
# edge races and never matches. The level is latched instead, as evidence that
# the panels slept at some point during the idle.
#
# Implemented as a binary speaking X11 directly rather than a shell loop around
# xset(1)/xrandr(1): the poll loop then spawns no processes at all, which keeps
# it out of execsnoop, and it never issues an xrandr --query, which on this
# driver forces a full DFP re-probe.
{ config, lib, pkgs, ... }:
let
hdmi-relink = pkgs.callPackage ./package.nix {};
in
{
# also exposed for running by hand after a manual layout change
environment.systemPackages = [ hdmi-relink ];
systemd.user.services.hdmi-relink = {
description = "Re-initialise HDMI-0 TMDS link on wake";
partOf = [ "plasma-workspace.target" ];
after = [ "plasma-workspace.target" ];
wantedBy = [ "plasma-workspace.target" ];
# Plasma exports DISPLAY and XAUTHORITY to the user manager.
unitConfig.ConditionEnvironment = "XDG_SESSION_TYPE=x11";
serviceConfig = {
# ExecStart, not `script`, so systemd execs the binary directly
# instead of wrapping it in a generated shell script
ExecStart = "${lib.getExe hdmi-relink} --watch";
Restart = "on-failure";
RestartSec = 5;
};
};
}