From a74afeb4e5aae89393318d32bcac40804ce0a8ba Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 23 Apr 2026 11:54:11 +0200 Subject: [PATCH] Switch to an earlier recovery for the internal monitor on reboot --- bin/omarchy-cmd-first-run | 1 + bin/omarchy-hw-recover-internal-monitor | 11 +++++++++++ .../user/omarchy-recover-internal-monitor.service | 11 +++++++++++ default/hypr/autostart.conf | 1 - install/first-run/recover-internal-monitor.sh | 1 + migrations/1776935686.sh | 9 +++++++++ 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 bin/omarchy-hw-recover-internal-monitor create mode 100644 config/systemd/user/omarchy-recover-internal-monitor.service create mode 100644 install/first-run/recover-internal-monitor.sh create mode 100644 migrations/1776935686.sh diff --git a/bin/omarchy-cmd-first-run b/bin/omarchy-cmd-first-run index 830bef54..67a0c321 100755 --- a/bin/omarchy-cmd-first-run +++ b/bin/omarchy-cmd-first-run @@ -10,6 +10,7 @@ if [[ -f $FIRST_RUN_MODE ]]; then rm -f "$FIRST_RUN_MODE" bash "$OMARCHY_PATH/install/first-run/battery-monitor.sh" + bash "$OMARCHY_PATH/install/first-run/recover-internal-monitor.sh" bash "$OMARCHY_PATH/install/first-run/cleanup-reboot-sudoers.sh" bash "$OMARCHY_PATH/install/first-run/firewall.sh" bash "$OMARCHY_PATH/install/first-run/dns-resolver.sh" diff --git a/bin/omarchy-hw-recover-internal-monitor b/bin/omarchy-hw-recover-internal-monitor new file mode 100755 index 00000000..794cafea --- /dev/null +++ b/bin/omarchy-hw-recover-internal-monitor @@ -0,0 +1,11 @@ +#!/bin/bash + +# Clear the internal-monitor-disable toggle if no external display is connected. +# Runs before the graphical session so Hyprland doesn't block on having no output +# to render to when the user rebooted with the external unplugged. + +TOGGLE="$HOME/.local/state/omarchy/toggles/hypr/internal-monitor-disable.conf" + +if [[ -f $TOGGLE ]] && ! omarchy-hw-external-monitors; then + rm -f "$TOGGLE" +fi diff --git a/config/systemd/user/omarchy-recover-internal-monitor.service b/config/systemd/user/omarchy-recover-internal-monitor.service new file mode 100644 index 00000000..fef52180 --- /dev/null +++ b/config/systemd/user/omarchy-recover-internal-monitor.service @@ -0,0 +1,11 @@ +[Unit] +Description=Recover the internal monitor toggle when no external display is connected +Before=graphical-session-pre.target +ConditionPathExists=%h/.local/state/omarchy/toggles/hypr/internal-monitor-disable.conf + +[Service] +Type=oneshot +ExecStart=%h/.local/share/omarchy/bin/omarchy-hw-recover-internal-monitor + +[Install] +WantedBy=graphical-session-pre.target diff --git a/default/hypr/autostart.conf b/default/hypr/autostart.conf index f34aa49f..984b55a3 100644 --- a/default/hypr/autostart.conf +++ b/default/hypr/autostart.conf @@ -7,7 +7,6 @@ exec-once = uwsm-app -- swayosd-server exec-once = /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 exec-once = omarchy-cmd-first-run exec-once = omarchy-powerprofiles-init -exec-once = omarchy-hyprland-monitor-internal recover exec-once = uwsm-app -- omarchy-hyprland-monitor-watch # Slow app launch fix -- set systemd vars diff --git a/install/first-run/recover-internal-monitor.sh b/install/first-run/recover-internal-monitor.sh new file mode 100644 index 00000000..c1e84fc0 --- /dev/null +++ b/install/first-run/recover-internal-monitor.sh @@ -0,0 +1 @@ +systemctl --user enable omarchy-recover-internal-monitor.service diff --git a/migrations/1776935686.sh b/migrations/1776935686.sh new file mode 100644 index 00000000..303db7b8 --- /dev/null +++ b/migrations/1776935686.sh @@ -0,0 +1,9 @@ +echo "Recover the internal monitor at login when no external display is connected" + +SERVICE=omarchy-recover-internal-monitor.service + +mkdir -p ~/.config/systemd/user +cp $OMARCHY_PATH/config/systemd/user/$SERVICE ~/.config/systemd/user/$SERVICE + +systemctl --user daemon-reload +systemctl --user enable $SERVICE