Ensure internal display is turned back on if the external one is disconnected

This commit is contained in:
David Heinemeier Hansson
2026-04-19 17:11:48 +02:00
parent bdead4a3d1
commit d6aaf30e43
5 changed files with 33 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
# Re-enable the internal display if it was toggled off and no external monitors
# are currently active (e.g. external got disconnected live, during sleep, or
# wasn't present on boot).
if omarchy-hyprland-toggle-enabled internal-monitor-disable; then
ACTIVE_COUNT=$(hyprctl monitors -j 2>/dev/null | jq 'length')
if [[ ${ACTIVE_COUNT:-0} -eq 0 ]]; then
omarchy-hyprland-toggle \
--disabled-notification "󰍹 Internal display restored (no external connected)" \
internal-monitor-disable
fi
fi
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
# Listen on Hyprland's event socket and recover the internal display whenever
# a monitor is removed.
SOCKET="$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock"
socat -U - "UNIX-CONNECT:$SOCKET" | while read -r event; do
case "$event" in
monitorremoved\>\>*|monitorremovedv2\>\>*)
omarchy-hyprland-monitor-internal-recover
;;
esac
done
+2
View File
@@ -7,6 +7,8 @@ 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
exec-once = systemctl --user import-environment $(env | cut -d'=' -f 1)
+1
View File
@@ -112,6 +112,7 @@ sddm
signal-desktop
slurp
spotify
socat
starship
sushi
swaybg
+2
View File
@@ -0,0 +1,2 @@
echo "Install socat for the Hyprland monitor event watcher"
omarchy-pkg-add socat