launch-stream.sh (1343B)
1 #!/bin/sh 2 3 # Format for streams.csv: 4 # `NerdCubed,nerdcubed,@NerdCubed,NONE` 5 # Syntax is: `name,twitch,youtube-at-kick` 6 7 STREAMS_FILE="$XDG_CONFIG_HOME/regexghost/streams.csv" 8 9 DMENU_SCRIPT="$XDG_DATA_HOME/regexghost/wm-scripts/dmenu-runner.sh" 10 11 stream="$(cat "$STREAMS_FILE" | cut -d "," -f 1 | "$DMENU_SCRIPT" "Select Stream:" -ix)" 12 13 [ "$stream" = "" ] && exit 14 15 line="$(sed -n "$((stream+1))p" "$STREAMS_FILE")" 16 name="$(echo "$line" | cut -d "," -f 1)" 17 twitch="$(echo "$line" | cut -d "," -f 2)" 18 youtube="$(echo "$line" | cut -d "," -f 3)" 19 kick="$(echo "$line" | cut -d "," -f 4)" 20 21 # Try YouTube, then Kick, then Twitch 22 23 if ! [ "$youtube" = "NONE" ]; then 24 notify-send "Launching ${name} YouTube stream" 25 mpv --no-resume-playback --ytdl-format="bestvideo[height<=480]+bestaudio" "https://youtube.com/${youtube}/live" && exit 26 notify-send "Failed to open ${name} YouTube stream" 27 fi 28 29 if ! [ "$kick" = "NONE" ]; then 30 notify-send "Launching ${name} Kick stream" 31 mpv --no-resume-playback --ytdl-format="2" "https://kick.com/${kick}" && exit 32 notify-send "Failed to open ${name} Kick stream" 33 fi 34 35 if ! [ "$twitch" = "NONE" ]; then 36 notify-send "Launching ${name} Twitch stream" 37 mpv --no-resume-playback "https://twitch.tv/${twitch}" && exit 38 notify-send "Failed to open ${name} Twitch stream" 39 fi 40 41 notify-send "Not live or unable to open stream"