Skip to content

Instantly share code, notes, and snippets.

@carnar
Last active June 18, 2018 12:49
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 carnar/d9cd7b17b575c5222211 to your computer and use it in GitHub Desktop.
Save carnar/d9cd7b17b575c5222211 to your computer and use it in GitHub Desktop.
How to open spotify urls in native application instead of Google Chrome

How to open spotify urls in native application instead of Google Chrome

Problem

When you open a Spotify URL in linux Google Chrome, this launches spotify web player instead of native application.

Solution

  1. Install Switcheroo Redirector extension for Google Chrome and create next routes.

     http://open.spotify.com/ -> spotify:
     http://play.spotify.com/ -> spotify:
     https://open.spotify.com/ -> spotify:
     https://play.spotify.com/ -> spotify:
    
  2. Rename spotify application

     sudo mv /usr/bin/spotify /usr/bin/spotify-base
    
  3. Create a bash file with this code (i.e. ~/spotify-launcher.sh)

     #!/bin/bash
    
     if [[ -z $1 ]]; then
         spotify-base &
     else
         # remove protocol
         uri=spotify${1#*spotify}
    
         # remove query string
         uri=${uri%\?*}
    
         # replace / with :
         uri=${uri//\//:}
    
         # launch spotify
         spotify-base /uri "${uri}" &
     fi
    
  4. Create a symbolic link for new spotify laucher

     sudo ln -s ~/spotify-launcher.sh /usr/bin/spotify
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment