Mis notas - Matias Hernández

Spotify on emacs

Spotify can be controlled with Emacs!!

What I used?

First I installed a package to control spotify from MELPA https://github.com/Lautaro-Garcia/counsel-spotify

  • Just `M-x package-install counsel-spotify`

  • Need to register an application in spotify.

  • Copy the client id and client secret and set two variables in `config.el` (Doom Emacs)

    (setq counsel-spotify-client-id "")
    (setq counsel-spotify-client-secret "")
    
  • Done!.. Now you can control Spotify directly from Emacs!..

Is that all?

If Spotify app is not running counsel-spotify will open it for me, i dislike that .. so I took a look and found https://github.com/Spotifyd/spotifyd

A spotify daemon!!.

Since I’m running on Mac I just installed with `brew`

$ brew install spotifyd

And then configure it by creating a file inside `~/.config/spotifyd/spotifyd.conf`

With the following (is a toml file)

[global]
# Fill this in with your Spotify login.
username = USERNAME

# You'll be using the macOS keychain to specify your password.
use_keyring = true

# How this machine shows up in Spotify Connect.
device_name = spotifyd
device_type = computer

# This is the default location of Spotify's cache, so just replace LOGIN_NAME
# with your macOS login name (type `whoami` at a Terminal window).
cache_path = /Users/LOGIN_NAME/Library/Application Support/Spotify/PersistentCache/Storage
no_audio_cache = false

# Various playback options. Tweak these if Spotify is too quiet.
bitrate = 320
volume_normalisation = true
normalisation_pregain = -10

# These need to be set, but don't need to be changed.
backend = rodio
mixer = PCM
volume_controller = softvol
zeroconf_port = 1234
  • Then I just need to add the password to the keychain

    $ security add-generic-password -s spotifyd -D rust-keyring -a <your username> -w <your password>
    
  • Launch the daemon

$ brew services start spotifyd
  • Last step is to enable emacs to access the daemeon, configure this in the `config.el` (or by using `M-X describe-variable` and customize group)

    (setq counsel-spotify-service-name "spotifyd")
    
    

Done Now I can listen Spotify without using their Electron app

Links to this note