#!/bin/sh
# xdg-desktop-portal-wlr output chooser: prints the output to share (nothing = cancelled).
outs=$(wlr-randr --json 2>/dev/null | python3 -c 'import json,sys;print("\n".join(o["name"] for o in json.load(sys.stdin) if o.get("enabled")))' 2>/dev/null)
n=$(printf '%s\n' "$outs" | grep -c .)
if [ "$n" -eq 1 ]; then printf '%s\n' "$outs"; exit 0; fi
notify-send -a "Screen sharing" -i video-display -t 6000 "Choose a screen to share" "Click the screen you want to share. Press Esc to cancel." 2>/dev/null
exec slurp -f %o -or
