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