Skip to content

Instantly share code, notes, and snippets.

@fabienjuif
Created May 16, 2025 11:07
Show Gist options
  • Select an option

  • Save fabienjuif/9c543bd238262f87caf3a9c219edf737 to your computer and use it in GitHub Desktop.

Select an option

Save fabienjuif/9c543bd238262f87caf3a9c219edf737 to your computer and use it in GitHub Desktop.
sharescreen.sh / wayland | sway
#!/bin/bash
# for this to works you need to recompile xdg-desktop-portal-wlr with the following patch:
# - https://github.com/emersion/xdg-desktop-portal-wlr/pull/156/files
# - packaged for void with https://github.com/emersion/xdg-desktop-portal-wlr/pull/156/files
CONFIG="${HOME}/.config/xdg-desktop-portal-wlr/config"
function usage() {
echo "Usage: $0 - Configure xdg-desktop-portal-wlr to share the whole screen"
echo "Usage: $0 region - Configure xdg-desktop-portal-wlr to share a region of the screen"
exit 1
}
MODE=fullscreen
if [[ ${#} -gt 0 ]]; then
MODE=${1}
if [[ ${#} -gt 1 ]]; then
usage
fi
if [[ ${1} != "region" ]]; then
usage
fi
fi
sed -i '/^region=/d' ${CONFIG}
if [[ "${MODE}" == "region" ]]; then
[ -n "$(tail -c1 ${CONFIG})" ] && echo >> ${CONFIG}
region=$(slurp)
sed -i "\$ a region=${region// /:}" "${CONFIG}"
fi
/usr/libexec/xdg-desktop-portal-wlr -r &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment