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