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