Name: sl-display-mirror Version: 1.0.0 Release: 1%{?dist} Summary: Smart multi-display mirroring script for Niri License: MIT URL: https://slsrepo.com BuildArch: noarch Requires: bash Requires: niri Requires: jq Requires: wl-mirror Requires: fuzzel Requires: util-linux Requires: procps-ng %description Smart multi-display mirroring script for Niri. %prep # No external source. Script is generated from the spec, matching the Arch PKGBUILD. %build cat > sl-display-mirror <<'EOF' #!/usr/bin/env bash # Toggle Switch if pgrep -x "wl-mirror" >/dev/null; then killall -q wl-mirror exit 0 fi # Clean Niri's temporary sockets unset WAYLAND_SOCKET unset XDG_ACTIVATION_TOKEN unset DESKTOP_STARTUP_ID # Identify displays dynamically SOURCE=$(niri msg --json focused-output | jq -r .name) # Read all other outputs into an array mapfile -t EXTERNAL_DISPLAYS < <(niri msg --json outputs | jq -r --arg src "$SOURCE" 'keys[] | select(. != $src)') NUM_EXT=${#EXTERNAL_DISPLAYS[@]} TARGETS=() if [ "$NUM_EXT" -eq 0 ]; then echo "FAILED: No external display detected." exit 1 elif [ "$NUM_EXT" -eq 1 ]; then # Exactly one external display, skip the menu TARGETS=("${EXTERNAL_DISPLAYS[0]}") else # Loop to allow selecting multiple monitors with Fuzzel AVAILABLE=("${EXTERNAL_DISPLAYS[@]}") while [ ${#AVAILABLE[@]} -gt 0 ]; do # Add "Done" to the top of the list CHOICE=$(printf "%%s\n" "Done" "${AVAILABLE[@]}" | fuzzel --dmenu -p 'Mirror to (Select Done to finish):') # Exit the loop if the user hits escape, closes the menu, or selects "Done" if [[ -z "$CHOICE" || "$CHOICE" == "Done" ]]; then break fi # Add selection to targets TARGETS+=("$CHOICE") # Remove the chosen display from the available list so it can't be picked twice NEW_AVAILABLE=() for disp in "${AVAILABLE[@]}"; do if [[ "$disp" != "$CHOICE" ]]; then NEW_AVAILABLE+=("$disp") fi done AVAILABLE=("${NEW_AVAILABLE[@]}") done fi # If user cancelled out of the menu without picking anything, exit gracefully if [ ${#TARGETS[@]} -eq 0 ]; then echo "No displays selected. Exiting." exit 0 fi # Loop through targets and launch wl-mirror for TARGET in "${TARGETS[@]}"; do niri msg action focus-monitor "$TARGET" script -q -c "wl-mirror -S $SOURCE" /dev/null & sleep 0.3 done # Return the mouse cursor back to the original display niri msg action focus-monitor "$SOURCE" # Keep the script alive for the toggle switch wait EOF %install install -Dm755 sl-display-mirror %{buildroot}%{_bindir}/sl-display-mirror %files %{_bindir}/sl-display-mirror %changelog * Sat Jun 20 2026 Sl (Shahaf Levi) - 1.0.0-1 - Initial COPR package for Slash