Skip to content

Instantly share code, notes, and snippets.

@edisionnano
Created May 15, 2022 20:47
Show Gist options
  • Save edisionnano/4cd912315ae4e309261147be23ed0dee to your computer and use it in GitHub Desktop.
Save edisionnano/4cd912315ae4e309261147be23ed0dee to your computer and use it in GitHub Desktop.
Screenshare on Discord with sound on a Steam Deck
#!/usr/bin/env bash
#Download the binary if it doesn't exist
if [ ! -f /home/${USER}/.local/bin/virtmic ]; then
mkdir -p /home/${USER}/.local/bin
curl https://raw.githubusercontent.com/edisionnano/Screenshare-with-audio-on-Discord-with-Linux/main/virtmic_steamdeck > /home/${USER}/.local/bin/virtmic
chmod +x /home/${USER}/.local/bin/virtmic
fi
#Kill it if it's running
killall -9 virtmic 2>/dev/null
NODES=`pw-dump Node|grep application.name|awk '!seen[$0]++'|grep -oP '(?<="application.name": ").*(?=",)'|sed 's/\(^\|$\)/"/g'|awk -vRS="\n" -vORS=" FALSE " '1'`
#Terminate the script if the NODES var is empty
if [ -z "$NODES" ]
then
zenity --error --text="No app or game is playing audio!" --title="Error" --width=500 --width=200
exit 1
fi
OPTIONS='--list --title "Pick one choice" --text "Pick a game or application to share: " --radiolist --column "Pick" --column "App/Game name" TRUE '
SIZE=' --height=250 --width=300'
RES=`eval zenity $OPTIONS ${NODES:0:-7} $SIZE`
#Terminate the script if the RES var is empty as the user didn't pick anything
if [ -z "$RES" ]
then
zenity --info --text="No app or game will be shared." --title="Info" --width=500 --width=200
exit 0
fi
#Pass the node.name to virtmic
yes $RES|/home/${USER}/.local/bin/virtmic&
PID=$!
RET=`zenity --progress --pulsate --text="Sharing $RES"`
if $RET; then
kill $PID 2>/dev/null
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment