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