Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stsewd/spotify.nvim
Control Spotify from Neovim, powered by D-Bus.
https://github.com/stsewd/spotify.nvim
dbus neovim neovim-plugin python spotify
Last synced: 9 days ago
JSON representation
Control Spotify from Neovim, powered by D-Bus.
- Host: GitHub
- URL: https://github.com/stsewd/spotify.nvim
- Owner: stsewd
- License: mit
- Created: 2018-02-05T06:19:37.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-11T02:47:37.000Z (11 months ago)
- Last Synced: 2024-10-30T00:05:07.302Z (19 days ago)
- Topics: dbus, neovim, neovim-plugin, python, spotify
- Language: Python
- Homepage:
- Size: 47.9 KB
- Stars: 31
- Watchers: 3
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Spotify.nvim
Control Spotify from Neovim.
![1](https://user-images.githubusercontent.com/4975310/184558071-58685fed-4fba-459b-a0fd-061981c1ea34.png)
![2](https://user-images.githubusercontent.com/4975310/184558074-bbd5ebd9-39c6-4b69-a579-7d7f28f44f7d.png)*Showing status using [nvim-notify](https://github.com/rcarriga/nvim-notify)*
## Requirements
- Linux operating system (this plugin doesn't work on Windows, and I not sure about Mac).
- [pydbus](https://github.com/LEW21/pydbus) (see [requirements](https://github.com/LEW21/pydbus#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](https://en.wikipedia.org/wiki/Wmctrl) (optional, required only for the `show` command)
- `sudo apt-get install wmctrl`
- `sudo dnf install wmctrl`## Installation
Install using [vim-plug](https://github.com/junegunn/vim-plug).
Put this on your `init.vim`.```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
```vim
g:spotify_show_status = 1
```### Symbols used in the player status
See [below for inspiration](#inspiration-for-symbols).
```vim
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.```vim
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`.
```vim
g:spotify_width = 34
```### Progress bar width
The width of the progress bar used when rendering the template from `spotify_template`.
```vim
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_.
```vim
g:spotify_wait_time = 0.2
```## Mappings example
```vim
nmap ss (spotify-play/pause)
nmap sj (spotify-next)
nmap sk (spotify-prev)
nmap so (spotify-show)
nmap sc (spotify-status)
```## Inspiration for symbols
- playing: โถ โถ๏ธ
- paused: โธ โธ๏ธ
- stopped: โ โน๏ธ
- album: ๐ฟ๏ธ๐ฟ
- artist: ยฉ ๐จ
- music: โซโช ๐ถ
- volume: โ ๐จ ๐ฉ ๐ช ๐ ๐ ๐ ๐
- shuffle: โคฎ ๐## References
- https://specifications.freedesktop.org/mpris-spec/latest/index.html
- https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html
- https://github.com/LEW21/pydbus/blob/master/doc/tutorial.rst