fabiofalci / sconsify

A spotify console application
https://fabiofalci.github.io/sconsify
Apache License 2.0
565 stars 26 forks source link
command-line go golang spotify spotify-console

A spotify console app

Join the chat at https://gitter.im/fabiofalci/sconsify

Important notice: libspotify is no longer available for download. If you have installed, then sconsify should be working. Unfortunately, we don't know for how long.

A very early stage of a spotify console application.

Requirements: Libspotify SDK & PortAudio & Spotify user subscribed to the Premium tier of the Spotify Service (Libspotify SDK terms of use).

Installation

Archlinux

$ pacman -S portaudio
$ yaourt -S libspotify

Ubuntu & debian

$ curl http://apt.mopidy.com/mopidy.gpg | sudo apt-key add - && sudo curl -o /etc/apt/sources.list.d/mopidy.list http://apt.mopidy.com/mopidy.list
$ sudo apt-get update && sudo apt-get install -y libportaudio2 libspotify12 --no-install-recommends 

Fedora Workstation

Install libspotify-devel from rpmfusion-nonfree. Install instructions

$ sudo dnf install libspotify portaudio

OSX

Install brew, the missing package manager for OS X and

$ brew tap homebrew/binary
$ brew install portaudio

Then, download libspotify 12.1.51 for Mac OS X/Darwin Uncompress the file and copy libspotify.framework to /Library/Frameworks (optional)

$ wget https://developer.spotify.com/download/libspotify/libspotify-12.1.51-Darwin-universal.zip
$ sudo cp -R ./libspotify-12.1.51-Darwin-universal/libspotify.framework /Library/Frameworks

sconsify will load libspotify from /usr/local/opt/libspotify/lib/libspotify. User should create a symbolic link to /usr/local/opt/libspotify/lib/libspotify

$ mkdir -p /usr/local/opt/libspotify/lib
$ ln -s /Library/Frameworks/libspotify.framework/libspotify /usr/local/opt/libspotify/lib

alt tag

Modes

There are 2 modes:

Parameters

No UI Parameters

UI mode keyboard

Search fields: album, artist or track.

    album:help
    artist:the beatles
    track:let it be

Aliases al = album, ar = artist, tr = track:

    al:help
    ar:the beatles
    tr:let it be

Vi navigation style:

No UI mode keyboard

Interprocess commands

Sconsify starts a server for interprocess commands using sconsify -command <command>. Available commands: replay, play_pause, next, pause.

i3 bindings for multimedia keys:

    bindsym XF86AudioPrev exec sconsify -command replay
    bindsym XF86AudioPlay exec sconsify -command play_pause
    bindsym XF86AudioNext exec sconsify -command next

    # pause when locking computer with i3lock
    bindsym Control+Mod1+l exec "i3lock -c 000000 && sconsify -command pause"

macOS: create a new service in Automator. Then pick Library > Utilities > Run Shell Script. Drag it to the workflow. Pick no input and then add to the script /path/to/sconsify -command replay, save it. Go to Keyboard Shortcuts > Services in System Settings, find the service you've just saved and type the desired shortcut. Repeat for each command (replay, play_pause, next, pause).

If you prefer doing this within tmux, you can put the following lines to your .tmux.conf file:

bind-key F7 run-shell 'sconsify -command replay'
bind-key F8 run-shell 'sconsify -command play_pause'
bind-key F9 run-shell 'sconsify -command next'

sconsifyrc

Similar to .ackrc you can define default parameters in ~/.sconsify/sconsifyrc:

-username=your-username
-noui-silent=true 
-noui-repeat-on=false

How to build

Install go (same version from Dockerfile), glide and get a Spotify application key and copy as a byte array to /sconsify/spotify/spotify_key_array.key.

var key = []byte{
    0x02, 0xA2, ...
    ...
    0xA1}

When building for OSX you may face an issue where it doesn't get your application key. Just retry the build that eventually it will get the key.