Last active
August 11, 2016 00:10
-
-
Save fabienduhamel/8834aee5318f5716e1c0bb3db265a033 to your computer and use it in GitHub Desktop.
Twitch livestreamer desktop launcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| VIDEO="vlc" | |
| echo "Which stream?" | |
| read stream | |
| starting_video_proc_count=`ps aux | grep -v grep | grep $VIDEO | wc -l` | |
| nohup livestreamer twitch.tv/$stream best &>/dev/null & export LIVESTREAMER_ID=$! | |
| echo "Starting Livestreamer on twitch.tv/$stream..." | |
| while true; do | |
| livestreamer_proc_count=`ps aux | grep -v grep | grep $LIVESTREAMER_ID | wc -l` | |
| video_proc_count=`ps aux | grep -v grep | grep $VIDEO | wc -l` | |
| if [[ $video_proc_count == $((starting_video_proc_count + 1)) ]]; then | |
| exit 0 | |
| fi | |
| if [[ $livestreamer_proc_count == 0 ]]; then | |
| exit 1 | |
| fi | |
| sleep 0.5 | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/zsh | |
| VIDEO="vlc" | |
| MODES=( best 1080p60 1080p30 ) | |
| MAX_ATTEMPTS=10 | |
| SLEEP_DELAY=0.5 | |
| echo "Which stream?" | |
| read stream | |
| starting_video_proc_count=`ps aux | grep -v grep | grep $VIDEO | wc -l` | |
| for mode in "${MODES[@]}"; do | |
| echo "Starting Livestreamer on twitch.tv/$stream in $mode mode..." | |
| nohup livestreamer twitch.tv/$stream $mode &>/dev/null & export LIVESTREAMER_ID=$! | |
| s=0 | |
| while [ $s -lt $MAX_ATTEMPTS ]; do | |
| livestreamer_proc_count=`ps aux | grep -v grep | grep $LIVESTREAMER_ID | wc -l` | |
| video_proc_count=`ps aux | grep -v grep | grep $VIDEO | wc -l` | |
| if [[ $video_proc_count == $((starting_video_proc_count + 1)) ]]; then | |
| echo "Livestreamer launched." | |
| exit 0 | |
| fi | |
| # if [[ $livestreamer_proc_count == 0 ]]; then | |
| # echo "Livestreamer failed." | |
| # exit 1 | |
| # fi | |
| sleep $SLEEP_DELAY | |
| s=$(( $s + 1 )) | |
| done | |
| done | |
| echo "Livestreamer failed." | |
| exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Desktop Entry] | |
| Version=1.0 | |
| Type=Application | |
| Name=Twitch Livestreamer | |
| Icon=/home/fab/bin/livestreamer-launcher/stream.png | |
| Exec="/home/fab/bin/livestreamer-launcher/livestreamer-launcher" | |
| Categories=Game; | |
| Terminal=true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment