Skip to content

Instantly share code, notes, and snippets.

@lsde
Last active February 17, 2022 17:35
Show Gist options
  • Save lsde/e103f7e2ed3c9a6eac437ca94ce32a9a to your computer and use it in GitHub Desktop.
Save lsde/e103f7e2ed3c9a6eac437ca94ce32a9a to your computer and use it in GitHub Desktop.
Connect to TurboVNC server with sound over PulseAudio
#!/bin/bash
set -e
# Assuming VNC listens on :5911 and you have following in .vnc/xstartup.turbovnc or .profile :
# export PULSE_SERVER=127.0.0.1:4714
if [[ $# -eq 0 ]] ; then
ANSWER=$(zenity --forms --forms --title="Connect to VNC with sound" --text="Enter credentials" --add-entry="Hostname" --add-entry="Username")
HN=$(echo $ANSWER | cut -d '|' -f1)
UN=$(echo $ANSWER | cut -d '|' -f2)
ARGS="${HN} -l${UN}"
fi
PACTL_MODULE=$(pactl load-module module-native-protocol-tcp auth-ip-acl='::1;127.0.0.1')
ssh -N -L 59011:127.0.0.1:5911 -R 4714:127.0.0.1:4713 ${ARGS} $@ &
/opt/TurboVNC/bin/vncviewer 127.0.0.1:59011
pactl unload-module $PACTL_MODULE
kill $!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment