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