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