* Add check for active external monitors before disabling internal display Co-authored-by: Copilot <copilot@github.com> * Revert "Add check for active external monitors before disabling internal display" This reverts commit e20b3da87e3df0f084c0bca232a61ba58fab4cdc. * feat(hyprland): add toggle for internal monitor mirroring - Implement `omarchy-hyprland-monitor-internal-mirror` to dynamically mirror the internal eDP display to external monitor. - Update `omarchy-hyprland-monitor-internal` to prevent disabling the laptop screen if mirroring is currently active. - Add "Mirror Display" toggle to omarchy hardware Menu * Ensure there is also a laptop monitor available to mirror before we do it * Fix toggle use * Recover from mirror mode gracefully * Add hotkey to mirroring --------- Co-authored-by: Copilot <copilot@github.com> Co-authored-by: David Heinemeier Hansson <david@hey.com>
56 lines
1.5 KiB
Bash
Executable File
56 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
TOGGLE="internal-monitor-mirror"
|
|
TOGGLE_FLAG="$HOME/.local/state/omarchy/toggles/hypr/$TOGGLE.conf"
|
|
DISABLE_TOGGLE="internal-monitor-disable"
|
|
|
|
# Get names dynamically
|
|
INTERNAL=$(hyprctl monitors -j | jq -r '.[] | select(.name | contains("eDP")).name' | head -n 1)
|
|
# Get the first available external monitor
|
|
EXTERNAL=$(hyprctl monitors -j | jq -r '.[] | select(.name | contains("eDP") | not).name' | head -n 1)
|
|
|
|
enable() {
|
|
if [[ -z "$EXTERNAL" ]]; then
|
|
notify-send -u low " No external monitors found for mirror"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "$INTERNAL" ]]; then
|
|
notify-send -u low " No laptop monitor found to mirror"
|
|
exit 1
|
|
fi
|
|
|
|
if omarchy-hyprland-toggle-enabled "$DISABLE_TOGGLE"; then
|
|
omarchy-hyprland-toggle "$DISABLE_TOGGLE"
|
|
fi
|
|
|
|
if omarchy-hyprland-toggle-disabled "$TOGGLE"; then
|
|
echo "monitor=$EXTERNAL, preferred, auto, 1, mirror, $INTERNAL" > "$TOGGLE_FLAG"
|
|
notify-send -u low " Mirroring enabled ($EXTERNAL)"
|
|
hyprctl reload
|
|
fi
|
|
}
|
|
|
|
disable() {
|
|
if omarchy-hyprland-toggle-enabled "$TOGGLE"; then
|
|
omarchy-hyprland-toggle --disabled-notification " Extended mode restored" "$TOGGLE"
|
|
fi
|
|
}
|
|
|
|
recover() {
|
|
if ! omarchy-hw-external-monitors && omarchy-hyprland-toggle-enabled "$TOGGLE"; then
|
|
omarchy-hyprland-toggle "$TOGGLE"
|
|
fi
|
|
}
|
|
|
|
case "$1" in
|
|
on) enable ;;
|
|
off) disable ;;
|
|
toggle) if omarchy-hyprland-toggle-enabled "$TOGGLE"; then disable; else enable; fi ;;
|
|
recover) recover ;;
|
|
*)
|
|
echo "Usage: $(basename "$0") {on|off|toggle|recover}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|