A bash script that turns mpv into a radio.
- mpv: to play the stream
- dmenu: to choose radio stations
- jq: to parse IPC responses from mpv
- socat: to send IPC requests to mpv
- notify-send: to trigger desktop notifications
- awk: string processing
- youtube-dl: to play some streams
Create a file at $HOME/.radio/stations
that will contain your online radio stations.
This is how you'll control what stations you can listen to.
Each station should be recorded on its own line in the file as "<station name>",<station_url>
.
Here's an example (using fake stations):
"Metal.FM",https://metal.fm
"HipHop 90s",https://anothersite.com/hiphop/90s/
You can also run radio add <station name> <station url>
e.g. radio add "Metal.FM" "https://metal.fm"
Once a list of stations has been prepped, run radio start
.
This will launch dmenu asking you to select one of your radio stations.
Once the station is selected, the script launches mpv in the background to play the station stream.
You can run radio start
again to change stations.
The mpv instance is reused every time you run radio start
to change stations (so long as it's still alive).
To stop mpv playing the stream, run radio stop
.
To find out the current song that's playing on the stream (assuming the station provides icy-title
tags for the songs its playing), run radio info
.
You can also mute/unmute the stream with radio toggle
.
Running radio
with no arguments will print out a usage guide.
Have fun!
MIT License
Copyright (c) 2019 Kennedy Mwenja
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.