1. scmus(3)
  2. scmus Scripting Reference
  3. scmus(3)

NAME

scmus - scmus Scripting Environment

SYNOPSIS

(bind keys context expression [force])
(can-set-color?)
(clear-queue)
(colorscheme name)
(command arg ...)
(*command cmd)
(connect [host [port [password]]])
(consume?)
(consume-set true-or-false)
(current-bitrate)
(current-elapsed)
(current-track)
(current-volume)
(define-command (name args ...) body ...)
(describe object)
(disconnect)
(echo arg ...)
(enter-command-mode [text [cursor-pos]])
(enter-eval-mode [text [cursor-pos]])
(enter-search-mode [text [cursor-pos]])
(exit)
(get-environment-variable name)
(get-option name)
(load path)
(mixramp-db)
(mixramp-delay)
(mpd-address)
(mpd-host)
(mpd-port)
(next)
(next-id)
(next-pos)
(pause)
(play)
(playlist-add name uri)
(playlist-clear name)
(playlist-delete name song-pos)
(playlist-edit name)
(playlist-load name)
(playlist-move name song-id song-pos)
(playlist-rename name new-name)
(playlist-rm name)
(playlist-save name)
(prev)
(queue-delete pos)
(queue-delete (start . end))
(queue-delete-id song-id)
(queue-length)
(queue-move from to)
(queue-move (start . end) to)
(queue-move-id song-id to)
(queue-swap pos-a pos-b)
(queue-swap-id id-a id-b)
(queue-version)
(quit)
(random?)
(random-set true-or-false)
(refresh-library)
(register-command name handler [force?])
(register-event-handler event handler)
(repeat?)
(repeat-set true-or-false)
(rescan [path])
(scmus-format format [track [length]])
(seek seconds)
(set-option name value)
(set-view name)
(set-volume value [relative?])
(shell command . args)
(shell-sync command . args)
(shell-term command . args)
(shell/capture-stdout command . args)
(shuffle)
(single?)
(single-set true-or-false)
(start-timer thunk seconds #!key (recurring? #f))
(state)
(stop)
(toggle-consume)
(toggle-random)
(toggle-repeat)
(toggle-single)
(track-album track)
(track-albumartist track)
(track-artist track)
(track-composer track)
(track-date track)
(track-disc track)
(track-duration track)
(track-end track)
(track-file track)
(track-genre track)
(track-id track)
(track-last-modified track)
(track-name track)
(track-performer track)
(track-pos track)
(track-prio track)
(track-start track)
(track-title track)
(track-track track)
(unbind keys context)
(update [path])
(win-activate)
(win-add [dst])
(win-bottom)
(win-clear)
(win-clear-marked)
(win-deactivate)
(win-edit)
(win-mark)
(win-unmark)
(win-move nr [relative?])
(win-paste [before?])
(win-remove)
(win-search query)
(win-search-next)
(win-search-prev)
(win-toggle-mark)
(win-top)
(write-config filename)
(xfade)

DESCRIPTION

(bind keys context expression [force])

Bind keys to expression in context. If force is #t, then any binding conflicting with keys is first unbound. Otherwise, if there is a conflicting binding then this function will fail to bind keys and return #f. If expression is a string, then it is implicitly wrapped in a call to *command: (*command expression).

(can-set-color?)

Returns #t if the terminal is capable or redefining colors (in which case set-color may be used), otherwise #f.

(clear-queue)

Remove all tracks from the play queue.

(colorscheme name)

Load the colorscheme name. This function looks for a file named name.scm in the scmus colorscheme directory (usually /usr/local/share/scmus/colors/).

(command name arg ...)

Execute the command name with the given arguments. The command name and arguments are converted to strings (as if by display) and read as if implicitly double-quoted.

(*command cmd)

Pass the string cmd to the command interpreter, as if entered on the command line. When *command is used in a key binding, the expression is displayed in bindings-view as a bare command string rather than a Scheme expression.

(connect [host [port [password]]])

Connect to the MPD server given by password@host:port, using the values of the mpd-address, mpd-port and mpd-password options if they are not provided as arguments.

(consume?)

Returns #t if MPD is currently in consume mode, otherwise #f.

(consume-set true-or-false)

Set the value of the consume MPD option to true-or-false.

(current-bitrate)

Returns the current bitrate of the playing audio.

(current-elapsed)

Returns the position within the current track as a number of seconds.

(current-track)

Returns the track object for the currently playing track.

(current-volume)

Returns the current volume level.

(define-command (name args ...) body ...)

Defines a handler for the command name, taking arguments args and executing body when the command is run. A dotted tail may be used in the argument list to accept an arbitrary number of arguments.

(describe object)

Print a description of object on the command line. If object is a symbol, then a description is printed for the object bound to the symbol.

(disconnect)

Disconnects from the current MPD server.

(echo arg ...)

Prints its arguments to the command line, each separated by a space.

(enter-command-mode [text [cursor-pos]])

Enter command mode (a mode in which commands may be entered on the command line). If text is given, then the text is added on the command line. If cursor-pos is given, then the cursor is moved to the given position within text.

(enter-eval-mode [text [cursor-pos]])

Enter eval mode (a mode in which scheme expressions may be entered on the command line). See enter-command-mode for a description of the arguments to this procedure.

(enter-search-mode [text [cursor-pos]])

Enter search mode (a mode in which a search query may be entered on the command line). See enter-command-mode for a description of the arguments to this procedure.

(exit)

Exit scmus.

(get-environment-variable name)

Returns the value of the environment variable name, or #f if it is not set.

(get-option name)

Returns the value of the option name.

(load path)

Loads the file at path, which can be either a Scheme source file (with extension .scm) or a command script (extension .scmd).

(mixramp-db)

Returns the current value of the mixrampdb MPD setting.

(mixramp-delay)

Returns the current value of the mixrampdelay MPD setting.

(mpd-address)

Returns the IP address of the connected MPD server in XXX.XXX.XXX.XXX notation.

(mpd-host)

Returns the hostname of the connected MPD server.

(mpd-port)

Returns the port number of the connected MPD server.

(next)

Skip to the next track.

(next-id)

Returns the ID of the next track in the play queue.

(next-pos)

Returns the position of the next track in the play queue.

(pause)

Toggle pause.

(play [track-or-pos])

Begin playing a track. If track-or-pos is a track object, then the given track is played. If track-or-pos is an integer, then the track at that position in the play queue is played. If track-or-pos is ommitted then the current track is played from the beginning.

(playlist-add name uri)

Add uri to the playlist given by name.

(playlist-clear name)

Clear the playlist given by name.

(playlist-delete name song-pos)

Delete the track at song-pos from the playlist given by name.

(playlist-edit name)

Load the playlist given by name into the playlist editor.

(playlist-load name)

Load the playlist given by name into the play queue.

(playlist-move name songid song-pos)

Add song-id in the playlist given by name to the position song-pos.

(playlist-rename name new-name)

Rename the playlist name to new-name.

(playlist-rm name)

Delete the playlist given by name.

(playlist-save name)

Save the current playlist (i.e. the play queue) as name.

(prev)

Skip to the previous track.

(queue-delete pos)

Remove the track at position pos from the play queue.

(queue-delete (start . end))

Remove the tracks between positions start (inclusive) and end (exclusive) from the play queue.

(queue-delete-id song-id)

Remove the track with ID song-id from the play queue.

(queue-length)

Returns the length of the play queue (the number of tracks).

(queue-move from to)

Move the track at position from to position to in the play queue.

(queue-move (start . end) to)

Move the tracks between positions start (inclusive) and end (exclusive) to position to in the play queue.

(queue-move-id song-id to)

Move the track with ID song-id to position to in the play queue.

(queue-swap pos-a pos-b)

Swap the tracks at positions pos-a and pos-b in the play queue.

(queue-swap-id id-a id-b)

Swap the tracks with IDs id-a and id-b in the play queue.

(queue-version)

Returns the current version of the queue.

(quit)

Display a [y/N] confirmation prompt and exit scmus.

(random?)

Returns #t if MPD is currently in random mode, otherwise #f.

(random-set true-or-false)

Set the value of the random MPD option to true-or-false.

(refresh-library)

Refresh the data in the library view.

(register-command name handler [force?])

Register handler as a handler for the command name. If force? is #t, then handler will be registered even if a handler already exists for name. Returns #t if handler was successfully registered, otherwise #f.

(register-event-handler event handler)

Register handler as a handler for the event event.

(repeat?)

Returns #t if MPD is currently in repeat mode, otherwise #f.

(repeat-set true-or-false)

Set the value of the repeat MPD option to true-or-false.

(rescan [path])

Update the music data, rescanning even unmodified files. If path is given, then only that path is updated.

(scmus-format format [track [length]])

Returns a string formatted according to the format string format. If track is given, then it is used as the data source for the format string, otherwise it defaults to the null track. If length is given, then it is used as the available size (in terminal columns) of the output string, otherwise it defaults to the current terminal width minus two. See the Format Strings section in scmus(1) for information about format strings in scmus.

(seek seconds)

Seek seconds relative to the current position in the current track.

(set-color color-number rgb)

Set the value of the terminal color given by color-number to the RGB value given by rgb. (Hint: you can use Scheme's hexadecimal syntax, e.g. #xFFFFFF.)

(set-color color-number r g b)

Set the value of the terminal color given by color-number to the RGB values given by r g and b. The valid range for these values is 0-1000.

(set-option name value)

Set the value of the option given by name to value.

(set-view name)

Change the current view to the view given by name.

(set-volume value [relative?])

Set MPD's volume level. If relative? is given and not #f, then value is interpreted relative to the current volume level.

(shell command . args)

Run the command command with arguments args in a separate process.

(shell-sync command . args)

Run the command command with arguments args in a separate process. This function blocks until the child process exits, and returns the status code.

(shell-term command . args)

Like shell-sync, except that curses is temporarily disabled while the command runs.

(shell/capture-stdout command . args)

Like shell-sync, except that the child process's output on standard output is returned as a string instead of the status code.

(shuffle)

Shuffles the order of tracks in the play queue.

(single?)

Returns #t if MPD is currently in single mode, otherwise #f.

(single-set true-or-false)

Set the value of the single MPD option to true-or-false.

(start-timer thunk seconds #!key (recurring? #f))

Set a timer to expire in seconds seconds. When the timer expires, the procedure thunk is called with no arguments. If recurring? is given and not #f, then the timer will re-arm itself to expire again in seconds seconds after thunk returns.

(state)

Returns one of [pause play stop unknown] if MPD is paused, playing, stopped or in an unknown state, respectively.

(stop)

Stop playing the current track.

(toggle-consume)

Toggle the value of the consume MPD option.

(toggle-random)

Toggle the value of the random MPD option.

(toggle-repeat)

Toggle the value of the repeat MPD option.

(toggle-single)

Toggle the value of the single MPD option.

(track-album track)

Returns the album tag for the track track.

(track-albumartist track)

Returns the albumartist tag for the track track.

(track-artist track)

Returns the artist tag for the track track.

(track-composer track)

Returns the composer tag for the track track.

(track-date track)

Returns the date tag for the track track.

(track-disc track)

Returns the disc number tag for the track track.

(track-duration track)

Returns the duration of the track track.

(track-end track)

Returns the end position of the track track.

(track-file track)

Returns the filename for the track track.

(track-genre track)

Returns the genre tag for the track track.

(track-id track)

Returns the ID of the track track. Undefined if track wasn't obtained from the play queue.

(track-last-modified track)

Return the POSIX UTC time stamp for the track track.

(track-name track)

Return the name tag for the track track.

(track-performer track)

Returns the performer tag for the track track.

(track-pos track)

Returns the position of the track track in the play queue. Undefined if track wasn't obtained from the play queue.

(track-prio track)

Returns the priority of the track track in the play queue. Undefined if track wasn't obtained from the play queue.

(track-start track)

Returns the start position of the track track.

(track-title track)

Returns the title tag for the track track.

(track-track track)

Returns the track number tag for the track track.

(unbind keys context)

Remove the binding for keys in context, or any bindings in conflict with keys.

(update [path])

Update the music database. If path is given, then only that path is updated.

(win-activate)

Activate the current window. What this means depends on the view and the current selection. E.g. in queue view, this function will begin playing the selected track.

(win-add [dst])

Add the current selection to the play queue or playlist editor. dst should be either 'queue or 'playlist. If dst is not given, it defaults to 'queue.

(win-bottom)

Move the cursor to the bottom of the current window.

(win-clear)

Clear the current window.

(win-clear-marked)

Clear the marked items in the current window.

(win-deactivate)

Deactivate the current window. What this means depends on the view and the current selection. E.g. in library view, this navigates backwards in the artist/album/file/metadata hierarchy.

(win-edit)

Begin editing the selected item in the current window (when applicable).

(win-mark)

Mark the selected item in the current window.

(win-unmark)

Clear the mark on the selected item in the current window.

(win-move nr [relative?])

Move the cursor up or down nr rows in the current window. Positive values for nr mean move down; negative values mean move up. If relative is #t then nr is interpreted as a percentage of the visible rows.

(win-paste [before?])

Paste the marked lines at the cursor. If before? is given and not #f, then the lines are pasted under the cursor; otherwise they are pasted beginning at the line after the cursor.

(win-remove)

Remove the selected item in the current window (when applicable).

(win-search query)

Search for query in the current window.

(win-search-next)

Select the next match after the cursor for the current search query.

(win-search-prev)

Select the next match before the cursor for the current search query.

(win-toggle-mark)

Toggle the marked status of the selected item in the current window.

(win-top)

Move the cursor to the top of the current window.

(write-config filename)

Write the current options to filename, such that a subsequent call to (load filename) would restore scmus's options to the current values.

(xfade)

Returns the current value of the xfade MPD option.

BUGS

You can submit bugs to the issue tracker on Github (https://github.com/drewt/scmus/issues).

SEE ALSO

scmus(1)

AUTHOR

scmus was written by Drew Thoreson <drew.thoreson@alumni.ubc.ca>.

  1. January 2019
  2. scmus(3)