Last active
September 18, 2021 13:37
-
-
Save fabriziogiordano/8c06077fe462b88e6739 to your computer and use it in GitHub Desktop.
Tmux to record and play a streaming radio
This file contains 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/sh | |
SESSION_NAME=Music | |
STREAMRIPPER="streamripper 'http://www.pulsradio.com/pls/puls-adsl.m3u' -d ~/Downloads/streamripper -s -r 9090 -o larger -M 500" | |
PLAY="clear && sleep 5s && mpg321 http://localhost:9090" | |
tmux has-session -t $SESSION_NAME 2>/dev/null | |
if [ $? -eq 1 ] | |
# Music session does not exist so create a new one | |
then | |
echo "Create new tmux $SESSION_NAME session" | |
tmux new -s $SESSION_NAME -n streamripper -d | |
echo "Start Streamripper" | |
tmux send-keys -t $SESSION_NAME "$STREAMRIPPER" C-m | |
tmux split-window -h -t $SESSION_NAME | |
tmux select-pane -t 1 | |
tmux send-keys -t $SESSION_NAME "$PLAY" C-m | |
printf "Wait 5 seconds to start play stream\r" && sleep 1s | |
printf "Wait 4 seconds to start play stream\r" && sleep 1s | |
printf "Wait 3 seconds to start play stream\r" && sleep 1s | |
printf "Wait 2 seconds to start play stream\r" && sleep 1s | |
printf "Wait 1 seconds to start play stream\r" && sleep 1s | |
# tmux attach -t $SESSION_NAME | |
# Music session exist so it exit | |
else | |
echo "$SESSION_NAME already exists. | |
To attach run: | |
tmux attach -t $SESSION_NAME | |
To stop the session | |
tmux kill-session -t $SESSION_NAME" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment