chiark / gitweb /
core audio support in speaker
[disorder] / doc / disorder_config.5.in
CommitLineData
460b9539 1.\"
405fea4e 2.\" Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
460b9539 3.\"
4.\" This program is free software; you can redistribute it and/or modify
5.\" it under the terms of the GNU General Public License as published by
6.\" the Free Software Foundation; either version 2 of the License, or
7.\" (at your option) any later version.
8.\"
9.\" This program is distributed in the hope that it will be useful, but
10.\" WITHOUT ANY WARRANTY; without even the implied warranty of
11.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12.\" General Public License for more details.
13.\"
14.\" You should have received a copy of the GNU General Public License
15.\" along with this program; if not, write to the Free Software
16.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17.\" USA
18.\"
19.TH disorder_config 5
20.SH NAME
21pkgconfdir/config - DisOrder jukebox configuration
22.SH DESCRIPTION
23The purpose of DisOrder is to organize and play digital audio files, under the
24control of multiple users. \fIpkgconfdir/config\fR is the primary
25configuration file but this man page currently documents all of its various
26configuration files.
27.SS Tracks
28DisOrder can be configured with multiple collections of tracks, indexing them
29by their filename, and picking players on the basis of filename patterns (for
30instance, "*.mp3").
31.PP
32Although the model is of filenames, it is not inherent that there are
33corresponding real files - merely that they can be interpreted by the chosen
34player. See \fBdisorder\fR(3) for more details about this.
35.PP
36Each track can have a set of preferences associated with it. These are simple
37key-value pairs; they can be used for anything you like, but a number of keys
38have specific meanings. See \fBdisorder\fR(1) for more details about these.
39.SS "Track Names"
40Track names are derived from filenames under the control of regular
41expressions, rather than attempting to interpret format-specific embedded name
42information. They can be overridden by setting preferences.
43.PP
44Names for display are distinguished from names for sorting, so with the right
45underlying filenames an album can be displayed in its original order even if
46the displayed track titles are not lexically sorted.
47.SS "Server State"
48A collection of global preferences define various bits of server state: whether
49random play is enabled, what tags to check for when picking at random, etc.
50.SS "Users And Access Control"
51DisOrder distinguishes between multiple users. This is for access control and
52reporting, not to provide different views of the world: i.e. preferences and so
53on are global.
54.PP
55It's possible to restrict a small number of operations to a specific subset of
56users. However, it is assumed that every user is supposed to be able to do
57most operations - since the users are all sharing the same audio environment
58they are expected to cooperate with each other.
59.PP
60Access control is entirely used-based. If you configure DisOrder to listen for
61TCP/IP connections then it will accept a connection from anywhere provided the
62right password is available. Passwords are never transmitted over TCP/IP
63connections in clear, but everything else is. The expected model is that
64host-based access control is imposed at the network layer.
65.SS "Web Interface"
66The web interface is controlled by a collection of template files, one for each
67kind of page, and a collection of option files. These are split up and
68separate from the main configuration file to make it more convenient to
69override specific bits.
70.PP
71The web interface connects to the DisOrder server like any other user, though
72it is given a special privilege to "become" any other user. (Thus, any process
73with the same UID as the web interface is very powerful as far as DisOrder
74goes.)
75.PP
76Access control to the web interface is (currently) separate from DisOrder's own
77access control (HTTP authentication is required) but uses the same user
78namespace.
79.SH "CONFIGURATION FILE"
80.SS "General Syntax"
81Lines are split into fields separated by whitespace (space, tab, line
82feed, carriage return, form feed). Comments are started by the number
83sign ("#").
84.PP
85Fields may be unquoted (in which case they may not contain spaces and
86may not start with a quotation mark or apostrophe) or quoted by either
87quotation marks or apostrophes. Inside quoted fields every character
88stands for itself, except that a backslash can only appear as part of
89one of the following escape sequences:
90.TP
91.B \e\e
92Backslash
93.TP
94.B \e"
95Quotation mark
96.\" "
97.TP
98.B \e'
99Apostrophe
100.TP
101.B \en
102Line feed
103.PP
104No other escape sequences are allowed.
105.PP
106Within any line the first field is a configuration command and any
107further fields are parameters. Lines with no fields are ignored.
108.PP
109After editing the config file use \fBdisorder reconfigure\fR to make
110it re-read it. If there is anything wrong with it the daemon will
111record a log message and ignore the new config file. (You should fix
112it before next terminating and restarting the daemon, as it cannot
113start up without a valid config file.)
114.SS "Global Configuration"
115.TP
116.B home \fIDIRECTORY\fR
117The home directory for state files. Defaults to
118.IR pkgstatedir .
119.TP
120.B plugin \fIPATH\fR
121Adds a directory to the plugin path. (This is also used by the web
122interface.)
123.IP
124Plugins are opened the first time they are required and never after,
125so after changing a plugin you must restart the server before it is
126guaranteed to take effect.
127.SS "Server Configuration"
128.TP
129.B alias \fIPATTERN\fR
130Defines the pattern use construct virtual filenames from \fBtrackname_\fR
131preferences.
132.IP
133Most characters stand for themselves, the exception being \fB{\fR which is used
134to insert a track name part in the form \fB{\fIname\fB}\fR or
135\fB{/\fIname\fB}\fR.
136.IP
137The difference is that the first form just inserts the name part while the
138second prefixes it with a \fB/\fR if it is nonempty.
139.IP
140The pattern should not attempt to include the collection root, which is
141automatically included, but should include the proper extension.
142.IP
143The default is \fB{/artist}{/album}{/title}{ext}\fR.
144.TP
637fdea3
RK
145.B authorization_algorthm \fIALGORITHM\fR
146Defines the algorithm used to authenticate clients. The valid options
147are sha1 (the default), sha256, sha384 and sha512. See
148.BR disorder_protocol (5)
149for more details.
150.TP
30ad4dab 151.B broadcast \fIADDRESS\fR \fIPORT\fR
152Transmit sound data to \fIADDRESS\fR using UDP port \fIPORT\fR. This implies
29573477 153\fBspeaker_backend network\fR.
30ad4dab 154.TP
155.B broadcast_from \fIADDRESS\fR \fIPORT\fR
156Sets the (local) source address used by \fBbroadcast\fR.
157.TP
460b9539 158.B channel \fICHANNEL\fR
159The mixer channel that the volume control should use. Valid names depend on
160your operating system and hardware, but some standard ones that might be useful
161are:
162.RS
163.TP 8
164.B pcm
165Output level for the audio device. This is probably what you want.
166.TP
167.B speaker
168Output level for the PC speaker, if that is connected to the sound card.
169.TP
170.B pcm2
171Output level for alternative codec device.
172.TP
173.B vol
174Master output level. The OSS documentation recommends against using this, as
175it affects all output devices.
176.RE
177.IP
178You can also specify channels by number, if you know the right value.
179.TP
180.B collection \fIMODULE\fR \fIENCODING\fR \fIROOT\fR
181Define a collection of tracks.
182.IP
183\fIMODULE\fR defines which plugin module should be used for this
184collection. Use the supplied \fBfs\fR module for tracks that exists
185as ordinary files in the filesystem.
186.IP
187\fIENCODING\fR defines the encoding of filenames in this collection.
188For \fBfs\fR this would be the encoding you use for filenames.
189Examples might be \fBiso-8859-1\fR or \fButf-8\fR.
190.IP
191\fIROOT\fR is the root in the filesystem of the filenames and is
192passed to the plugin module.
193.TP
194.B device \fINAME\fR
195ALSA device to play raw-format audio. Default is \fBdefault\fR, i.e. to use
196the whatever the ALSA configured default is.
197.TP
198.B gap \fISECONDS\fR
199Specifies the number of seconds to leave between tracks. The default
200is 2.
201.TP
202.B history \fIINTEGER\fR
203Specifies the number of recently played tracks to remember (including
204failed tracks and scratches).
205.TP
206.B listen \fR[\fIHOST\fR] \fISERVICE\fR
207Listen for connections on the address specified by \fIHOST\fR and port
208specified by \fISERVICE\fR. If \fIHOST\fR is omitted then listens on all
209local addresses.
210.IP
211Normally the server only listens on a UNIX domain socket.
212.TP
213.B lock yes\fR|\fBno
214Determines whether the server locks against concurrent operation. Default is
215\fByes\fR.
216.TP
217.B mixer \fIPATH\fR
218The path to the mixer device, if you want access to the volume control,
219e.g. \fB/dev/mixer\fR.
220.TP
23205f9c
RK
221.B multicast_ttl \fIHOPS\fR
222Set the maximum number of hops to send multicast packets. This only applies is
223\fBspeaker_backend\fR is set to \fBnetwork\fR and \fBbroadcast\fR is actually a
224multicast address.
225.TP
460b9539 226.B namepart \fIPART\fR \fIREGEXP\fR \fISUBST\fR [\fICONTEXT\fR [\fIREFLAGS\fR]]
227Determines how to extract trackname part \fIPART\fR from a
228track name (with the collection root part removed).
229Used in \fB@recent@\fR, \fB@playing@\fR and \fB@search@\fR.
230.IP
231Track names can be different in different contexts. For instance the sort
232string might include an initial track number, but this would be stripped for
233the display string. \fICONTEXT\fR should be a glob pattern matching the
234contexts in which this directive will be used.
235.IP
236Valid contexts are \fBsort\fR and \fBdisplay\fR.
237.IP
238All the \fBnamepart\fR directives are considered in order. The
239first directive for the right part, that matches the desired context,
240and with a \fIREGEXP\fR that
241matches the track is used, and the value chosen is constructed from
242\fISUBST\fR according to the substitution rules below.
243.IP
244Note that searches use the raw track name and \fBtrackname_\fR preferences but
245not (currently) the results of \fBnamepart\fR, so generating words via this option
246that aren't in the original track name will lead to confusing results.
247.IP
248If you supply no \fBnamepart\fR directives at all then a default set will be
249supplied automatically. But if you supply even one then you must supply all of
250them. See the example config file for the defaults.
251.TP
252.B nice_rescan \fIPRIORITY\fR
253Set the recan subprocess priority. The default is 10.
254.IP
255(Note that higher values mean the process gets less CPU time; UNIX priority
04e42396 256values are backwards.)
460b9539 257.TP
258.B nice_server \fIPRIORITY\fR
259Set the server priority. This is applied to the server at startup time (and
260not when you reload configuration). The server does not use much CPU itself
261but this value is inherited by programs it executes. If you have limited CPU
262then it might help to set this to a small negative value. The default is 0.
263.TP
264.B nice_speaker \fIPRIORITY\fR
265Set the speaker process priority. This is applied to the speaker process at
266startup time (and not when you reload the configuration). The speaker process
267is not massively CPU intensive by today's standards but depends on reasonably
268timely scheduling. If you have limited CPU then it might help to set this to a
269small negative value. The default is 0.
270.TP
2a10b70b
RK
271.B noticed_history
272The maximum days that a track can survive in the database of newly added
273tracks. The default is 31.
274.TP
460b9539 275.B player \fIPATTERN\fR \fIMODULE\fR [\fIOPTIONS.. [\fB--\fR]] \fIARGS\fR...
276Specifies the player for files matching the glob \fIPATTERN\fR. \fIMODULE\fR
277specifies which plugin module to use.
278.IP
279The following options are supported:
280.RS
281.TP
282.B --wait-for-device\fR[\fB=\fIDEVICE\fR]
283Waits (for up to a couple of seconds) for the default, or specified, libao
284device to become openable.
285.TP
286.B --
287Defines the end of the list of options. Needed if the first argument to the
288plugin starts with a "-".
289.RE
290.IP
291The following are the standard modules:
292.RS
293.TP
294.B exec \fICOMMAND\fR \fIARGS\fR...
295The command is executed via \fBexecvp\fR(3), not via the shell.
296The \fBPATH\fR environment variable is searched for the executable if it is not
297an absolute path.
298The command is expected to know how to open its own sound device.
299.TP
300.B execraw \fICOMMAND\fR \fIARGS\fR...
301Identical to the \fBexec\fR except that the player is expected to use the
ce6c36be 302DisOrder raw player protocol.
303.BR disorder-decode (8)
304can decode several common audio file formats to this format. If your favourite
305format is not supported, but you have a player which uses libao, there is also
306a libao driver which supports this format; see below for more information about
307this.
460b9539 308.TP
309.B shell \fR[\fISHELL\fR] \fICOMMAND\fR
310The command is executed using the shell. If \fISHELL\fR is specified then that
311is used, otherwise \fBsh\fR will be used. In either case the \fBPATH\fR
312environment variable is searched for the shell executable if it is not an
313absolute path. The track name is stored in the environment variable
314\fBTRACK\fR.
315.IP
316Be careful of the interaction between the configuration file quoting rules and
317the shell quoting rules.
318.RE
319.IP
320If multiple player commands match a track then the first match is used.
321.TP
322.B prefsync \fISECONDS\fR
323The interval at which the preferences log file will be synchronised. Defaults
324to 3600, i.e. one hour.
325.TP
459d4402 326.B queue_pad \fICOUNT\fR
327The target size of the queue. If random play is enabled then randomly picked
328tracks will be added until the queue is at least this big.
329.TP
405fea4e 330.B sample_format \fIBITS\fB/\fIRATE\fB/\fICHANNELS
331Describes the sample format expected by the \fBspeaker_command\fR (below). The
332components of the format specification are as follows:
333.RS
334.TP 10
335.I BITS
336The number of bits per sample. Optionally, may be suffixed by \fBb\fR or
337\fBl\fR for big-endian and little-endian words. If neither is used the native
338byte order is assumed.
339.TP
340.I RATE
341The number of samples per second.
342.TP
343.I CHANNELS
344The number of channels.
345.PP
346The default is
347.BR 16/44100/2 .
937be4c0
RK
348.PP
349With the
350.B network
351backend the sample format is forced to
352.B 16/44100/2b
353and with the
354.B coreaudio
355backend it is forced to
356.BR 16/44100/2 ,
357in both cases regardless of what is specified in the configuration file.
405fea4e 358.RE
359.TP
460b9539 360.B signal \fINAME\fR
361Defines the signal to be sent to track player process groups when tracks are
362scratched. The default is \fBSIGKILL\fR.
363.IP
364Signals are specified by their full C name, i.e. \fBSIGINT\fR and not \fBINT\fR
365or \fBInterrupted\fR or whatever.
366.TP
29573477 367.B speaker_backend \fINAME\fR
368Selects the backend use by the speaker process. The following options are
369available:
370.RS
371.TP
372.B alsa
373Use the ALSA API. This is only available on Linux systems, on which it is the
374default.
375.TP
937be4c0
RK
376.B coreaudio
377Use Apple Core Audio. This only available on OS X systems, on which it is the
378default.
379.TP
29573477 380.B command
381Execute a command. This is the default if
382.B speaker_command
937be4c0 383is specified, or if no native is available.
29573477 384.TP
385.B network
386Transmit audio over the network. This is the default if
803f6e52 387\fBbroadcast\fR is specified. You can use
388.BR disorder-playrtp (1)
389to receive and play the resulting stream on Linux and OS X.
29573477 390.RE
391.TP
5330d674 392.B sox_generation \fB0\fR|\fB1
393Determines whether calls to \fBsox\fR(1) should use \fB-b\fR, \fB-x\fR, etc (if
394the generation is 0) or \fB-\fIbits\fR, \fB-L\fR etc (if it is 1). The default
395is 0.
396.TP
405fea4e 397.B speaker_command \fICOMMAND
398Causes the speaker subprocess to pipe audio data into shell command
399\fICOMMAND\fR, rather than writing to a local sound card. The sample format is
400determine by
401.B sample_format
402above.
77cfc7a2 403.IP
404Note that if the sample format is wrong then
405.BR sox (1)
406is invoked to translate it. If
407.B sox
408is not installed then this will not work.
405fea4e 409.TP
460b9539 410.B restrict \fR[\fBscratch\fR] [\fBremove\fR] [\fBmove\fR]
411Determine which operations are restricted to the submitter of a
412track. By default, no operations are restricted, i.e. anyone can
413scratch or remove anything.
414.IP
415If \fBrestrict scratch\fR or \fBrestrict remove\fR are set then only the user
416that submitted a track can scratch or remove it, respectively.
417.IP
418If \fBrestrict move\fR is set then only trusted users can move tracks around in
419the queue.
420.IP
421If \fBrestrict\fR is used more than once then only the final use has any
422effect.
423.TP
424.B scratch \fIPATH\fR
425Specifies a scratch. When a track is scratched, a scratch track is
426played at random.
427Scratches are played using the same logic as other tracks.
428.IP
429At least for the time being, path names of scratches must be encoded using
430UTF-8 (which means that ASCII will do).
431.TP
432.B stopword \fIWORD\fR ...
433Specifies one or more stopwords that should not take part in searches
434over track names.
435.SS "Client Configuration"
436.TP
ccf0aafa 437.B connect \fIHOST SERVICE\fR
460b9539 438Connect to the address specified by \fIHOST\fR and port specified by
ccf0aafa 439\fISERVICE\fR.
460b9539 440.SS "Web Interface Configuration"
441.TP
442.B refresh \fISECONDS\fR
443Specifies the maximum refresh period in seconds. Default 15.
444.TP
445.B templates \fIPATH\fR ...
446Specifies the directory containing templates used by the web
447interface. If a template appears in more than one template directory
448then the one in the earliest directory specified is chosen.
449.IP
450See below for further details.
451.TP
452.B transform \fITYPE\fR \fIREGEXP\fR \fISUBST\fR [\fICONTEXT\fR [\fIREFLAGS\fR]]
453Determines how names are sorted and displayed in track choice displays.
454.IP
455\fITYPE\fR is the type of transformation; usually \fBtrack\fR or
456\fBdir\fR but you can define your own.
457.IP
458\fICONTEXT\fR is a glob pattern matching the context. Standard contexts are
459\fBsort\fR (which determines how directory names are sorted) and \fBdisplay\fR
460(which determines how they are displayed). Again, you can define your
461own.
462.IP
463All the \fBtransform\fR directives are considered in order. If
464the \fITYPE\fR, \fIREGEXP\fR and the \fICONTEXT\fR match
465then a new track name is constructed from
466\fISUBST\fR according to the substitution rules below. If several
467match then each is executed in order.
468.IP
469If you supply no \fBtransform\fR directives at all then a default set will be
470supplied automatically. But if you supply even one then you must supply all of
471them. See the example config file for the defaults.
472.TP
473.B url \fIURL\fR
474Specifies the URL of the web interface. This URL will be used in
475generated web pages.
476.IP
477This must be the full URL, e.g. \fBhttp://myhost/cgi-bin/jukebox\fR and not
478\fB/cgi-bin/jukebox\fR.
479.SS "Authentication Configuration"
480.TP
481.B allow \fIUSERNAME\fR \fIPASSWORD\fR
482Specify a username/password pair.
483.TP
484.B password \fIPASSWORD\fR
485Specify password.
486.TP
487.B trust \fIUSERNAME\fR
488Allow \fIUSERNAME\fR to perform privileged operations such as shutting
489down or reconfiguring the daemon, or becoming another user.
490.TP
491.B user \fIUSER\fR
492Specifies the user to run as. Only makes sense if invoked as root (or
493the target user).
494.TP
495.B username \fIUSERNAME\fR
496Specify username. The default is taken from the environment variable
497\fBLOGNAME\fR.
498.PP
499Configuration files are read in the following order:
500.TP
501.I pkgconfdir/config
502.TP
503.I pkgconfdir/config.private
504Should be readable only by the jukebox group, and contain \fBallow\fR
505commands for authorised users.
506.TP
507.I pkgconfdir/config.\fRUSER
508Per-user system-controlled client configuration. Optional but if it
509exists must be readable only by the relevant user. Would normally
510contain a \fBpassword\fR directive.
511.TP
512.I ~\fRUSER\fI/.disorder/passwd
513Per-user client configuration. Optional but if it exists must be
514readable only by the relevant user. Would normally contain a
515\fBpassword\fR directive.
516.SH "GLOBAL PREFERENCES"
517These are the values set with \fBset-global\fR.
518.TP
519.B required-tags
520If this is set an nonempty then randomly played tracks will always have at
521least one of the listed tags.
522.IP
523Tags can contain any printing character except comma. Leading and trailing
524spaces are not significant but internal spaces are. Tags in a list are
525separated by commas.
526.TP
527.B prohibited-tags
528If this is set an nonempty then randomly played tracks will never have any of
529the listed tags.
530.TP
531.B playing
532If unset or \fByes\fR then play is enabled. Otherwise it is disabled. Use
533\fBdisable\fR rather than setting it directly.
534.TP
535.B random-play
536If unset or \fByes\fR then random play is enabled. Otherwise it is disabled.
537Use \fBdisable\fR rather than setting it directly.
538.SH "LIBAO DRIVER"
539.SS "Raw Protocol Players"
540Raw protocol players are expected to use the \fBdisorder\fR libao driver.
541Programs that use libao generally have command line options to select the
542driver and pass options to it.
543.SS "Driver Options"
544The known driver options are:
545.TP
546.B fd
547The file descriptor to write to. If this is not specified then the driver
548looks like the environment variable \fBDISORDER_RAW_FD\fR. If that is not set
549then the default is 1 (i.e. standard output).
550.TP
551.B fragile
552If this is set to a nonzero value then the driver will call \fB_exit\fR(2) if a
553write to the output file descriptor fails. This is a workaround for buggy
554players such as \fBogg123\fR that ignore write errors.
555.SH "WEB TEMPLATES"
556When \fBdisorder.cgi\fR wants to generate a page for an action it searches the
557directories specified with \fBtemplates\fR for a matching file. It is
558suggested that you leave the distributed templates unchanged and put
559any customisations in an earlier entry in the template path.
560.PP
561The supplied templates are:
562.TP
563.B about.html
564Display information about DisOrder.
565.TP
566.B choose.html
567Navigates through the track database to choose a track to play. The
568\fBdir\fR argument gives the directory to look in; if it is missing
569then the root directory is used.
570.TP
571.B choosealpha.html
572Provides a front end to \fBchoose.html\fR which allows subsets of the top level
573directories to be selected by initial letter.
574.TP
d5b6ffd7
RK
575.B new.html
576Lists newly added tracks.
577.TP
460b9539 578.B playing.html
579The "front page", which usually shows the currently playing tracks and
580the queue.
581Gets an HTTP \fBRefresh\fR header.
582.IP
583If the \fBmgmt\fR CGI argument is set to \fBtrue\fR then we include extra
584buttons for moving tracks up and down in the queue. There is some logic in
585\fBdisorder.cgi\fR to ensure that \fBmgmt=true\fR is preserved across refreshes
586and redirects back into itself, but URLs embedded in web pages must include it
587explicitly.
588.TP
589.B prefs.html
590Views preferences. If the \fBfile\fR, \fBname\fR and \fBvalue\fR arguments are
591all set then that preference is modified; if \fBfile\fR and \fBname\fR are set
592but not \fBvalue\fR then the preference is deleted.
593.TP
594.B recent.html
595Lists recently played tracks.
596.TP
597.B search.html
598Presents search results.
599.TP
600.B volume.html
601Primitive volume control.
602.PP
603Additionally, other standard files are included by these:
604.TP
605.B credits.html
606Included at the end of the main content \fB<DIV>\fR element.
607.TP
d5b6ffd7
RK
608.B topbar.html
609Included at the start of the \fB<BODY>\fR element. (This supplants
610\fBsidebar.html\fR, though the latter is still available; override label
611\fBmenu\fR to choose between them.)
460b9539 612.TP
613.B stdhead.html
614Included in the \fB<HEAD>\fR element.
615.TP
616.B stylesheet.html
617Contains the default DisOrder stylesheet. You can override this by editing the
618CSS or by replacing it all with a \fB<LINK>\fR to an external stylesheet.
619.PP
620Templates are ASCII files containing HTML documents, with an expansion
621syntax to enable data supplied by the implementation to be inserted.
622.PP
623If you want to use characters outside the ASCII range, use either the
624appropriate HTML entity, e.g. \fB&eacute;\fR, or an SGML numeric
625character reference, e.g. \fB&#253;\fR. Use \fB&#64;\fR to insert a
626literal \fB@\fR without falling foul of the expansion syntax.
627.SS "Expansion Syntax"
628Expansions are surrounded by at ("@") symbols take the form of a keyword
629followed by zero or more arguments. Arguments may either be quoted by curly
630brackets ("{" and "}") or separated by colons (":"). Both kinds may be mixed
631in a single expansion, though doing so seems likely to cause confusion.
632The descriptions below contain suggested forms for each
633expansion.
634.PP
635Leading and trailing whitespace in unquoted arguments is ignored, as is
636whitespace (including newlines) following a close bracket ("}").
637.PP
638Arguments are recursively expanded before being interpreted, except for
639\fITEMPLATE\fR arguments. These are expanded (possibly more than once) to
640produce the final expansion.
641(More than once means the same argument being expanded more than once
642for different tracks or whatever, not the result of the first
643expansion itself being re-expanded.)
644.PP
645Strings constructed by expansions (i.e. not literally copied from the template
646text) are SGML-quoted: any character which does not stand for itself in #PCDATA
647or a quoted attribute value is replaced by the appropriate numeric character
648reference.
649.PP
650The exception to this is that such strings are \fInot\fR quoted when they are
651generated in the expansion of a parameter.
652.PP
653In the descriptions below, the current track means the one set by
654\fB@playing@\fR, \fB@recent@\fR or \fB@queue@\fR, not the one that is playing.
655If none of these expansions are in force then there is no current track.
656\fIBOOL\fR should always be either \fBtrue\fR or \fBfalse\fR.
657.SS "Expansions"
658The following expansion keywords are defined:
659.TP
660.B @#{\fICOMMENT\fB}@
661Ignored.
662.TP
663.B @action@
664The current action. This reports
665.B manage
666if the action is really
667.B playing
668but
669.B mgmt=true
670was set.
671.TP
672.B @and{\fIBOOL\fB}{\fIBOOL\fB}\fR...\fB@
673If there are no arguments, or all the arguments are \fBtrue\fB, then expands to
674\fBtrue\fR, otherwise to \fBfalse\fR.
675.TP
676.B @arg:\fINAME\fB@
677Expands to the value of CGI script argument \fINAME\fR.
678.TP
679.B @basename@
680The basename of the current directory component, in \fB@navigate@\fR.
681.TP
682.B @basename{\fIPATH\fB}@
683The base name part of \fIPATH\fR.
684.TP
685.B @choose{\fIWHAT\fB}{\fITEMPLATE\fB}@
686Expands \fITEMPLATE\fR repeatedly for each file or directory under
687\fB@arg:directory@\fR.
688\fIWHAT\fR should be either \fBfile\fR or \fBdirectory\fR.
689Use \fB@file@\fR to get the display name or filename of the file or
690directory.
691Usually used in \fBchoose.html\fR.
692.TP
693.B @dirname@
694The directory of the current directory component, in \fB@navigate@\fR.
695.TP
696.B @dirname{\fIPATH\fB}@
697The directory part of \fIPATH\fR.
698.TP
699.B @enabled@
700Expands to \fBtrue\fR if play is currently enabled, otherwise to \fBfalse\fR.
701.TP
702.B @eq{\fIA\fB}{\fIB\fB}
703Expands to \fBtrue\fR if \fIA\fR and \fIB\fR are identical, otherwise to
704\fBfalse\fR.
705.TP
706.B @file@
707Expands to the filename of the current file or directory, inside the template
708argument to \fBchoose\fR.
709.TP
710.B @files{\fITEMPLATE\fB}
711Expands \fITEMPLATE\fB once for each file indicated by the \fBdirectory\fR CGI
712arg if it is present, or otherwise for the list of files counted by \fBfiles\fR
713with names \fB0_file\fR, \fB1_file\fR etc.
714.TP
715.B @fullname@
716The full path of the current directory component, in \fB@navigate@\fR.
717.TP
718.B @id@
719The ID of the current track.
720.TP
721.B @if{\fIBOOL\fB}{\fITRUEPART\fB}{\fIFALSEPART\fB}@
722If \fIBOOL\fR expands to \fBtrue\fR then expands to \fITRUEPART\fR, otherwise
723to \fIFALSEPART\fR (which may be omitted).
724.TP
725.B @include:\fIPATH\fR@
726Include the named file as if it were a template file. If \fIPATH\fR
727starts with a \fB/\fR then it is used as-is; otherwise, ".html" is
728appended and the template path is searched.
729.TP
730.B @index@
731Expands to the index of the current file in \fB@queue@\fR, \fB@recent@\fR or
732\fB@files@\fR.
733.TP
734.B @isdirectories@
735Expands to \fBtrue\fR if there are any directories in \fB@arg:directory@\fR,
736otherwise to \fBfalse\fR.
737.TP
738.B @isfiles@
739Expands to \fBtrue\fR if there are any files in \fB@arg:directory@\fR,
740otherwise to \fBfalse\fR.
741.TP
742.B @isfirst@
743Expands to \fBtrue\fR if this is the first repetition of a \fITEMPLATE\fR
744argument in a loop (\fB@queue\fR or similar), otherwise to \fBfalse\fR.
745.TP
746.B @islast@
747Expands to \fBtrue\fR if this is the last repetition of a \fITEMPLATE\fR in a
748loop, otherwise to \fBfalse\fR.
749.TP
d5b6ffd7
RK
750.B @isnew@
751Expands to \fBtrue\fR if the newly added tracks list has any tracks in it,
752otherwise to \fBfalse\fR.
753.TP
460b9539 754.B @isplaying@
755Expands to \fBtrue\fR if a track is playing, otherwise to \fBfalse\fR.
756.TP
757.B @isqueue@
758Expands to \fBtrue\fR if there are any tracks in the queue, otherwise to
759\fBfalse\fR.
760.TP
761.B @isrecent@
762Expands to \fBtrue\fR if the recently played list has any tracks in it,
763otherwise to \fBfalse\fR.
764.TP
765.B @label:\fINAME\fR\fB@
766Expands to the value of label \fINAME\fR. See the shipped \fIoptions.labels\fR
767file for full documentation of the labels used by the standard templates.
768.TP
769.B @length@
770Expands to the length of the current track.
771.TP
772.B @navigate{\fIDIRECTORY\fB}{\fITEMPLATE\fB}
773Expands \fITEMPLATE\fR for each component of \fIDIRECTORY\fR in turn.
774Use \fB@dirname\fR and \fB@basename@\fR to get the components of the path to
775each component.
776Usually used in \fBchoose.html\fR.
777.TP
778.B @ne{\fIA\fB}{\fIB\fB}
779Expands to \fBtrue\fR if \fIA\fR and \fIB\fR differ, otherwise to \fBfalse\fR.
780.TP
d5b6ffd7
RK
781.B @new{\fITEMPLATE\fB}
782Expands \fITEMPLATE\fR for each track in the newly added tracks list, starting
783with the most recent. Used in \fBnew.html\fR.
784.TP
460b9539 785.B @nfiles@
786Expands to the number of files from \fB@files\fR (above).
787.TP
788.B @nonce@
789Expands to a string including the time and process ID, intended to be
790unique across invocations.
791.TP
792.B @not{\fIBOOL\fB}@
793Expands to \fBfalse\fR if \fIBOOL\fR is \fBtrue\fR, otherwise to
794\fBfalse\fR.
795.TP
796.B @or{\fIBOOL\fB}{\fIBOOL\fB}\fR...\fB@
797If at least one argument is \fBtrue\fB, then expands to \fBtrue\fR, otherwise
798to \fBfalse\fR.
799.TP
800.B @parity@
801Expands to \fBeven\fR or \fBodd\fR depending on whether the current track is at
802an even or odd position in \fB@queue@\fR, \fB@recent@\fR or \fB@files@\fR.
803.TP
804.B @part{\fICONTEXT\fB}{\fIPART\fB}@
805Expands to track name part \fIPART\fR using context \fICONTEXT\fR for the
806current track. The context may be omitted (and normally would be) and defaults
807to \fBdisplay\fR.
808.TP
809.B @part{\fICONTEXT\fB}{\fIPART\fB}{\fITRACK\fB}@
810Expands to track name part \fIPART\fR using context \fICONTEXT\fR for
811\fITRACK\fR. In this usage the context may not be omitted.
812.TP
813.B @paused@
814Expands to \fBtrue\fR if the current track is paused, else \fBfalse\fR.
815.TP
816.B @playing{\fITEMPLATE\fB}@
817Expands \fITEMPLATE\fR using the playing track as the current track.
818.TP
819.B @pref{\fITRACK\fB}{\fIKEY\fB}@
820Expand to the track preference, or the empty string if it is not set.
821.TP
822.B @prefname@
823Expands to the name of the current preference, in the template
824argument of \fB@prefs@\fR.
825.TP
826.B @prefs{\fIFILE\fB}{\fITEMPLATE\fB}@
827Expands \fITEMPLATE\fR repeatedly, for each preference of track
828\fIFILE\fR.
829Use \fB@prefname@\fR and \fB@prefvalue@\fR to get the name and value.
830.TP
831.B @prefvalue@
832Expands to the value of the current preference, in the template
833argument of \fB@prefs@\fR.
834.TP
835.B @queue{\fITEMPLATE\fB}@
836Expands \fITEMPLATE\fR repeatedly using the each track on the queue in turn as
837the current track. The track at the head of the queue comes first.
838.TP
839.B @random-enabled@
840Expands to \fBtrue\fR if random play is currently enabled, otherwise to
841\fBfalse\fR.
842.TP
843.B @recent{\fITEMPLATE\fB}@
844Expands \fITEMPLATE\fR repeatedly using the each recently played track in turn
845as the current track. The most recently played track comes first.
846.TP
847.B @resolve{\fITRACK\fB}@
848Resolve aliases for \fITRACK\fR and expands to the result.
849.TP
850.B @search{\fIPART\fB}\fR[\fB{\fICONTEXT\fB}\fR]\fB{\fITEMPLATE\fB}@
851Expands \fITEMPLATE\fR once for each group of search results that have
852a common value of track part \fIPART\fR.
853The groups are sorted by the value of the part.
854.IP
855.B @part@
856and
857.B @file@
858within the template will apply to one of the tracks in the group.
859.IP
860If \fICONTEXT\fR is specified it should be either \fBsort\fR or \fBdisplay\fR,
861and determines the context for \fIPART\fR. The default is \fBsort\fR. Usually
862you want \fBdisplay\fR for everything except the title and \fBsort\fR for the
863title. If you use \fBsort\fR for artist and album then you are likely to get
864strange effects.
865.TP
866.B @server-version@
867Expands to the server's version string.
868.TP
869.B @shell{\fICOMMAND\fB}@
870Expands to the output of \fICOMMAND\fR executed via the shell. \fBsh\fR is
871searched for using \fBPATH\fR. If the command fails then this is logged but
872otherwise ignored.
873.TP
874.B @state@
875In \fB@queue@\fR and \fB@recent@\fR, expands to the state of the current
876track. Otherwise the empty string. Known states are:
877.RS
878.TP 12
879.B failed
880The player terminated with nonzero status, but not because the track was
881scratched.
882.TP
883.B isscratch
884A scratch, in the queue.
885.TP
886.B no_player
887No player could be found.
888.TP
889.B ok
890Played successfully.
891.TP
892.B random
893A randomly chosen track, in the queue.
894.TP
895.B scratched
896This track was scratched.
897.TP
898.B unplayed
899An explicitly queued track, in the queue.
900.RE
901.IP
902Some additional states only apply to playing tracks, so will never be seen in
903the queue or recently-played list:
904.RS
905.TP 12
906.B paused
907The track has been paused.
908.TP
909.B quitting
910Interrupted because the server is shutting down.
911.TP
912.B started
913This track is currently playing.
914.RE
915.TP
916.B @stats@
917Expands to the server statistics.
918.TP
919.B @thisurl@
920Expands to the URL of the current page. Typically used in
921.B back
922arguments. If there is a
923.B nonce
924argument then it is changed to a fresh value.
925.TP
926.B @track@
927The current track.
928.TP
929.B @trackstate{\fIPATH\fB}@
930Expands to the current track state: \fBplaying\fR if the track is actually
931playing now, \fBqueued\fR if it is queued or the empty string otherwise.
932.TP
933.B @transform{\fIPATH\fB}{\fITYPE\fB}{\fICONTEXT\fB}@
934Transform a path according to \fBtransform\fR (see above).
935\fIPATH\fR should be a raw filename (of a track or directory).
936\fITYPE\fR should be the transform type (e.g. \fItrack\fR or \fIdir\fR).
937\fICONTEXT\fR should be the context, and can be omitted (the default
938is \fBdisplay\fR).
939.TP
940.B @url@
941Expands to the canonical URL as defined in \fIpkgconfdir/config\fR.
942.TP
943.B @urlquote{\fISTRING\fB}@
944URL-quote \fISTRING\fR.
945.TP
946.B @version@
947Expands to \fBdisorder.cgi\fR's version string.
948.TP
949.B @volume:\fISPEAKER\fB@
950The volume on the left or right speaker. \fISPEAKER\fR must be \fBleft\fB or
951\fBright\fR.
952.TP
953.B @when@
954When the current track was played (or when it is expected to be played, if it
955has not been played yet)
956.TP
957.B @who@
958Who submitted the current track.
959.SH "WEB OPTIONS"
960This is a file called \fIoptions\fR, searched for in the same manner
961as templates. It includes numerous options for the control of the web
962interface. The general syntax is the same as the main configuration
963file, except that it should be encoded using UTF-8 (though this might
964change to the current locale's character encoding; stick to ASCII to
965be safe).
966.PP
967The shipped \fIoptions\fR file includes four standard options files.
968In order, they are:
969.TP
970.I options.labels
971The default labels file. You wouldn't normally edit this directly - instead
972supply your own commands in \fIoptions.user\fR. Have a look at the shipped
973version of the file for documentation of labels used by the standard templates.
974.TP
975.I options.user
976A user options file. Here you should put any overrides for the default
977labels and any extra labels required by your modified templates.
978.PP
979Valid directives are:
980.TP
981.B columns \fINAME\fR \fIHEADING\fR...
982Defines the columns used in \fB@playing@\fR and \fB@recent@\fB. \fINAME\fR
983must be either \fBplaying\fR, \fBrecent\fR or \fBsearch\fR.
984\fIHEADING\fR... is a list of
985heading names. If a column is defined more than once then the last definitions
986is used.
987.IP
988The heading names \fBbutton\fR, \fBlength\fR, \fBwhen\fR and \fBwho\fR
989are built in.
990.TP
991.B include \fIPATH\fR
992Includes another file. If \fIPATH\fR starts with a \fB/\fR then it is
993taken as is, otherwise it is searched for in the template path.
994.TP
995.B label \fINAME\fR \fIVALUE\fR
996Define a label. If a label is defined more than once then the last definition
997is used.
998.SS Labels
999Some labels are defined inside \fBdisorder.cgi\fR and others by the
1000default templates. You can define your own labels and use them inside
1001a template.
1002.PP
1003When an undefined label is expanded, if it has a dot in its name then
1004the part after the final dot is used as its value. Otherwise the
1005whole name is used as the value.
1006.PP
1007Labels are no longer documented here, see the shipped \fIoptions.labels\fR file
1008instead.
1009.SH "REGEXP SUBSTITUTION RULES"
1010Regexps are PCRE regexps, as defined in \fBpcrepattern\fR(3). The
1011only option used is \fBPCRE_UTF8\fR. Remember that the configuration
1012file syntax means you have to escape backslashes and quotes inside
1013quoted strings.
1014.PP
1015In a \fISUBST\fR string the following sequences are interpreted
1016specially:
1017.TP
1018.B $1 \fR... \fB$9
1019These expand to the first to ninth bracketed subexpression.
1020.TP
1021.B $&
1022This expands to the matched part of the subject string.
1023.TP
1024.B $$
1025This expands to a single \fB$\fR symbol.
1026.PP
1027All other pairs starting with \fB$\fR are undefined (and might be used
1028for something else in the future, so don't rely on the current
1029behaviour.)
1030.PP
1031If \fBi\fR is present in \fIREFLAGS\fR then the match is case-independent. If
1032\fBg\fR is present then all matches are replaced, otherwise only the first
1033match is replaced.
1034.SH "ACTIONS"
1035What the web interface actually does is terminated by the \fBaction\fR CGI
1036argument. The values listed below are supported.
1037.PP
1038Except as specified, all actions redirect back to the \fBplaying.html\fR
1039template unless the \fBback\fR argument is present, in which case the URL it
1040gives is used instead.
1041.PP
1042Redirection to \fBplaying.html\fR preserves \fBmgmt=true\fR if it is present.
1043.TP 8
1044.B "move"
1045Move track \fBid\fR by offset \fBdelta\fR.
1046.TP
1047.B "play"
1048Play track \fBfile\fR, or if that is missing then play all the tracks in
1049\fBdirectory\fR.
1050.TP
1051.B "playing"
1052Don't change any state, but instead compute a suitable refresh time and include
1053that in an HTTP header. Expands the \fBplaying.html\fR template rather than
1054redirecting.
1055.IP
1056This is the default if \fBaction\fR is missing.
1057.TP
1058.B "random-disable"
1059Disables random play.
1060.TP
1061.B "random-enable"
1062Enables random play.
1063.TP
1064.B "disable"
1065Disables play completely.
1066.TP
1067.B "enable"
1068Enables play.
1069.TP
1070.B "pause"
1071Pauses the current track.
1072.TP
1073.B "remove"
1074Remove track \fBid\fR.
1075.TP
1076.B "resume"
1077Resumes play after a pause.
1078.TP
1079.B "scratch"
1080Scratch the playing track. If \fBid\fR is present it must match the playing
1081track.
1082.TP
1083.B "volume"
1084Change the volume by \fBdelta\fR, or if that is missing then set it to the
1085values of \fBleft\fR and \fBright\fR. Expands to the \fBvolume.html\fR template
1086rather than redirecting.
1087.TP
1088.B "prefs"
1089Adjust preferences from the \fBprefs.html\fR template (which it then expands
1090rather than redirecting).
1091.IP
1092If
1093.B parts
1094is set then the cooked interface is assumed. The value of
1095.B parts
1096is used to determine which trackname preferences are set. By default the
1097.B display
1098context is adjusted but this can be overridden with the
1099.B context
1100argument. Also the
1101.B random
1102argument is checked; if it is set then random play is enabled for that track,
1103otherwise it is disabled.
1104.IP
1105Otherwise if the
1106.B name
1107and
1108.B value
1109arguments are set then they are used to set a single preference.
1110.IP
1111Otherwise if just the
1112.B name
1113argument is set then that preference is deleted.
1114.IP
1115It is recommended that links to the \fBprefs\fR action use \fB@resolve@\fR to
1116enure that the real track name is always used. Otherwise if the preferences
1117page is used to adjust a trackname_ preference, the alias may change, leading
1118to the URL going stale.
1119.TP
1120.B "error"
1121This action is generated automatically when an error occurs connecting to the
1122server. The \fBerror\fR label is set to an indication of what the error is.
1123.SH "TRACK NAME PARTS"
1124The traditional track name parts are \fBartist\fR, \fBalbum\fR and \fBtitle\fR,
1125with the obvious intended meaning. These are controlled by configuration and
1126by \fBtrackname_\fR preferences.
1127.PP
1128In addition there are two built-in parts, \fBpath\fR which is the whole path
1129name and \fBext\fR which is the filename extension, including the initial dot
1130(or the empty string if there is not extension).
1131.SH "SEE ALSO"
77cfc7a2 1132\fBdisorder\fR(1), \fBsox\fR(1), \fBdisorderd\fR(8), \fBdisorder-dump\fR(8),
460b9539 1133\fBpcrepattern\fR(3)
1134.\" Local Variables:
1135.\" mode:nroff
1136.\" fill-column:79
1137.\" End: