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