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