Advertisement
Guest User

steamlink.sh

a guest
Feb 24th, 2022
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.48 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 SDL_GAMECONTROLLERCONFIG_FILE="${XDG_DATA_HOME:-$HOME/.local/share}/Valve Corporation/SteamLink/controller_map.txt"
  45. #export SDL_GAMECONTROLLERCONFIG_FILE="$TOP/SteamLinkcontroller_map.txt"
  46.  
  47. export QT_QPA_PLATFORM="eglfs"
  48. #elif [ -f /opt/vc/lib/libbrcmGLESv2.so ]; then         # from steam launcher
  49. export QT_QPA_EGLFS_INTEGRATION=eglfs_brcm
  50. export QT_QPA_EGLFS_PRELOAD="/opt/vc/lib/libbrcmGLESv2.so"
  51. #
  52. export QT_QPA_EGLFS_FORCE888=1
  53. export QT_QPA_EGLFS_ALWAYS_SET_MODE=1
  54. #export QT_DEBUG_PLUGINS=1
  55.  
  56. echo 'starting pulseaudio'
  57. pulseaudio -k 2>/dev/null
  58. cat /etc/pulse/default.pa | sed 's/^\(load-module module-udev-detect\|load-module module-detect\)/\1 tsched=0/' > /storage/steamlink/pulse_default.pa
  59. pulseaudio -D -n -F "$TOP/pulse_default.pa"
  60.  
  61. echo 'starting cec'
  62. cec-client </dev/null | steamlink-cec &
  63. CEC_PID="$(jobs -p) $!"
  64.  
  65. echo 'starting steamlink'
  66. while true; do
  67.         LD_PRELOAD=$QT_QPA_EGLFS_PRELOAD shell "$@"
  68.  
  69.         # See if the shell wanted to launch anything
  70.         cmdline_file="$TMPDIR/launch_cmdline.txt"
  71.         if [ -f "$cmdline_file" ]; then
  72.                 cmd=`cat "$cmdline_file"`
  73.                 eval $cmd
  74.                 rm -f "$cmdline_file"
  75.         else
  76.                 # We're all done...
  77.                 break
  78.         fi
  79. done
  80.  
  81. cleanup
  82.  
  83. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement