Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions bin/omarchy-hyprland-monitor-internal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# omarchy:summary=Enable, disable, toggle, or recover the internal laptop display
# omarchy:args=<on|off|toggle|recover>
# omarchy:args=<on|off|toggle|recover|reapply>

TOGGLE="internal-monitor-disable"
TOGGLE_FLAG="$HOME/.local/state/omarchy/toggles/hypr/$TOGGLE.conf"
Expand Down Expand Up @@ -31,7 +31,14 @@ off() {
}

recover() {
if ! omarchy-hw-external-monitors; then
if omarchy-hyprland-toggle-enabled $TOGGLE; then
for i in {1..6}; do
if omarchy-hw-external-monitors; then
return
fi
sleep 0.5
done

omarchy-hyprland-toggle $TOGGLE off
fi
}
Expand All @@ -44,13 +51,20 @@ toggle() {
fi
}

reapply() {
if omarchy-hyprland-toggle-enabled $TOGGLE; then
hyprctl reload
fi
}

case "$1" in
on) on ;;
off) off ;;
toggle) toggle ;;
recover) recover ;;
reapply) reapply ;;
*)
echo "Usage: $(basename "$0") {on|off|toggle|recover}" >&2
echo "Usage: $(basename "$0") {on|off|toggle|recover|reapply}" >&2
exit 1
;;
esac
20 changes: 17 additions & 3 deletions bin/omarchy-hyprland-monitor-internal-mirror
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# omarchy:summary=Enable, disable, toggle, or recover mirroring the internal display to an external monitor
# omarchy:args=<on|off|toggle|recover>
# omarchy:args=<on|off|toggle|recover|reapply>

TOGGLE="internal-monitor-mirror"
TOGGLE_FLAG="$HOME/.local/state/omarchy/toggles/hypr/$TOGGLE.conf"
Expand Down Expand Up @@ -45,18 +45,32 @@ toggle() {
}

recover() {
if ! omarchy-hw-external-monitors; then
if omarchy-hyprland-toggle-enabled $TOGGLE; then
for i in {1..6}; do
if omarchy-hw-external-monitors; then
return
fi
sleep 0.5
done

omarchy-hyprland-toggle $TOGGLE off
fi
}

reapply() {
if omarchy-hyprland-toggle-enabled $TOGGLE; then
hyprctl reload
fi
}

case "$1" in
on) on ;;
off) off ;;
toggle) toggle ;;
recover) recover ;;
reapply) reapply ;;
*)
echo "Usage: $(basename "$0") {on|off|toggle|recover}" >&2
echo "Usage: $(basename "$0") {on|off|toggle|recover|reapply}" >&2
exit 1
;;
esac
12 changes: 8 additions & 4 deletions bin/omarchy-hyprland-monitor-watch
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ 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-mirror recover
;;
monitorremoved\>* | monitorremovedv2\>*)
omarchy-hyprland-monitor-internal recover
omarchy-hyprland-monitor-internal-mirror recover
;;
monitoradded\>* | monitoraddedv2\>*)
omarchy-hyprland-monitor-internal reapply
omarchy-hyprland-monitor-internal-mirror reapply
;;
esac
done