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