Skip to content

Add monitor auto-configuration#4835

Open
dlsvob wants to merge 1 commit intobasecamp:devfrom
dlsvob:monitor-autoconfig
Open

Add monitor auto-configuration#4835
dlsvob wants to merge 1 commit intobasecamp:devfrom
dlsvob:monitor-autoconfig

Conversation

@dlsvob
Copy link
Copy Markdown

@dlsvob dlsvob commented Mar 1, 2026

Summary

When an unknown monitor is plugged in, Hyprland's fallback rule (monitor=,preferred,auto,auto) picks a reasonable mode and scale — but that choice isn't persisted. Next time the same monitor appears, Hyprland starts fresh.

This PR adds a background script (omarchy-monitor-autoconfig) that:

  • On startup: scans all connected monitors, adds desc: entries for any not already in monitors.conf
  • On hotplug: listens for monitoradded events via socat on Hyprland's socket2, then captures and saves the new monitor's settings
  • Falls back to polling every 5s if socat isn't available

For each detected monitor, the script:

  1. Skips eDP-1 (laptop panel — always manually configured)
  2. Skips disabled monitors and those with empty make/model
  3. Builds a desc: prefix from make + model (no serial, so it matches any unit of that model)
  4. Checks if monitors.conf already has a matching desc: entry — if so, skips
  5. Reads current width, height, refreshRate, and scale from hyprctl monitors -j
  6. Inserts a new entry before the fallback rule in monitors.conf
  7. Sends a desktop notification via notify-send

Position is always auto — users can manually set positions later.

Changes

File Change
bin/omarchy-monitor-autoconfig New script
default/hypr/autostart.conf Added exec-once
install/omarchy-base.packages Added socat
migrations/1772362507.sh Installs socat for existing users

Test plan

  • Fresh install: verify the script launches on login and doesn't add entries for monitors that don't exist
  • Existing monitors: verify already-configured monitors are recognized and skipped (no duplicates)
  • Hotplug: plug in a new/unknown monitor → expect notification and new desc: entry in monitors.conf
  • No socat: uninstall socat, restart script → verify it falls back to polling mode
  • Laptop skip: verify eDP-1 is always skipped regardless of state

🤖 Generated with Claude Code

When an unknown monitor is plugged in, Hyprland's fallback rule picks
a reasonable mode and scale but doesn't persist the choice. This adds
a background script that captures those settings and writes desc:-based
entries into monitors.conf, so every monitor becomes "known" after its
first connection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 1, 2026 11:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an automatic monitor configuration persistence mechanism for Hyprland by introducing a background script that records Hyprland’s chosen mode/scale for newly-seen monitors into ~/.config/hypr/monitors.conf, and wires it into startup/hotplug handling.

Changes:

  • Add omarchy-monitor-autoconfig script to detect unknown monitors and write monitor=desc:... rules.
  • Start the script on login via Hyprland exec-once.
  • Ensure socat is installed (base packages + migration) for event-driven hotplug detection with a polling fallback.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
bin/omarchy-monitor-autoconfig Implements monitor scanning, config insertion, and socat/polling hotplug detection.
default/hypr/autostart.conf Launches the new autoconfig script at session start.
install/omarchy-base.packages Adds socat to the base install set.
migrations/1772362507.sh Installs socat for existing users.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread migrations/1772362507.sh

# Install socat if not already present (needed for event-driven hotplug detection)
if ! command -v socat &>/dev/null; then
sudo pacman -S --noconfirm socat
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with other migrations that install packages, consider adding --needed to the pacman -S invocation so reruns don’t attempt reinstalls (even though you already gate on command -v).

Suggested change
sudo pacman -S --noconfirm socat
sudo pacman -S --needed --noconfirm socat

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants