Music player minimalism
After installing Arch Linux and beginning to use it again for the fourth or so time I've given myself a new challenge. Try to eliminate packages that I feel like are unnecessary. I like foobar2000 but it's a Windows program and I only use a small subset of its features. I don't really have a lot of experience with Linux music playing software and have tried to avoid it. Avoiding a proper music player has resulted in me doing some funny things.
The first music player (a shell script)
The idea is to make a shell script that can do at least the following:
- Recursively find files according to some pattern
- Loop a list of files
- Shuffle a list of files
- Set the volume
I chose gstreamer a multimedia framework for handling the file reading, decoding, playing of audio files which is built around the idea of a configurable pipeline as the method of playing the files.
Here is the source code to play-audio.sh
#!/bin/sh
if ; then
fi
loop=0
shuffle=0
file_reorder="sort -z"
if ; then
fi
files=""
if ; then
files=""
fi
vol_elem="identity"
if ; then
vol_elem="volume volume="
fi
while ; do
# play the playlist
while ; do
done
# shuffle the playlist if shuffle is on
if ; then
if ; then
files=""
fi
fi
|| break
done
This solution is pretty good but it has a few large glaring flaws:
- No way to pause the audio or remember state
- No playlist controls (skip, previous, etc..)
- No way to change the volume once a song is playing
The second music player (a daemon)
The idea is to make a daemon that runs in the background and is commanded through a socket
I chose mpv specifically libmpv bindings in Rust as the audio playing backend.