Logo Computer scientist,
engineer, and educator
• Software
• The kmediad project

kmediadcmd — a command-line, interactive interface to kmediad

Version 0.1.0

What is this?

kmediadcmd is a command-line interface to the kmediad music player. It is based on the kmedia API. It allows the user to select particular tracks or albums for playback, and to query the music track database in various ways.

For more information, see the kmediadcmd man page.

Command line

kmediadcmd can be used in batch or interactive mode. In interactive mode, it prompts for commands and executes them. Since kmediadcmd commands often take command-line switches of their own, some care has to be taken to avoid getting these different kinds of switches mixed up. In non-interactive mode, the general format of the command line is
$ kmediad [program_options] [--] [command [command_options]]
The "--" token indicates that what follows is a command and its switches, and that the switches apply to the command, and not the program in general. For example, in this command:
$ kmediad -p 30001 — playlist -p
the first "-p" is an instruction to use port 30001 for communication with the server, whilst the second is an option to the "playlist" command, telling it to display file paths rather than track titles. The "--" can be ommitted if the command takes no switches. For example:
$ kmediad play 
Anything after a hash (#) is taken to be a comment, but hashes can be used explicitly in searches, either by enclosing them in quotes, or preceding them by a backslash. So the following are equivalent:
artists --title "mambo #5"
artists --title mambo\ \#5
In either case, quotes or escapes must be used around text strings that contain spaces.


# List all albums whose genre tab is "baroque" 
albums --genre "baroque

# Play the album "Bach - Goldberg Variations". Not that the album title is
#   case sensitive, and should be quoted if it contains spaces.
play-album "Bach - Goldberg Variations"

# Select and play an album at random that has "Christmas" (case insensitive)
#    in its command tag
play-random-album --comment "christmas"

Playlist management

kmediadcmd can import and export the kmediad playlist. For example, to store the current playlist in a file:
export-playlist playlist.txt
Iterms are written one-to-a-line in a fairly obvious format, suitable for manipulating with (for example) a text editor. Use import-playlist to read the tracks back into kmediad.

The titles command will also write data in a way that is suitable for importing as a playlist (without or without editing). For example, to make a playlist of every track by Frank Sinatra:

$ kmediadcmd — titles --artist=sinatra > sinatra.txt
$ kmediadcmd import-playlist sinatra.txt 

Building kmediadcmd

kmediadcmd builds from a simple Makefile. It has dependencies on the kmediad interface, and on KLib. It may be necessary to adjust the Makefile to indicate the installation locations of those components.


- Searching is carried out on the kmediad server, and proceeds according to its rules. Notably, search terms are generally case-insensitive, and must match whole words. Search terms can be combined, in principle, but the results are generally not well-defined.

- Long lists of results are passed to a pager, if output is to a terminal. The pager can be selected, or disabled, on the command line (--pager none.)

- The volume command sends a set-volume instruction to the kmediad server. Whether this has any effect depends on how kmediad is set up, and the specific sound device.


Source code bundle
Copyright © 1994-2015 Kevin Boone. Updated Dec 12 2016