#!/usr/bin/env bash # Toggle: mirror the internal display to the first connected external monitor. # Travel use case — plug into a conference room TV/projector via HDMI, press # the bound key, and the external mirrors the laptop. Press again to revert # to the host's default monitor layout (via hyprctl reload). set -u internal="eDP-1" external=$(hyprctl monitors -j | jq -r ".[] | select(.name != \"$internal\") | .name" | head -n1) if [[ -z "$external" ]]; then notify-send "Mirror" "No external display connected" exit 0 fi mirror_of=$(hyprctl monitors -j | jq -r ".[] | select(.name == \"$external\") | .mirrorOf // \"\"") if [[ -n "$mirror_of" ]]; then hyprctl reload notify-send "Mirror" "Off — reverted to default layout" else hyprctl keyword monitor "$external,preferred,auto,1,mirror,$internal" notify-send "Mirror" "On — $internal → $external" fi