From cd3e683fefdffc497131d23dd1185174673d9e6f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 22 Apr 2026 13:35:20 +0200 Subject: [PATCH] Combine into one script with options --- bin/omarchy-hyprland-monitor-internal | 37 +++++++++++++++++++ bin/omarchy-hyprland-monitor-internal-disable | 13 ------- bin/omarchy-hyprland-monitor-internal-enable | 7 ---- bin/omarchy-hyprland-monitor-internal-recover | 9 ----- bin/omarchy-hyprland-monitor-internal-toggle | 9 ----- bin/omarchy-hyprland-monitor-watch | 2 +- bin/omarchy-menu | 2 +- default/hypr/autostart.conf | 2 +- default/hypr/bindings/utilities.conf | 6 +-- 9 files changed, 43 insertions(+), 44 deletions(-) create mode 100755 bin/omarchy-hyprland-monitor-internal delete mode 100755 bin/omarchy-hyprland-monitor-internal-disable delete mode 100755 bin/omarchy-hyprland-monitor-internal-enable delete mode 100755 bin/omarchy-hyprland-monitor-internal-recover delete mode 100755 bin/omarchy-hyprland-monitor-internal-toggle diff --git a/bin/omarchy-hyprland-monitor-internal b/bin/omarchy-hyprland-monitor-internal new file mode 100755 index 00000000..74e6f491 --- /dev/null +++ b/bin/omarchy-hyprland-monitor-internal @@ -0,0 +1,37 @@ +#!/bin/bash + +TOGGLE="internal-monitor-disable" + +enable() { + if omarchy-hyprland-toggle-enabled "$TOGGLE"; then + omarchy-hyprland-toggle --disabled-notification "󰍹 Laptop display enabled" "$TOGGLE" + fi +} + +disable() { + if omarchy-hyprland-monitors-many; then + if omarchy-hyprland-toggle-disabled "$TOGGLE"; then + omarchy-hyprland-toggle --enabled-notification "󰍹 Laptop display disabled" "$TOGGLE" + fi + else + notify-send -u low "󰍹 Can't disable the only active display" + exit 1 + fi +} + +recover() { + if omarchy-hyprland-monitors-none && omarchy-hyprland-toggle-enabled "$TOGGLE"; then + enable + fi +} + +case "$1" in + on) enable ;; + off) disable ;; + toggle) if omarchy-hyprland-toggle-enabled "$TOGGLE"; then enable; else disable; fi ;; + recover) recover ;; + *) + echo "Usage: $(basename "$0") {on|off|toggle|recover}" >&2 + exit 1 + ;; +esac diff --git a/bin/omarchy-hyprland-monitor-internal-disable b/bin/omarchy-hyprland-monitor-internal-disable deleted file mode 100755 index 55ae0faf..00000000 --- a/bin/omarchy-hyprland-monitor-internal-disable +++ /dev/null @@ -1,13 +0,0 @@ -#!/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 --enabled-notification "󰍹 Laptop display disabled" internal-monitor-disable - fi -else - notify-send -u low "󰍹 Can't disable the only active display" - exit 1 -fi diff --git a/bin/omarchy-hyprland-monitor-internal-enable b/bin/omarchy-hyprland-monitor-internal-enable deleted file mode 100755 index 8f90b30e..00000000 --- a/bin/omarchy-hyprland-monitor-internal-enable +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# Enable the internal laptop display. No-op if already enabled. - -if omarchy-hyprland-toggle-enabled internal-monitor-disable; then - omarchy-hyprland-toggle --disabled-notification "󰍹 Laptop display enabled" internal-monitor-disable -fi diff --git a/bin/omarchy-hyprland-monitor-internal-recover b/bin/omarchy-hyprland-monitor-internal-recover deleted file mode 100755 index 41a81d4f..00000000 --- a/bin/omarchy-hyprland-monitor-internal-recover +++ /dev/null @@ -1,9 +0,0 @@ -#!/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-monitors-none && omarchy-hyprland-toggle-enabled internal-monitor-disable; then - omarchy-hyprland-monitor-internal-enable -fi diff --git a/bin/omarchy-hyprland-monitor-internal-toggle b/bin/omarchy-hyprland-monitor-internal-toggle deleted file mode 100755 index 61316ce0..00000000 --- a/bin/omarchy-hyprland-monitor-internal-toggle +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# Toggle the internal laptop display on/off. - -if omarchy-hyprland-toggle-enabled internal-monitor-disable; then - omarchy-hyprland-monitor-internal-enable -else - omarchy-hyprland-monitor-internal-disable -fi diff --git a/bin/omarchy-hyprland-monitor-watch b/bin/omarchy-hyprland-monitor-watch index 0dce58cb..470bf3de 100755 --- a/bin/omarchy-hyprland-monitor-watch +++ b/bin/omarchy-hyprland-monitor-watch @@ -8,7 +8,7 @@ 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 + omarchy-hyprland-monitor-internal recover ;; esac done diff --git a/bin/omarchy-menu b/bin/omarchy-menu index 25cf71c2..4d524497 100755 --- a/bin/omarchy-menu +++ b/bin/omarchy-menu @@ -184,7 +184,7 @@ show_toggle_menu() { *Ratio*) omarchy-hyprland-window-single-square-aspect-toggle ;; *Gaps*) omarchy-hyprland-window-gaps-toggle ;; *Scaling*) omarchy-hyprland-monitor-scaling-cycle ;; - *Laptop*) omarchy-hyprland-monitor-internal-toggle ;; + *Laptop*) omarchy-hyprland-monitor-internal toggle ;; *Touchpad*) omarchy-toggle-touchpad ;; *) back_to show_trigger_menu ;; esac diff --git a/default/hypr/autostart.conf b/default/hypr/autostart.conf index f4a2f392..f34aa49f 100644 --- a/default/hypr/autostart.conf +++ b/default/hypr/autostart.conf @@ -7,7 +7,7 @@ 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 = omarchy-hyprland-monitor-internal recover exec-once = uwsm-app -- omarchy-hyprland-monitor-watch # Slow app launch fix -- set systemd vars diff --git a/default/hypr/bindings/utilities.conf b/default/hypr/bindings/utilities.conf index e3256a6e..70730368 100644 --- a/default/hypr/bindings/utilities.conf +++ b/default/hypr/bindings/utilities.conf @@ -28,9 +28,9 @@ bindd = SUPER SHIFT ALT, COMMA, Restore last notification, exec, makoctl restore # Toggles 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 +bindd = SUPER CTRL, Delete, Toggle laptop display, exec, omarchy-hyprland-monitor-internal toggle +bindl = , switch:on:Lid Switch, exec, omarchy-hyprland-monitor-internal off +bindl = , switch:off:Lid Switch, exec, omarchy-hyprland-monitor-internal on # Control Apple Display brightness bindd = CTRL, F1, Apple Display brightness down, exec, omarchy-brightness-display-apple -5000