Control Spotify app from within Emacs.
Spotify.el is a collection of extensions that allows you to control the Spotify application from within your favorite text editor.
Note: This is very alpha software, and it works only in Mac OS X and Linux.
- Spotify client integration for GNU/Linux (via D-Bus) and OS X (via AppleScript)
- Communicates with the Spotify API via Oauth2
- Displays the current track in mode line
- Create playlists (public or private)
- Browse the Spotify featured playlists, your own playlists, and their tracks
- Search for tracks and playlists that match the given keywords
- Easily control basic Spotify player features like, play/pause, previous, next, shuffle, and repeat with the Spotify Remote minor mode
First, make sure your system satisfies the given dependencies:
- Emacs 24.4+
- Python 2.7+ (needed for the Oauth2 callback server)
To manually install spotify.el, just clone this project somewhere in your
disk, add that directory in the load-path
, and require the spotify
module:
(add-to-list 'load-path "<spotify.el-dir>")
(require 'spotify)
;; Settings
(setq spotify-oauth2-client-secret "<spotify-app-client-secret>")
(setq spotify-oauth2-client-id "<spotify-app-client-id>")
In order to get the the client ID and client secret, you need to create a Spotify app, specifying http://localhost:8591/ as the redirect URI.
Go to Create an Application and give your application a name and a description:
At this point, the client ID and the client secret is already available, so set
those values to spotify-oauth2-client-id
and spotify-oauth2-client-secret
,
respectively.
Then, scroll down a little bit, type http://localhost:8591/ as the Redirect URI for the application, and click Add:
Finally, scroll to the end of the page and hit Save.
Whenever you enable the spotify-remote-mode
minor mode you get the following
key bindings:
Key | Function | Description |
---|---|---|
M-p M-s | spotify-toggle-shuffle |
Turn shuffle on/off [1] |
M-p M-r | spotify-toggle-repeat |
Turn repeat on/off [1] |
M-p M-p | spotify-toggle-play |
Play/pause |
M-p M-f | spotify-next-track |
Next track |
M-p M-b | spotify-previous-track |
Previous track |
M-p p m | spotify-my-playlists |
Show your playlists |
M-p p f | spotify-featured-playlists |
Show the featured playlists |
M-p p s | spotify-playlist-search |
Search for playlists |
M-p p u | spotify-user-playlists |
Show playlists for the given user |
M-p p c | spotify-create-playlist |
Create a new playlist |
M-p t s | spotify-track-search |
Search for tracks |
The current song being played by the Spotify client is displayed in the mode
line along with the player status (playing, paused). The interval in which the
mode line is updated can be configured via the
spotify-mode-line-refresh-interval
variable:
;; Updates the mode line every second (set to 0 to disable this feature)
(setq spotify-mode-line-refresh-interval 1)
[1] No proper support for this in D-Bus implementation for GNU/Linux
The information displayed in the mode line can be customized by setting the
desired format in spotify-mode-line-format
. The following placeholders are
supported:
Symbol | Description | Example |
---|---|---|
%u |
Track URI | spotify:track:<id> |
%a |
Artist name (truncated) | Pink Floyd |
%t |
Track name (truncated) | Us and Them |
%n |
Track # | 7 |
%l |
Track duration, in minutes | 7:49 |
%r |
Player repeat status | R , - |
%s |
Player shuffle status | S , - |
%p |
Player playing status | Playing , Paused , Stopped |
The default format is "[%p: %a - %t ◷ %l %r%s]"
.
The number of characters to be shown in truncated fields can be configured via
the spotify-mode-line-truncate-length
variable.
(setq spotify-mode-line-truncate-length 10) ; default: 15
The text indicator for each of the following player statuses can be configured via their corresponding variables:
Player State | Variable | Default Value |
---|---|---|
Playing | spotify-mode-line-playing-text |
"Playing" |
Paused | spotify-mode-line-paused-text |
"Paused" |
Stopped | spotify-mode-line-stopped-text |
"Stopped" |
Shuffling On | spotify-mode-line-repeating-text |
"R" |
Shuffling Off | spotify-mode-line-not-repeating-text |
"-" |
Repeating On | spotify-mode-line-shuffling-text |
"S" |
Repeating Off | spotify-mode-line-not-shuffling-text |
"-" |
This mode can be enabled globally by running M-x global-spotify-remote-mode.
To search for tracks, run M-x spotify-track-search and type in your query. The results will be displayed in a separate buffer with the following key bindings:
Key | Description |
---|---|
l | Loads the next page of results (pagination) |
g | Clears the results and reloads the first page of results |
M-RET | Plays the track under the cursor in the context of its album [1] |
[1] D-Bus implementation for GNU/Linux do not support passing the context, so only the track under the cursor will be played
The resulting buffer loads the spotify-remote-mode
by default.
Tip: In order to customize the number of items fetched per page, just change
the variable spotify-api-search-limit
:
;; Do not use values larger than 50 for better compatibility across endpoints
(setq spotify-api-search-limit 50)
To ask the Spotify client to play a resource by URI, run M-x spotify-play-uri and enter the resource URI.
To create new playlists, run M-x spotify-create-playlist and follow the prompts.
Currently it's not possible to add tracks to a playlist you own, or to remove tracks from them.
To return the playlists for the current user, run M-x spotify-my-playlists, or M-x spotify-user-playlists to list the public playlists for some given user. To search playlists that match the given search criteria, run M-x spotify-playlist-search CRITERIA. Also, run M-x spotify-featured-playlists in order to browse the featured playlists from Spotify en_US.
Change the following variables in order to customize the locale and region for the featured playlists endpoint:
;; Spanish (Mexico)
(setq spotify-api-locale "es_MX")
(setq spotify-api-country "MX")
All these commands will display results in a separate buffer with the following key bindings:
Key | Description |
---|---|
l | Loads the next page of results (pagination) |
g | Clears the results and reloads the first page of results |
f | Follows the playlist under the cursor |
u | Unfollows the playlist under the cursor |
t | Lists the tracks of the playlist under the cursor |
M-RET | Plays the playlist under the cursor |
Once you opened the list of tracks of a playlist, you get the following key bindings in the resulting buffer:
Key | Description |
---|---|
l | Loads the next page of results (pagination) |
g | Clears the results and reloads the first page of results |
f | Follows the current playlist |
u | Unfollows the current playlist |
M-RET | Plays the track under the cursor in the context of the playlist [1] |
Both buffers load the spotify-remote-mode
by default.
[1] D-Bus implementation for GNU/Linux do not support passing the context, so only the track under the cursor will be played
If this project is useful for you, buy me a beer!
Bitcoin: bc1qtwyfcj7pssk0krn5wyfaca47caar6nk9yyc4mu
Copyright (C) Daniel Fernandes Martins
Distributed under the New BSD License. See COPYING for further details.