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