Last active
September 5, 2025 11:44
-
-
Save denzuko/2af226be5507db468f4c12abb318c64b to your computer and use it in GitHub Desktop.
Plan9 and OpenBSD Inspired music player
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
| kgnu-live: URI=https://kgnu.streamguys1.com/kgnu | |
| kgnu-live: player | |
| kgnu-music: URI=https://kgnu.streamguys1.com/kgnu-music | |
| kgnu-music: player | |
| anonradio: URI=http://anonradio.net:8000/anonradio | |
| anonradio: player | |
| payphoneradio: URI="https://centova11.instainternet.com/proxy/marktho1?mp=/stream" | |
| payphoneradio: player | |
| hpr: URI=https://hackerpublicradio.com/hpr_mp3_rss.php | |
| hpr: feed | |
| qanonpodcast: URI=https://feeds.soundcloud.com/users/soundcloud:users:492135420/sounds.rss | |
| qanonpodcast: feed | |
| littlebro: URI=https://www.littlebrotherpodcast.com/feed/podcast/ | |
| littlebro: feed | |
| offthehook: URI=https://www.2600.com/oth-broadband.xml | |
| offthehook: feed | |
| offthewall: URI=https://www.2600.com/otw-broadband.xml | |
| offthewall: feed | |
| darknet: URI=https://podcast.darknetdiaries.com/ | |
| darknet: feed | |
| hackerspace-signal-live: URI=http://broadcast.sonologic.net:8090/signal.mp3 | |
| hackerspace-signal-live: player | |
| hackerspace-signal: URI=https://signal.hackerspaces.org/archive/signal-mp3.xml | |
| hackerspace-signal: feed |
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
| include player.mk | |
| include example.mk |
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
| # player.mk - (C)2025 Dwight Spencer <[email protected]>. All Rights Reserved. | |
| # Licenced under BSD 2-clause. https://opensource.org/license/bsd-2-clause | |
| #### | |
| # Usage: | |
| # Append your makefile with `import player.mk` | |
| # | |
| # `make all` provides a list of all stations defined in your playlist makefile | |
| # This is also used for 9menu / dmenu which ends up calling `make <station_name>` | |
| # | |
| # Testing new endpoints/stations is easy with the following: | |
| # `make feed URI=<rss url>` | |
| # `make playlist URI=<m3u url>` | |
| # `make player URI=<http stream url>` | |
| # bookmarking a station is done by simply adding it to your playlist makefile. | |
| # | |
| # playlist makefiles uses the following schema: | |
| # <station_name>: URI=<stream url> | |
| # <station_name>: [feed|playlist|player] | |
| # feed :== rss feed, playlist := pls/m3u playlist(http/s), player := media player | |
| # URI may be anu uri that curl or your $(PLAYER) supports | |
| # | |
| # `make completion` is tab completion for ash shells based off make all | |
| ## | |
| # Uses gst123, 9menu, plan9ports, gnu make. May work with tweeks to GLOBALS | |
| # for dmenu/fzf, mpg123/ffplay, and bsd/plan9 make. | |
| ### | |
| ## Config | |
| PLAYER := gst123 | |
| MENURC := 9menu | |
| ## GLOBALS | |
| STATIONS := $(shell grep ': URI' $(wildcard *.mk) Makefile | cut -d: -f2 | grep -v '^#\|^STATIONS' | sort -u) | |
| FILES := $(shell find * -type f -name \*.mp3 -o -name \*.ogg) | |
| MENU := $(shell echo $(STATIONS) | tr ' ' "\n" | xargs -I{} echo "{}:\'exec xterm -e make -C ~/music {}\'" |xargs) | |
| define COMPLETION | |
| #!/usr/bin/env bash | |
| _mkplayer() { | |
| local cur=$${COMP_WORDS[COMP_CWORD]} | |
| COMPREPLY=( $$(compgen -W "$$(make)" -- $$cur) ) | |
| } | |
| complete -F _mkplayer make | |
| endef | |
| export COMPLETION | |
| .PHONY: all menu completion help stop pause play radio player playlist feed | |
| all: # List all stations | |
| @echo "$(STATIONS)" | |
| radio: stop | |
| @curl -sSLk "${URI}" 2>/dev/null | $(PLAYER) /dev/stdin | |
| feed: stop | |
| @$(PLAYER) "$(shell curl -sSlk "${URI}" | xq -x '//item/enclosure/@url' | sed '1q')" | |
| playlist: stop | |
| @$(PLAYER) "$(shell curl -sSlk "${URI}" | grep -oP 'https?://\S+' | sed '1q')" | |
| player: stop | |
| @$(PLAYER) "${URI}" | |
| stop: #uses plan9ports to send KILL signal to player | |
| @eval $(shell 9 slay $(PLAYER)) | |
| pause: #uses plan9ports to send STOP signal to player | |
| @eval $(shell 9 stop $(PLAYER)) | |
| play: #uses plan9ports to send CONT signal to player | |
| @eval $(shell 9 start $(PLAYER)) | |
| completion: #generates tap completion for shells | |
| @echo "$$COMPLETION" | |
| menu: #calls GUI menu system with stations | |
| @${MENURC} ${MENU} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment