Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@henrik242
Last active January 4, 2023 12:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrik242/ba0957dbb43cb232eade2a99e328dff4 to your computer and use it in GitHub Desktop.
Save henrik242/ba0957dbb43cb232eade2a99e328dff4 to your computer and use it in GitHub Desktop.

Installation

  1. Install Shpotify: brew install shpotify
  2. Unzip spotify-workflows.zip into $HOME/Library/Services/
  3. Go to System Preferences -> Keyboard -> Shortcuts -> Services -> General
  4. Set hotkeys for each of your actions (I use control-cmd-option plus arrow keys or P)

You're done!

Manual installation

You can create the contents of spotify-workflows.zip yourself using Automator:

  1. Open Automator.app.
  2. Create new Quick Action
  3. Double click Library -> Utilities -> Run Shell Script
  4. Set Workflow recieves: no input and Shell: /bin/bash
  5. Paste the contents of one of the workflow scripts below into Run Shell Script
  6. Save and specify a name. (Will be saved to $HOME/Library/Services/)
  7. Repeat pt. 2-6 for each script below
STATUS=$(/usr/local/bin/spotify next | grep -e Artist -e Track)
TRACK=$(echo $STATUS | /usr/bin/perl -pe 's/Track: / - /; s/Artist: //;')
osascript -e "display notification \"$TRACK\" with title \"Next track\""
PLAYING=$(/usr/local/bin/spotify pause)
STATUS=$(/usr/local/bin/spotify status | grep -e Artist -e Track -e Position)
TRACK=$(echo $STATUS | /usr/bin/perl -pe 's/Artist: //; s/[\w]+: / - /g;')
osascript -e "display notification \"$TRACK\" with title \"$PLAYING\""
SHUFFLE=$(/usr/local/bin/spotify toggle shuffle)
osascript -e "display notification \"$SHUFFLE\" with title \"Spotify\""
VOLUME=$(/usr/local/bin/spotify vol down)
osascript -e "display notification \"$VOLUME\" with title \"Spotify\""
VOLUME=$(/usr/local/bin/spotify vol up)
osascript -e "display notification \"$VOLUME\" with title \"Spotify\""
@henrik242
Copy link
Author

I've found https://redsweater.com/fastscripts/ to be better/faster than Automator for this task. More info at https://gist.github.com/henrik242/4e64e208a184f540a80a343187e075c1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment