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