Last active
June 29, 2022 13:20
-
-
Save simonbru/0409852bf2a3f7d81667ac2ed64117f7 to your computer and use it in GitHub Desktop.
Open spotify URLs in open Spotify instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# CLI wrapper that works around a bug with Spotify's handling of URIs. | |
# See https://community.spotify.com/t5/Desktop-Linux/Linux-Spotify-URI-only-opens-start-page/m-p/1675578#M1812 | |
uri="$1" | |
echo "Trying to play: \"$uri\"" | |
if ! qdbus org.mpris.MediaPlayer2.spotify \ | |
/org/mpris/MediaPlayer2 \ | |
org.mpris.MediaPlayer2.Player.OpenUri \ | |
"$uri" | |
then | |
echo "No Spotify instance seems to be open." | |
echo "Opening URI with new instance." | |
# use "--no-zygote" to prevent occasional crashes on startup: | |
# https://wiki.archlinux.org/index.php/Spotify#Crashes_on_startup | |
spotify --no-zygote --uri="$uri" & | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env xdg-open | |
[Desktop Entry] | |
Type=Application | |
Name=spotify-open | |
TryExec=spotify-open | |
Exec=spotify-open %u | |
Terminal=false | |
NoDisplay=true | |
MimeType=x-scheme-handler/spotify; | |
StartupNotify=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Desktop Entry] | |
Type=Application | |
Name=Spotify | |
GenericName=Music Player | |
Icon=spotify-client | |
TryExec=spotify | |
# Spotify currently only supports opening one URI with "--uri=%u" | |
# https://community.spotify.com/t5/Desktop-Linux/Linux-Spotify-URI-only-opens-start-page/m-p/1675578#M1812 | |
# Use "--no-zygote" to prevent occasional crashes on startup: | |
# https://wiki.archlinux.org/index.php/Spotify#Crashes_on_startup | |
Exec=spotify --no-zygote --uri=%u | |
Terminal=false | |
# Stop opening URLs directly with spotify because it opens a new instance everytime. | |
# Let "spotify-open" handle it. | |
# MimeType=x-scheme-handler/spotify; | |
Categories=Audio;Music;Player;AudioVideo; | |
StartupWMClass=spotify |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment