Created
April 29, 2020 11:09
-
-
Save davidsharp/707417fdc85b3128f91bb075fb17fbcc to your computer and use it in GitHub Desktop.
bitbar plugin that provides a shuffle button for Spotify
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/bash | |
function shuffle(){ | |
osascript -l JavaScript<<'END' | |
const spotify = Application('spotify') | |
if(spotify.running()){ | |
try{ | |
spotify.shuffling = !spotify.shuffling() | |
} | |
catch(e){''} | |
} | |
else '' | |
END | |
} | |
if [[ "$1" = "shuffle" ]]; then | |
shuffle | |
fi | |
function shuffle_state(){ | |
osascript -l JavaScript<<'END' | |
const spotify = Application('spotify') | |
if(spotify.running()){ | |
try{ | |
spotify.shuffling()?'🔀':'🔁' | |
} | |
catch(e){'💚'} | |
} | |
else '' | |
END | |
} | |
function run(){ | |
state=$(shuffle_state) | |
if [[ $state ]];then | |
echo "$state|bash=$0 param1=shuffle terminal=false refresh=true" | |
fi | |
} | |
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ) | |
run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment