Advertisement
Guest User

steamlink.sh

a guest
May 1st, 2020
3,099
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.10 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Script to launch the Steam Link app on Raspberry Pi
  4.  
  5. TOP=$(cd "$(dirname "$0")" && pwd)
  6.  
  7. # Set up the temporary directory
  8. export TMPDIR="$TOP/.tmp"
  9. rm -rf "$TMPDIR"
  10. mkdir -p "$TMPDIR"
  11.  
  12. # Restore the display when we're done
  13. cleanup()
  14. {
  15.     pulseaudio -k
  16.     kill $CEC_PID 2>/dev/null
  17.     screenblank -k
  18. }
  19. trap cleanup 2 3 15
  20.  
  21. # stop kodi
  22. if [ ! -z "$(pidof kodi.bin)" ]; then
  23.     echo 'stopping kodi'
  24.     systemctl stop kodi
  25. fi
  26.  
  27. # setup udev
  28. #if [ ! -f /lib/udev/rules.d/60-steam-input.rules ]; then
  29. if [ ! -f /lib/udev/rules.d/56-steamlink.rules ]; then
  30.     echo 'adding udev overlay'
  31.     mount -t overlay overlay -o lowerdir=/lib/udev/rules.d,upperdir=/storage/steamlink/udev/rules.d/,workdir=/storage/steamlink/overlay_work /lib/udev/rules.d
  32.     udevadm trigger
  33. fi
  34.  
  35. # Run the shell application and launch streaming
  36. QT_VERSION=5.14.1
  37. export HOME="/storage"
  38. export PATH="$TOP/bin:$PATH"
  39. export QTDIR="$TOP/Qt-$QT_VERSION"
  40. export QT_PLUGIN_PATH="$QTDIR/plugins"
  41. #export QT_QPA_PLATFORM="eglfs"
  42. #export QT_QPA_PLATFORM_PLUGIN_PATH="$QT_PLUGIN_PATH/platforms"
  43. export LD_LIBRARY_PATH="$TOP/lib:$QTDIR/lib:$LD_LIBRARY_PATH"
  44. #export LD_LIBRARY_PATH="$QTDIR/lib:$TOP/lib:$LD_LIBRARY_PATH"
  45. export SDL_GAMECONTROLLERCONFIG_FILE="${XDG_DATA_HOME:-$HOME/.local/share}/Valve Corporation/SteamLink/controller_map.txt"
  46. #export SDL_GAMECONTROLLERCONFIG_FILE="$TOP/SteamLinkcontroller_map.txt"
  47.  
  48. QPLATFORM="eglfs"
  49. export QT_QPA_EGLFS_FORCE888=1
  50.  
  51. echo 'starting pulseaudio'
  52. pulseaudio -k 2>/dev/null
  53. cat /etc/pulse/default.pa | sed 's/^\(load-module module-udev-detect\|load-module module-detect\)/\1 tsched=0/' > /storage/steamlink/pulse_default.pa
  54. pulseaudio -D -n -F "$TOP/pulse_default.pa"
  55.  
  56. echo 'starting cec'
  57. cec-client </dev/null | steamlink-cec &
  58. CEC_PID="$(jobs -p) $!"
  59.  
  60. echo 'starting steamlink'
  61. while true; do
  62.     shell -platform "$QPLATFORM" "$@"
  63.  
  64.     # See if the shell wanted to launch anything
  65.     cmdline_file="$TMPDIR/launch_cmdline.txt"
  66.     if [ -f "$cmdline_file" ]; then
  67.         cmd=`cat "$cmdline_file"`
  68.         eval $cmd
  69.         rm -f "$cmdline_file"
  70.     else
  71.         # We're all done...
  72.         break
  73.     fi
  74. done
  75.  
  76. cleanup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement