#!/bin/bash # omarchy:summary=Enable, disable, toggle, or recover mirroring the internal display to an external monitor # omarchy:args= 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) on() { if [[ -z $EXTERNAL ]]; then omarchy-notification-send -g 󰍹 "No external monitors found for mirror" exit 1 fi if [[ -z $INTERNAL ]]; then omarchy-notification-send -g 󰍹 "No laptop monitor found to mirror" exit 1 fi omarchy-hyprland-toggle $DISABLE_TOGGLE off echo "monitor=$EXTERNAL, preferred, auto, 1, mirror, $INTERNAL" >"$TOGGLE_FLAG" omarchy-notification-send -g 󰍹 "Mirroring enabled ($EXTERNAL)" hyprctl reload } off() { if omarchy-hyprland-toggle-enabled $TOGGLE; then omarchy-hyprland-toggle $TOGGLE off omarchy-notification-send -g 󰍹 "Extended mode restored" fi } toggle() { if omarchy-hyprland-toggle-enabled $TOGGLE; then off else on fi } recover() { if ! omarchy-hw-external-monitors; then omarchy-hyprland-toggle $TOGGLE off fi } case "$1" in on) on ;; off) off ;; toggle) toggle ;; recover) recover ;; *) echo "Usage: $(basename "$0") {on|off|toggle|recover}" >&2 exit 1 ;; esac