macos_wm
macos_wm copied to clipboard
Spotify
How do I get a refresh token so the Spotify token doesn't expire?
hey @ThatOneCalculator, Actually I have no idea. I did this project for experiment.
Gotcha. If I ever figure it out, I'll post it here.
Thanks man. I really appreciate it. Have a nice day
I figured it out! As it turns out, the Spotify API is actual bs, so I did the only sensible thing...
...cut it out entirely!
Turns out, AppleScript has a giant built in dictionary for accessing info about Spotify. How neat! I put this addition into Pecan bar, but it can super easily be replicated in your bar.
song.jsx:
const command = 'bash pecan/scripts/song';
const refreshFrequency = 500; //ms
let render = ({ output }) => {
if (String(output).includes('No song playing')){
return (<div></div>);
}
else{
return (<div class='screen'><div class='pecansong'>{output}</div></div>);
}
}
export { command, refreshFrequency, render };
song:
#!/pecan/scripts/song'
spotify=$(osascript -e 'if application "Spotify" is running then
set myvar to "running"
end if')
if [ "$spotify" == "running" ]; then
song=$(osascript -e 'tell application "Spotify"
set track_name to name of current track
end tell')
artist=$(osascript -e 'tell application "Spotify"
set track_artist to artist of current track
end tell')
echo "$song by $artist"
else
echo "No song playing"
fi
@ThatOneCalculator Hey, thank you for your contribution. I will check and implement it in next monday. Currently I don't have any mac to test.
@ThatOneCalculator Hey, thank you for your contribution. I will check and implement it in next monday. Currently I don't have any mac to test.
Is it next monday? 🙃