man moosic (Commandes) - a command-line client for the Moosic jukebox system.

NAME

moosic - a command-line client for the Moosic jukebox system.

SYNOPSIS

moosic [options] command [options] [command arguments]

DESCRIPTION

The moosic program is the command-line interface to the Moosic jukebox system. It communicates with moosicd(1), the Moosic server, querying the server for information and telling the server what to do. moosic will not be able to do very much unless moosicd is running. When moosicd isn't already running, moosic will automatically start it for you, unless you specifically request otherwise (with the --no-startserver option).

USAGE

moosic works by sending a command to the Moosic server and returning the response, if any. The first non-option argument given to moosic is the name of the command to be performed. This command name is case-insensitive, and all non-alphanumeric characters in it are ignored. You can use the help command to quickly and easily view the names of all the available commands and to get a brief description of individual commands. You can also use CWmoosic --showcommands to display the short descriptions of all the commands at once. The COMMANDS section below lists the full details of each command. There are very many commands, so you should start by just learning a few commonly used commands, and only learning others as you feel the need. I recommend starting with the following short command vocabulary: add, list, stop, play, and shuffle.

For example, CWmoosic add foo.mp3 adds the file foo.mp3 (in the current directory) to the end of the song queue and returns you immediately back to your shell prompt without printing any output (unless an error occurs). Compare with CWmoosic list, which will list the contents of the song queue. Note that if the song queue is empty, CWmoosic list will not display anything.

OPTIONS

Most of the options for moosic are only relevant if they are used with one of the commands that take a filelist argument. See COMMANDS for the definition of a filelist. The only shuffling options that don't mutually exclude each other are -d and -a. Shuffling options that are named later on the command line take precedence over ones that occur earlier. All options must be named immediately before the command given to moosic or immediately after the command; options placed within the list of the command's arguments will not be interpreted as options.

-g, --shuffle-global
This option causes moosic to shuffle the entire filelist after directory expansion has taken place, before sending the filelist to the Moosic server. This is the default behavior. This option is only meaningful if used in conjunction with a command that accepts a filelist.
-d, --shuffle-dir
This option causes moosic to shuffle the results of expanding the directories named in the filelist. This option is only meaningful if used in conjunction with a command that accepts a filelist.
-a, --shuffle-args
This option causes moosic to shuffle the actual command line arguments that comprise the filelist. This option is only meaningful if used in conjunction with a command that accepts a filelist.
-o, --inorder
When this option is used, moosic doesn't shuffle the filelist named on the command line at all. Rather, the order specified on the command line is preserved. This option is only meaningful if used in conjunction with a command that accepts a filelist.
-s, --sort
When this option is used, moosic sorts the filelist lexicographically after it has been expanded (through directory recursion or auto-finding or the like). The order specified on the command line is ignored. This option is only meaningful if used in conjunction with a command that accepts a filelist.
-r, --no-recurse
Using this option prevents moosic from replacing directories named in the filelist with a recursive traversal of their contents.
-n, --no-file-munge
Using this option prevents moosic from modifying the names in the expanded filelist. Normally, moosic converts relative filenames into absolute filenames before sending the names to moosicd, but this is generally not desirable behavior if you want to insert items that aren't local files into the queue (such as URLs). This option is only meaningful if used in conjunction with a command that accepts a filelist.
-i, --ignore-case
Treats any given regular expressions as if they were case-insensitive. This option is only meaningful if used in conjunction with a command that accepts one or more regular expressions as arguments. This option is syntactic sugar, since the regular expressions supported by Moosic can also be made case-insensitive by including (?i) within the regular expression.
-f, --auto-find
This option causes each string in the filelist with the results of performing a fuzzy search for music files. Fuzzy matching is done by simplifying all the candidate filenames (by lowering the case and removing all non-alphanumeric characters except slashes) and then testing to see if the search string (which has been similarly simplified) is contained in any of the filenames. The list of candidate filenames is obtained by recursively traversing the file hierarchy rooted at the directory specified by the --music-dir option (which has a default value of ~/music/). For example, if you use CWmoosic -f add severedgoddess, and the file ~/music/Meat_Puppets/Severed_Goddess_Hand.mp3 exists, then this file will be included in the list of files to be added to the queue. Similarly, if you use CWmoosic -f pre nesad, and the directory ~/music/J/Jane's Addiction/ exists, then all the files in this directory (and its subdirectories) will be included in the list of files to be prepended to the queue. This option is only meaningful if used in conjunction with a command that accepts a filelist. Beware that using this option can cause moosic to take a long time to complete if the directory tree being searched contains a very large number of files.
-F, --auto-grep
This option enables behavior very much like that of the --auto-find option, except that regular expression searching is used instead of the fuzzy search scheme. Specifically, each string in the filelist is treated as a regular expression, and is replaced with all the filenames that match the expression. As with --auto-find, the filenames that are eligible for matching are obtained by traversing the directory named with the --music-dir option (defaulting to ~/music/ if --music-dir is not used). Essentially, CWmoosic -F prepend something is semantically equivalent to CWmoosic prepend `find ~/music/ | grep something`, but is syntactically a lot sweeter. This option is only meaningful if used in conjunction with a command that accepts a filelist. Beware that using this option can cause moosic to take a long time to complete if the directory tree being searched contains a very large number of files.
-m directory, --music-dir directory
This option controls which directory is used for searching when the auto-find or auto-grep feature is enabled. These automatic searches are limited to the file hierarchy rooted at the directory specified by this option. When this option is not used, the ~/music/ directory is used as a default. This option is only meaningful if either --auto-find or --auto-grep is used.
-S, --showcommands
Prints a list of the commands that may be used with moosic and then exits. Note that this output is quite copious, so you will probably want to pipe it to a text pager, such as less.
-h, --help
Prints a short help message that explains the command line options and then exits.
-v, --version
Prints version information and then exits.
-c directory, --config-dir directory
This option is not needed under normal circumstances. It should only be used if you want moosic to communicate with an instance of moosicd which was invoked with the -c/--config option. Using this option tells moosic to search the specified directory for the files which are usually found in ~/.moosic/.
-t host:port, --tcp host:port
This option tells moosic to communicate with a Moosic server that is listening to the specified TCP/IP port on the specified host. Running a Moosic server that accepts requests via TCP/IP is not recommended because it is a security risk.
-N, --no-startserver
This option prevents moosic from trying to automatically start moosicd if it can't contact a Moosic server.

COMMANDS

Any of these commands may be specified with any mixture of upper-case and lower-case letters, and non-alphabetic characters (such as '-') may be omitted.

Many of these commands accept a range argument. A range is a pair of colon-separated numbers. Such a range addresses all items whose index in the song queue is both greater than or equal to the first number and less than the second number. For example, 3:7 addresses items 3, 4, 5, and 6. If the first number in the pair is omitted, then the range starts at the beginning of the song queue. If the second number in the pair is omitted, then the range extends to include the last item in the song queue. A range can also be a single number (with no colon), in which case it addresses the single item whose index is that of the given number. Negative numbers may be used to index items from the end of the list instead of the beginning. Thus, -1 refers to the last item in the song queue, -2 refers to the second-to-last item, etc.

Beware that a negative number that immediately follows a moosic command is liable to be incorrectly interpreted as an option, so option processing should be explicitly terminated with an argument of -- between the command and the number. This is illustrated by the following example, which removes the last item in the queue: CWmoosic del -- -1

Alternatively (and perhaps more conveniently), you can prevent negative numbers from being interpreted as options by preceding the range with a single character that can't be mistaken for a number or an option (i.e. any character that isn't a digit or a dash). Example: CWmoosic list /-15:-9. You can also place such a character at the end of the range if you think it makes it look prettier. Example: CWmoosic list /-15:-9/. The bracketing characters surrounding a range need not be the same: CWmoosic shuffle '[-13:8]'. Notice how the preceding example surrounded the range in quotes to prevent the shell from treating the [ and ] characters specially (since shells have a habit of doing things like that).

Querying for information

These commands print useful bits of information to standard output.

help [command ...]
Prints a brief description of the moosic commands named as arguments. If no arguments are given, a list of all the available moosic commands is printed.
current
Print the name of the song that is currently playing.
curr
An alias for current.
current-time [format]
Print the amount of time that the current song has been playing. By default, this time is printed in a format of hours:minutes:seconds, but if a different format is desired, a string argument can be given to specify it. The format should be a string that is appropriate for passing to the strftime(3) function.
list [range]
Print the list of items in the current song queue. A whole number is printed before each item in the list, indicating its position in the queue. If a range is specified, only the items that fall within that range are listed. Remember that the song queue does not contain the currently playing song.
plainlist [range]
Print the current song queue without numbering each line. If a range is specified, only the items that fall within that range are listed. This output is suitable for saving to a file which can be reloaded by the pl-append, pl-prepend, pl-insert, and pl-mixin commands.
history [number]
Print a list of items that were recently played. The times mentioned in the output of this command represents the time that a song finished playing. If a number is specified, then no more than that number of entries will be printed. If a number is not specified, then the entire history is printed. Note that moosicd limits the number of items stored in its history list.
hist [number]
An alias for history.
state
Print the current state of the music daemon.
status
An alias for state.
length
Print the number of items in the queue.
len
An alias for length.
ispaused
Show whether the current song is paused or not. If the song is paused, True is printed and moosic returns normally. If the song is not paused, False is printed and moosic returns with a non-zero exit status (which happens to be 2 for no particular reason).
islooping
Show whether the server is in loop mode. If the server is in loop mode, True is printed and moosic returns normally. If not, False is printed and moosic returns with a non-zero exit status (which happens to be 2 for no particular reason).
isadvancing
Show whether the server is advancing through the song queue. If the server is advancing, True is printed and moosic returns normally. If not, False is printed and moosic returns with a non-zero exit status (which happens to be 2 for no particular reason).
version
Print version information for both the client and the server, and then exit.

Adding to the song queue

These commands will add to the queue of items to be played. Many of these commands accept a filelist argument. A filelist is a list of one or more files or directories. Any directories named in the list will be replaced by a list of files produced by recursively traversing the contents of the directory (unless the --no-file-munge option or --no-recurse option is being used). Depending on the shuffling options specified when invoking moosic, the list will be shuffled before being added to the Moosic server's queue.

append filelist
Add the files to be played to the end of the song queue.
add filelist
An alias for append.
pl-append playlist-file ...
Add the items listed in the given playlist files to the end of the song queue. If - (a single dash) is given as the name of a playlist file, data will be read from from standard input instead of trying to read from a file named -.
pl-add playlist-file ...
An alias for pl-append.
prepend filelist
Add the files to be played to the beginning of the song queue.
pre filelist
An alias for prepend.
pl-prepend playlist-file ...
Add the items listed in the given playlist files to the beginning of the song queue. If - (a single dash) is given as the name of a playlist file, data will be read from from standard input instead of trying to read from a file named -.
mixin filelist
Add the files to the song queue and reshuffle the entire song queue.
pl-mixin playlist-file ...
Add the items listed in the given playlist files to the song queue and reshuffle the entire song queue. If - (a single dash) is given as the name of a playlist file, data will be read from from standard input instead of trying to read from a file named -.
replace filelist
Replace the current contents of the song queue with the songs contained in the filelist.
pl-replace playlist-file ...
Replace the current contents of the song queue with the songs named in the given playlists.
insert filelist index
Insert the given items at a given point in the song queue. The items are inserted such that they will precede the item that previously occupied the specified index.
pl-insert playlist-file ... index
Insert the items specified in the given playlist files at a specified point in the song queue. If - (a single dash) is given as the name of a playlist file, data will be read from from standard input instead of trying to read from a file named -.
putback
Reinsert the current song at the start of the song queue.
stagger-add filelist
Adds the file list to the end of the song queue, but only after rearranging it into a staggered order. This staggered order is very similar the order created by the stagger command (described below). Each element of the file list (before replacing directories with their contents) specifies a category into which the expanded file list will be divided. The staggered order of the list being added is formed by taking the first item from each category in turn until all the categories are empty. This may be a bit difficult to understand without an example, so here is a typical case: Initially, the queue contains a few items.
    [0] /music/a.ogg
    [1] /music/b.mp3
    [2] /music/c.mid
Additionally, there are two directories that each contain a few files:
    $ ls /music/X/ /music/Y/
    X:
    1.ogg  2.ogg  3.ogg
    Y:
    1.ogg  2.ogg  3.ogg  4.ogg
After executing CWmoosic -o stagger-add /music/Y /music/X, the queue now contains:
    [0] /music/a.ogg
    [1] /music/b.mp3
    [2] /music/c.mid
    [3] /music/Y/1.ogg
    [4] /music/X/1.ogg
    [5] /music/Y/2.ogg
    [6] /music/X/2.ogg
    [7] /music/Y/3.ogg
    [8] /music/X/3.ogg
    [9] /music/Y/4.ogg
stagger-merge filelist
Adds the given file list to the queue in an interleaved fashion. More specifically, the new song queue will consist of a list that alternates between the items from the given file list and the items from the existing song queu. For example, if the queue initially contains:
    [0] /music/a.ogg
    [1] /music/b.mp3
    [2] /music/c.mid
And the /music/Y/ directory contains:
    1.ogg  2.ogg  3.ogg  4.ogg
Then, after executing CWmoosic -o stagger-merge /music/Y, the queue will contain:
    [0] /music/Y/1.ogg
    [1] /music/a.ogg
    [2] /music/Y/2.ogg
    [3] /music/b.mp3
    [4] /music/Y/3.ogg
    [5] /music/c.mid
    [6] /music/Y/4.ogg
interval-add interval filelist
Inserts the given songs into the current song queue with a regular frequency that is specified with the given interval argument (which must be an integer). For example, if the queue initially contains:
    [0] /music/a.mod
    [1] /music/b.mod
    [2] /music/c.mod
    [3] /music/d.mod
    [4] /music/e.mod
    [5] /music/f.mod
    [6] /music/g.mod
And the /music/Z directory contains:
    aleph.wav  bet.wav  gimmel.wav
Then, after executing CWmoosic -o interval-add 3 /music/Z, the queue will contain:
    [0] aleph.wav
    [1] /music/a.mod
    [2] /music/b.mod
    [3] bet.wav
    [4] /music/c.mod
    [5] /music/d.mod
    [6] gimmel.wav
    [7] /music/e.mod
    [8] /music/f.mod
    [9] /music/g.mod

Removing from the song queue

These commands will remove from the queue of items to be played.

cut range
Removes all song queue items that fall within the given range.
del range
An alias for cut.
crop range
Removes all song queue items that do not fall within the given range.
remove regex ...
Remove all song queue items that match the given regular expression. If multiple regular expressions are given, any song that matches any one of the expressions will be removed.
filter regex ...
Remove all song queue items that do not match the given regular expression. If multiple regular expressions are given, only those songs that match all the regular expressions will remain afterward.
clear
Clear the song queue.
wipe
Clear the song queue and stop the current song.

Rearranging the song queue

These commands let you change the order of the items in the queue.

move range index
Moves all items in the given range to a new position in the song queue. If you want to move items to the end of the queue, use CW`moosic length` as the final argument. For example, to move the first 10 songs to the end of the queue, use the following command: CWmoosic move 0:10 `moosic length`
swap range range
Causes the songs contained within the two specified ranges to trade places.
reshuffle [range]
Reshuffle the song queue. If a range is specified, only items that fall within that range will be shuffled.
shuffle [range]
An alias for reshuffle.
sort [range]
Rearrange the song queue in sorted order. If a range is specified, only items that fall within that range will be sorted.
reverse [range]
Reverse the order of the song queue. If a range is specified, only items that fall within that range will be reversed.
partial-sort regex ...
For each specified regular expression, the items in the song queue that match that expression are removed from the queue and gathered into their own list. All of these lists (plus the list of items that did not match any regular expression) are then stitched back together through simple concatenation. Finally, this unified list replaces the contents of the song queue. The items that match a particular regular expression will remain in the same order with respect to each other. Each group of matched items will appear in the reordered song queue in the order that the corresponding regular expressions were specified on the command line.
stagger regex ...
For each specified regular expression, the items in the song queue that match that expression are removed from the queue and gathered into their own list. All of these lists are then merged together in a staggered fashion. All the leftover items (i.e. the ones that weren't matched by any regex on the command line) are appended to this unified list, which then replaces the contents of the song queue. For example, if you use CWmoosic stagger red blue green and the queue originally contains only names that either contain the string red or blue or green, then the members of the reordered queue will alternate between red items, blue items, and green items. If the queue does contain items that are neither red nor green nor blue, then these will be collected and placed at the end of the queue, after all the red, green, and blue items.
sub pattern replacement [range]
Perform a regular expression substitution on all items in the song queue. More precisely, this searches each queue item for the regular expression specified by the first argument, and replaces it with the text specified by the second argument. Any backslash escapes in the replacement text will be processed, including special character translation (e.g. \n to newline) and backreferences to groups within the match. If a range is given, then the substitution will only be applied to the items that fall within the range, instead of all items. Only the first matching occurrence of the pattern is replaced in each item.
suball pattern replacement [range]
This is identical to the sub command, except that all occurrences of the pattern within each queue item are replaced instead of just the first occurrence.

General management

These commands affect the state of the Moosic server in various ways.

next [number]
Stops the current song (if any), and jumps ahead to a song that is currently in the queue. The argument specifies the number of songs to be skipped, including the currently playing song. Its default value is 1. The skipped songs are recorded in the history as if they had been played. If queue advancement is disabled, this command merely stops the current song and removes the appropriate number of songs from the queue, and does not cause a new song to be played.
previous [number]
Retreats to a previously played song (from the history list) and begins playing it if queue advancement is enabled. If a number is given as an argument, then the music daemon will retreat by that number of songs. If no argument is given, then the music daemon will retreat to the most recent song in the history. More precisely, this command stops the current song (without recording it in the song history) and returns the most recently played song or songs to the queue. This command removes songs from the history when it returns them to the queue, thus modifying the song history. When loop mode is on, this command retreats into the tail end of the queue instead of the song history. This produces wrap-around behavior that you would expect from loop mode, and does not modify the song history.
prev
An alias for previous.
goto regex
Jumps to the next song in the queue that matches the given regular expression.
gobackto regex
Jumps back to the most recent previous song that matches the given regular expression.
noadvance
Tell the music daemon to stop playing any new songs, but without interrupting the current song. In other words, this halts queue advancement.
noadv
An alias for noadvance.
advance
Tell the music daemon to resume queue advancement (i.e. play new songs when the current one is finished). Obviously, this has no effect if queue advancement hasn't been disabled.
adv
An alias for advance.
toggle-advance
Halts queue advancement if it is enabled, and enables advancement if it is halted.
stop
Tell the music daemon to stop playing the current song and stop processing the song queue. The current song is put back into the song queue and is not recorded in the song history.
pause
Suspend the current song so that it can be resumed at the exact same point at a later time. Note: this often leaves the sound device locked.
unpause
Unpause the current song, if the current song is paused, otherwise do nothing.
play
Tell the music daemon to resume playing. (Use after stop, noadv, or pause.)
loop
Turn loop mode on. When loop mode is on, songs are returned to the end of the queue when they finish playing instead of being thrown away.
noloop
Turn loop mode off.
toggle-loop
Turn loop mode on if it is off, and turn it off if it is on.
reconfigure
Tell the music daemon to reload its configuration file.
reconfig
An alias for reconfigure.
showconfig
Query and print the music daemon's filetype associations.
start-server [options]
Start a new instance of the music daemon (also known as moosicd). If option arguments are given, they will be used as the options for invoking moosicd. The options that are accepted by moosicd can be found in its own manual page, moosicd(1).
exit
Tell the music daemon to quit.
quit
An alias for exit.
die
An alias for exit.

AUDIO CD SUPPORT

If you have the takcd program installed, and you have an appropriate entry for it in the Moosic server's player configuration, then you can play audio CD tracks with Moosic. The following entry should be in ~/.moosic/config:

    (?i)^cda://(\S*)
    takcd \1

To put CD tracks into the song queue, you should name them with the prefix cda://, followed immediately by the number of the track you wish to play. For example, CWmoosic -n add cda://3 will add the third track on the CD to the end of the song queue.

The takcd program can be found at <http://bard.sytes.net/takcd/>.

FILES

socket
This is a socket file which is used to allow Moosic clients to contact the Moosic server. It is generally located in the ~/.moosic/ directory, unless moosicd was invoked with the -c/--config option.

SEE ALSO

moosicd(1), for details on invoking the Moosic server by hand.

Various moosic commands accept regular expressions arguments. The syntax used for these regular expressions is identical to the syntax used by Python's regular expression library. The details of this syntax are explained in the chapter entitled Regular Expression Syntax <http://www.python.org/doc/current/lib/re-syntax.html> from the section dealing with the re module in the Python Library Reference.

AUTHOR

Daniel Pearson <daniel@nanoo.org>