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