Closing/opening lid will toggle internal monitor on/off

This commit is contained in:
David Heinemeier Hansson
2026-04-19 17:34:34 +02:00
parent fa48d2398b
commit 2b323459df
7 changed files with 38 additions and 18 deletions
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
# Disable the internal laptop display. No-op if already disabled or if it
# would leave no active display.
if omarchy-hyprland-monitors-many; then
if omarchy-hyprland-toggle-disabled internal-monitor-disable; then
omarchy-hyprland-toggle internal-monitor-disable --enabled-notification "󰍹 Internal display off"
fi
else
notify-send -u low "󰍹 Can't disable the only active display"
exit 1
fi
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
# Enable the internal laptop display. No-op if already enabled.
if omarchy-hyprland-toggle-enabled internal-monitor-disable; then
omarchy-hyprland-toggle internal-monitor-disable --disabled-notification "󰍹 Internal display on"
fi
@@ -4,11 +4,6 @@
# 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
if omarchy-hyprland-monitors-none && omarchy-hyprland-toggle-enabled internal-monitor-disable; then
omarchy-hyprland-monitor-internal-enable
fi
+4 -11
View File
@@ -2,15 +2,8 @@
# Toggle the internal laptop display on/off.
if omarchy-hyprland-toggle-disabled internal-monitor-disable; then
ACTIVE_COUNT=$(hyprctl monitors -j | jq 'length')
if [[ $ACTIVE_COUNT -le 1 ]]; then
notify-send -u low "󰍹 Can't disable the only active display"
exit 1
fi
if omarchy-hyprland-toggle-enabled internal-monitor-disable; then
omarchy-hyprland-monitor-internal-enable
else
omarchy-hyprland-monitor-internal-disable
fi
omarchy-hyprland-toggle \
--enabled-notification "󰍹 Internal display off" \
--disabled-notification "󰍹 Internal display on" \
internal-monitor-disable
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash
# Returns true when there are multiple monitors connected (so we can disable the internal one)
(( $(hyprctl monitors -j 2>/dev/null | jq length) > 1 ))
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash
# Returns true when no monitors are connected
(( $(hyprctl monitors -j 2>/dev/null | jq length) == 0 ))
+2
View File
@@ -29,6 +29,8 @@ bindd = SUPER SHIFT ALT, COMMA, Restore last notification, exec, makoctl restore
bindd = SUPER CTRL, I, Toggle locking on idle, exec, omarchy-toggle-idle
bindd = SUPER CTRL, N, Toggle nightlight, exec, omarchy-toggle-nightlight
bindd = SUPER CTRL, Delete, Toggle laptop display, exec, omarchy-hyprland-monitor-internal-toggle
bindl = , switch:on:Lid Switch, exec, omarchy-hyprland-monitor-internal-disable
bindl = , switch:off:Lid Switch, exec, omarchy-hyprland-monitor-internal-enable
# Control Apple Display brightness
bindd = CTRL, F1, Apple Display brightness down, exec, omarchy-brightness-display-apple -5000