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