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