connectr 0.2.0

Spotify Connect library and systray/menubar application for controlling Spotify devices.
Documentation

icon connectr icon

connectr is a Rust library and systray/menubar application for controlling and monitoring Spotify Connect devices.

Note: Spotify Premium is required to create an application. You must have Premium to use connectr.

As an application, connectr provides a minimal "systray" application to observe the currently playing track, control Spotify playback, switch playback devices, and start preset playlists. The goal is very low memory usage, so the basic Spotify functionality can always be available without keeping the massive Spotify desktop application resident in memory.

As a library, connectr exposes the official Spotify 'Player' Web API for controlling Spotify Connect devices.

Note: connectr is not an audio playback tool; it's just a remote control. Spotify has not publicly released a library for implementing audio playback with Spotify Connect support. There's a reverse engineering effort, coincidentally also in Rust, at librespot.

Development Status

OSX/Linux Build Status Windows Build Status

Beta / Hobby / Experimental

Code Status

Sloppy; this is my first Rust.

Cargo Crate

Crates.io Version

Platform Status

The underlying library should be fully cross-platform, though I'm only testing x86_64 Windows and OS X.

Web API Library: Fully functional and pretty stable for the requirements of the connectr menu bar app. Error handling isn't extremely robust, and it doesn't implement retries or exponential backoff, which it should. The Spotify API can, of course, do plenty more than connectr exposes.

Systray/Menubar Application:

  • Mac OS X - Done
  • Windows - Done
  • Linux - Maybe someday

Screenshot

Build Instructions

$ git clone https://github.com/mrmekon/connectr.git
$ cd connectr
$ cargo run

On first launch, Connectr will open your web browser to a self-configuration page, and save its configuration to your system home directory. The configuration page will walk you through creating the necessary Spotify developer application.

Spotify Developer Application configuration

On the first launch, connectr will guide you through setting up a Spotify developer application. If you want to do it manually instead, or if something goes wrong, here are the instructions:

  • Go to your Spotify Applications page (login with your Spotify credentials)
  • Click "CREATE AN APP" in the upper-right corner
  • Enter a name (perhaps "Connectr") and description ("Use Connectr app with my account.")
  • Add a Redirect URI: http://127.0.0.1:5432
  • Copy your Client ID and Client Secret to connectr.ini (see below).

Configuration file (connectr.ini) format

Note: connectr uses ~/.connectr.ini if it exists. If it does not exist, connectr will fallback to trying connectr.ini in the directory it is run from. A template is provided in connectr.ini.in.

connectr's configuration is read from a regular INI file with these sections:

[connectr]

  • port - Port to temporarily run web server on when requesting initial OAuth tokens (integer)

[application]

  • client_id - Spotify web application's Client ID (string)
  • secret - Spotify web application's Client Secret (string)

[presets]

  • - Key name is the display name of a playable preset, the value must be a Spotify URI to play. (string)

ex: Bakesale = spotify:album:70XjdLKH7HHsFVWoQipP0T will show as 'Bakesale' in the menu, and will play the specified Sebadoh album when clicked.

[tokens]

  • access - Spotify Web API access token
  • refresh - Spotify Web API refresh token
  • expire - Expiration time (UTC) for access token

note: this section is auto-generated and auto-updated at runtime

Example connectr.ini

[connectr]
port=5432

[application]
secret=xxxxxyyyyyaaaaabbbbbcccccddddd
client_id=xXxXxyYyYynNnNnNmMmMmMpPpPpP

[presets]
Discover Weekly=spotify:user:spotify:playlist:37i9dQZEVXcOmDhsenkuCu
Edge Detector=spotify:user:mrmekon:playlist:4SKkpDbZwNGklpIILmEZAg
Play Today=spotify:user:mrmekon:playlist:4c8eKK6kKrcdt1HToEX7Jc

[tokens]
access=this-is-autogenerated
refresh=this-is-also-autogenerated
expire=1492766270

Progress

Feature OS X Windows Linux
API
Fetch list of devices [x] [x] [x]
Fetch current playback information [x] [x] [x]
Transfer playback to device [x] [x] [x]
Start new playback on device [x] [x] [x]
Pause/Resume [x] [x] [x]
Skip next/previous [x] [x] [x]
Seek in track [x] [x] [x]
Change volume [x] [x] [x]
Change repeat state [x] [x] [x]
Change shuffle state [x] [x] [x]
Fetch album art [ ] [ ] [ ]
UI
Display current track [x] [x] [ ]
Current track in tooltip [x] [x] [ ]
Playback controls [x] [x] [ ]
Device selection [x] [x] [ ]
Volume control [x] [x] [ ]
Presets [x] [x] [ ]
Save current track to playlist [ ] [ ] [ ]
System
Persistent configuration [x] [x] [ ]
System logging [x] [x] [ ]
Installer [x] [ ] [ ]