Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

monitor-hotplug

Automatically reconfigure X11 displays when a monitor is plugged in or unplugged.

A udev rule watches for DRM hotplug events (monitor connected/disconnected) and runs a script that re-applies the X11 layout with xrandr: every connected output is enabled (--auto), every disconnected output is turned off. Handy for laptops and docked machines where the display arrangement changes frequently.

Files

  • monitor-hotplug.sh — finds the running X server (DISPLAY/XAUTHORITY), queries xrandr --verbose for output states, and enables/disables outputs accordingly. Logs to syslog (logger -t monitor-hotplug.sh).
  • 99-monitor-hotplug.rules — udev rule that triggers the script on ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1".

Setup

  1. Install the script and make it executable:

    sudo install -m 755 monitor-hotplug.sh /usr/local/bin/monitor-hotplug.sh
  2. Install the udev rule:

    sudo cp 99-monitor-hotplug.rules /etc/udev/rules.d/99-monitor-hotplug.rules
  3. Reload udev rules:

    sudo udevadm control --reload-rules

Plug in or unplug a monitor — the layout updates after a short delay (the script sleeps 3s to let the EDID settle). Check journalctl -t monitor-hotplug.sh to see what the script did.

Requirements

  • X11 (the script discovers the X server process to read its auth file; it does not work on pure Wayland sessions)
  • xrandr

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages