/spotify.nvim

Control Spotify from Neovim, powered by D-Bus.

Primary LanguagePythonMIT LicenseMIT

Spotify.nvim

Control Spotify from Neovim.

1 2

Showing status using nvim-notify

Requirements

  • Linux operating system (this plugin doesn't work on Windows, and I not sure about Mac).
  • pydbus (see requirements).
    • If you are using pyenv to manage your Python provider, make sure you use: pyenv virtualenv --system-site-packages system neovim to create it.
  • wmctrl (optional, required only for the show command)
    • sudo apt-get install wmctrl
    • sudo dnf install wmctrl

Installation

Install using vim-plug. Put this on your init.vim.

Plug 'stsewd/spotify.nvim', { 'do': ':UpdateRemotePlugins' }

Usage

  • Start Spotify.
  • Call :Spotify {option}. Where option can be:
    • play/pause
    • next
    • prev
    • play
    • pause
    • stop
    • show: Focus Spotify window
    • status: Show current song and player status
    • volume [value]: Set the volume to value. The value is a number from 0 to 100, you can prefix the value with + or - to change the volume relatively to the current value.
    • time [value]: Set the time of the current song to value. The value is given in seconds, you can prefix the value with + or - to change the time relatively to the current value.
    • shuffle [value]: De/activate shuffle. The value can be on or off,

Configuration

Show the player status after each command

g:spotify_show_status = 1

Symbols used in the player status

See below for inspiration.

let g:spotify_symbols = {
    \ "playing": "โ–ถ",
    \ "paused": "โธ",
    \ "stopped": "โ– ",
    \ "volume.high": "๐Ÿ”Š",
    \ "volume.medium": "๐Ÿ”‰",
    \ "volume.low":  "๐Ÿ”ˆ",
    \ "volume.muted": "๐Ÿ”‡",
    \ "shuffle.enabled": "โคฎ on",
    \ "shuffle.disabled": "โคฎ off",
    \ "progress.mark": "โ—",
    \ "progress.complete": "โ”€",
    \ "progress.missing": "โ”ˆ",
    \}

Template of the player status

The template is given by a list, where each element represents a line. And each element can be a template block or a list of of template blocks.

A template block is a dictionary with the folloing options:

  • template: A string that would be evaluated using the .format() Python method.
  • align: Alignment of the template, can be empty, left or center.
  • shorten: A boolean value, if it's true and the evaluated template is larger than width, the value will be truncated.

The variables you can use inside a template are:

  • status: the current status (playing, paused, stopped).
  • status_symbol: the symbol from spotify_symbols.
  • title: the title of the song.
  • artists: comma separated artists.
  • album_name: the name of the album.
  • album_artists: comma separated artists.
  • shuffle_symbol: the symbol from spotify_symbols.
  • volume: the current volume level (0 to 100).
  • volume_symbol: the symbol from spotify_symbols.
  • time: the current time of the song in mm:ss format.
  • length: the length of the song in mm:ss format.
  • progress_bar: progress bar.
let g:spotify_template = [
   \   {
   \       "template": " ๐ŸŽถ {title}",
   \       "shorten": v:true,
   \   },
   \   {
   \       "template": " ๐ŸŽจ {artists}",
   \       "shorten": v:true,
   \   },
   \   {
   \       "template": " ๐Ÿ’ฟ {album_name}",
   \       "shorten": v:true,
   \   },
   \   {},
   \   [
   \           {
   \               "template": "  {shuffle_symbol}",
   \               "align": "center",
   \           },
   \           {
   \               "template": "{status_symbol}",
   \               "align": "center",
   \           },
   \           {
   \               "template": "{volume_symbol} {volume}%  ",
   \               "align": "center",
   \           }
   \   ],
   \   {},
   \   {
   \       "template": "{time} / {length}",
   \       "align": "center",
   \   },
   \   {
   \       "template": "{progress_bar}",
   \       "align": "center",
   \   }
   \]

Status width

Used when rendering the template from spotify_template.

g:spotify_width = 34

Progress bar width

The width of the progress bar used when rendering the template from spotify_template.

g:spotify_progress_bar_width = 32

Wait time

Time in milliseconds to wait to show the player status after each command.

This is needed, since DBus/Spotify takes some time applying a change.

g:spotify_wait_time = 0.2

Mappings example

nmap <leader>ss <Plug>(spotify-play/pause)
nmap <leader>sj <Plug>(spotify-next)
nmap <leader>sk <Plug>(spotify-prev)
nmap <leader>so <Plug>(spotify-show)
nmap <leader>sc <Plug>(spotify-status)

Inspiration for symbols

  • playing: โ–ถ โ–ถ๏ธ
  • paused: โธ โธ๏ธ
  • stopped: โ–  โน๏ธ
  • album: ๐Ÿ’ฟ๏ธŽ๐Ÿ’ฟ
  • artist: ยฉ ๐ŸŽจ
  • music: โ™ซโ™ช ๐ŸŽถ
  • volume: โˆ… ๐Ÿ•จ ๐Ÿ•ฉ ๐Ÿ•ช ๐Ÿ”‡ ๐Ÿ”ˆ ๐Ÿ”‰ ๐Ÿ”Š
  • shuffle: โคฎ ๐Ÿ”€

References