Back to Spotify Player

Configuration Documentation

docs/config.md

0.23.020.6 KB
Original Source

Configuration Documentation

Table of Contents

Configuration files are located in the application's configuration directory, which defaults to $HOME/.config/spotify-player.

General

A sample app.toml is available at examples/app.toml.

spotify_player uses app.toml for application settings. Available options:

OptionDescriptionDefault
client_idSpotify client ID for API access. Uses a default if not specified.See code (default: ncspot's client ID)
client_id_commandShell command that outputs client ID to stdout (overrides client_id).None
login_redirect_uriRedirect URI for authentication.http://127.0.0.1:8989/login
client_portPort for the application's client to handle CLI commands.8080
log_folderPath to store log files.None
tracks_playback_limitMaximum number of tracks in a playback session.50
playback_formatFormat string for the playback window.{status} {track} • {artists} {liked}\n{album} • {genres}\n{metadata}
playback_metadata_fieldsOrdered list of metadata fields displayed in the playback UI {metadata} placeholder.["repeat", "shuffle", "volume", "device"]
notify_formatNotification format (if notify feature enabled).{ summary = "{track} • {artists}", body = "{album}" }
notify_timeout_in_secsNotification timeout in seconds (if notify feature enabled).0
notify_transientSend transient notifications (Linux only, if notify feature enabled).false
player_event_hook_commandCommand to execute on player events.None
ap_portSpotify session connection port.None
proxySpotify session connection proxy.None
themeName of the theme to use.default
app_refresh_duration_in_msInterval (ms) between application refreshes.32
playback_refresh_duration_in_msInterval (ms) between playback refreshes.0
page_size_in_rowsNumber of rows per page for navigation.20
enable_media_controlEnable media control support (requires media-control feature).true (Linux), false (macOS/Windows)
enable_streamingEnable streaming (Always, Never, or DaemonOnly).Always
enable_audio_visualizationShow a real-time frequency bar chart in the playback window (requires streaming feature).false
enable_notifyEnable notifications (requires notify feature).true
enable_cover_image_cacheCache album cover images.true
notify_streaming_onlySend notifications only when streaming is active (requires streaming and notify features).false
default_deviceDefault device to connect to on startup.spotify-player
play_iconIcon for playing state.
pause_iconIcon for paused state.▌▌
liked_iconIcon for liked songs.
explicit_iconIcon for explicit songs.(E)
border_typeBorder style: Hidden, Plain, Rounded, Double, or Thick.Plain
progress_bar_typeProgress bar style: Rectangle or Line.Rectangle
progress_bar_positionProgress bar position: Bottom or Right.Bottom
layoutLayout configuration (see below).See below
genre_numMax number of genres to display in playback text.2
cover_img_lengthCover image length (requires image feature).9
cover_img_widthCover image width (requires image feature).5
cover_img_scaleCover image scale (requires image feature).1.0
cover_img_pixelsPixels per side for cover image (requires pixelate feature).16
seek_duration_secsSeek duration in seconds for seek commands.5
sort_artist_albums_by_typeSort albums by type on artist pages.false
volume_scroll_stepVolume change step when using mouse scroll.5
enable_mouse_scroll_volumeEnable volume control via mouse scroll.true
deviceDevice configuration (see below).See below

Notes

  • By default, spotify-player uses ncspot's client ID for compatibility with Spotify's API. See this issue for details.
  • ap_port and proxy are passed to Librespot for session configuration. Librespot uses its defaults if unset.
  • Setting a positive app_refresh_duration_in_ms increases API usage and may trigger rate limits. By default, playback_refresh_duration_in_ms=0 refreshes playback only on events or commands.
  • enable_streaming accepts Always, Never, or DaemonOnly. For backward compatibility, true/false are also accepted.
  • border_type, progress_bar_type, and progress_bar_position accept only the values listed in the table above.
  • explicit_icon can be set to any Unicode character or an empty string to disable explicit markers.

Media control

Media control (enable_media_control) is enabled by default on Linux but disabled on macOS and Windows. On these platforms, the OS requires an open window to receive media events, which may cause the terminal to lose focus on startup.

Player event hook command

player_event_hook_command is an object with command and args fields. On each player event, the command executes with the event data passed as arguments.

A player event is represented as a list of arguments with either of the following values:

  • "Changed" NEW_TRACK_ID
  • "Playing" TRACK_ID POSITION_MS
  • "Paused" TRACK_ID POSITION_MS
  • "EndOfTrack" TRACK_ID

Note: If args is specified, these arguments precede the event arguments.

For example, with player_event_hook_command = { command = "a.sh", args = ["-b", "c", "-d"] }, a Changed event with NEW_TRACK_ID=id executes:

shell
a.sh -b c -d Changed id

Example script that reads event data from arguments and logs to a file:

sh
#!/bin/bash

set -euo pipefail

case "$1" in
    "Changed") echo "command: $1, new_track_id: $2" >> /tmp/log.txt ;;
    "Playing") echo "command: $1, track_id: $2, position_ms: $3" >> /tmp/log.txt ;;
    "Paused") echo "command: $1, track_id: $2, position_ms: $3" >> /tmp/log.txt ;;
    "EndOfTrack") echo "command: $1, track_id: $2" >> /tmp/log.txt ;;
esac

Client id command

To securely store your client_id, use client_id_command with a command and optional args. Example:

toml
client_id_command = { command = "cat", args = ["/full/path/to/file"] }

Note: Use absolute paths; ~ is not expanded.

Device configuration

Device options are configured in the [device] section:

OptionDescriptionDefault
nameDevice name.spotify-player
device_typeDevice type.speaker
volumeInitial volume (percent).70
bitrateBitrate in kbps (96, 160, or 320).320
audio_cacheEnable audio file caching.false
normalizationEnable audio normalization.false
autoplayEnable autoplay of similar songs.false

See the Librespot wiki for more details on these options.

Layout configuration

The [layout] section configures the UI layout:

OptionDescriptionDefault
library.album_percentPercentage of the album window in the library.40
library.playlist_percentPercentage of the playlist window in the library.40
playback_window_positionPosition of the playback window (Top or Bottom).Top
playback_window_heightHeight of the playback window.6

Example:

toml

[layout]
library = { album_percent = 40, playlist_percent = 40 }
playback_window_position = "Top"

Themes

spotify_player uses theme.toml for custom themes.

Sample themes are available at examples/theme.toml.

Select a theme by setting theme in app.toml or using the -t <THEME> / --theme <THEME> CLI flag.

A theme consists of:

  • name (required): Theme name.
  • palette (optional): Color palette.
  • component_style (optional): Styles for UI components.

Omitted palette values use terminal colors. Omitted component_style values use default styles.

Component Styles

The component_style table customizes UI component appearance. All fields are optional:

FieldDescription
block_titleStyle for block titles
borderStyle for borders
playback_statusStyle for the playback status indicator
playback_trackStyle for the currently playing track name
playback_artistsStyle for the artist(s) of the current track
playback_albumStyle for the album name of the current track
playback_genresStyle for the genres of the current track
playback_metadataStyle for the metadata section in playback
playback_progress_barStyle for the filled portion of the playback progress bar
playback_progress_bar_unfilledStyle for the unfilled portion (only for Line type)
current_playingStyle for the currently playing item in lists
page_descStyle for the page description
playlist_descStyle for the playlist description
table_headerStyle for table headers
selectionStyle for selected items
secondary_rowStyle for secondary rows in tables/lists
likeStyle for the like indicator
lyrics_playedStyle for played lyrics lines
lyrics_playingStyle for the currently playing lyrics line

Each style accepts optional fields:

  • fg: Foreground color
  • bg: Background color
  • modifiers: List of style modifiers

Defaults use palette values or remain unset if not specified.

Example

toml
[[themes]]
name = "my_theme"
[themes.component_style]
block_title = { fg = "Magenta", modifiers = ["Bold"] }
border = { fg = "White" }
selection = { modifiers = ["Reversed", "Bold"] }

Default Component Styles

toml
block_title = { fg = "Magenta"  }
border = {}
playback_status = { fg = "Cyan", modifiers = ["Bold"] }
playback_track = { fg = "Cyan", modifiers = ["Bold"] }
playback_artists = { fg = "Cyan", modifiers = ["Bold"] }
playback_album = { fg = "Yellow" }
playback_genres = { fg = "BrightBlack", modifiers = ["Italic"] }
playback_metadata = { fg = "BrightBlack" }
playback_progress_bar = { bg = "BrightBlack", fg = "Green" }
playback_progress_bar_unfilled = { bg = "BrightBlack" }
current_playing = { fg = "Green", modifiers = ["Bold"] }
page_desc = { fg = "Cyan", modifiers = ["Bold"] }
playlist_desc = { fg = "BrightBlack", modifiers = ["Dim"] }
table_header = { fg = "Blue" }
selection = { modifiers = ["Reversed", "Bold"] }
secondary_row = {}
like = {}
lyrics_played = { modifiers = ["Dim"] }
lyrics_playing = { fg = "Green", modifiers = ["Bold"] }

Accepted Colors

Colors can be:

  • Black, Blue, Cyan, Green, Magenta, Red, White, Yellow
  • BrightBlack, BrightWhite, BrightRed, BrightMagenta, BrightGreen, BrightCyan, BrightBlue, BrightYellow
  • Hex codes: #RRGGBB (e.g., #ff0000)

Style Modifiers

Supported modifiers:

  • Bold
  • Dim
  • Italic
  • Underlined
  • RapidBlink
  • Reversed
  • Hidden
  • CrossedOut

Specify multiple modifiers as a list: modifiers = ["Bold", "Underlined"].

Use script to add theme

The theme_parse Python script (requires toml and requests) converts iTerm2/alacritty color schemes to compatible theme format.

Example:

./theme_parse "Builtin Solarized Dark" "solarized_dark"  >> ~/.config/spotify-player/theme.toml

This converts the Builtin Solarized Dark color scheme to a theme named solarized_dark.

Palette

A theme's palette table can include:

  • background
  • foreground
  • black
  • blue
  • cyan
  • green
  • magenta
  • red
  • white
  • yellow
  • bright_black
  • bright_blue
  • bright_cyan
  • bright_green
  • bright_magenta
  • bright_red
  • bright_white
  • bright_yellow

Omitted fields use terminal defaults. Values can be color names or hex codes. See ANSI color reference.

Keymaps

spotify_player uses keymap.toml to add or override default key mappings. Add a keymaps entry to define a new mapping, or set the command to None to remove one. Example:

toml
[[keymaps]]
command = "NextTrack"
key_sequence = "g n"
[[keymaps]]
command = "PreviousTrack"
key_sequence = "g p"
[[keymaps]]
command = "Search"
key_sequence = "C-c C-x /"
[[keymaps]]
command = "ResumePause"
key_sequence = "M-enter"
[[keymaps]]
command = "None"
key_sequence = "q"
[[keymaps]]
command = { VolumeChange = { offset = 1 } }
key_sequence = "-"
[[keymaps]]
command = { SeekForward = { duration = 10 } }
key_sequence = "E"
[[keymaps]]
command = { SeekBackward = { } }
key_sequence = "Q"

A complete list of actions is available here.

Actions

Actions are defined in keymap.toml and triggered by unbound key sequences. Actions target the selected item by default, but can be configured with target set to PlayingTrack or SelectedItem. See the README for available actions.

Example:

toml
[[actions]]
action = "GoToArtist"
key_sequence = "g A"
[[actions]]
action = "GoToAlbum"
key_sequence = "g B"
target = "PlayingTrack"
[[actions]]
action="ToggleLiked"
key_sequence="C-l"