diff --git a/bin/omarchy-hw-lid-closed b/bin/omarchy-hw-lid-closed new file mode 100755 index 0000000000..8e03f9656f --- /dev/null +++ b/bin/omarchy-hw-lid-closed @@ -0,0 +1,11 @@ +#!/bin/bash + +# omarchy:summary=Returns true when the laptop lid is closed +# omarchy:hidden=true + +for state in /proc/acpi/button/lid/*/state; do + [[ -r $state ]] || continue + [[ $(< "$state") == *"closed"* ]] && exit 0 +done + +exit 1 diff --git a/bin/omarchy-hyprland-monitor-internal b/bin/omarchy-hyprland-monitor-internal index 6b72c2bd9f..6948928851 100755 --- a/bin/omarchy-hyprland-monitor-internal +++ b/bin/omarchy-hyprland-monitor-internal @@ -18,7 +18,7 @@ on() { } off() { - if ! omarchy-hw-external-monitors; then + if ! omarchy-hw-external-monitors && ! omarchy-hw-lid-closed; then omarchy-notification-send -g 󰍹 "Can't disable the only active display" exit 1 fi @@ -31,7 +31,7 @@ off() { } recover() { - if ! omarchy-hw-external-monitors && omarchy-hyprland-toggle-enabled $TOGGLE; then + if ! omarchy-hw-external-monitors && ! omarchy-hw-lid-closed && omarchy-hyprland-toggle-enabled $TOGGLE; then omarchy-hyprland-toggle $TOGGLE off fi } diff --git a/default/hypr/bindings/utilities.lua b/default/hypr/bindings/utilities.lua index e167256d63..c9cd1e6466 100644 --- a/default/hypr/bindings/utilities.lua +++ b/default/hypr/bindings/utilities.lua @@ -32,7 +32,7 @@ o.bind_toggle("SUPER + CTRL + I", "Toggle locking on idle", "idle") o.bind_toggle("SUPER + CTRL + N", "Toggle nightlight", "nightlight") o.bind("SUPER + CTRL + Delete", "Toggle laptop display", "omarchy-hyprland-monitor-internal toggle") o.bind("SUPER + CTRL + ALT + Delete", "Toggle laptop display mirroring", "omarchy-hyprland-monitor-internal-mirror toggle") -o.bind("switch:on:Lid Switch", nil, "omarchy-hw-external-monitors && omarchy-hyprland-monitor-internal off", { locked = true }) +o.bind("switch:on:Lid Switch", nil, "omarchy-hyprland-monitor-internal off", { locked = true }) o.bind("switch:off:Lid Switch", nil, "omarchy-hyprland-monitor-internal on", { locked = true }) o.bind("PRINT", "Screenshot", "omarchy-capture-screenshot")