Last active
April 22, 2020 16:54
-
-
Save davidsharp/f789b067448ae3548707b232d39f2e6b to your computer and use it in GitHub Desktop.
invisible bitbar plugin to be used with plash to generate desktop background's from the artwork of Spotify's currently playing
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
<img id="artwork" style="height:90vmin;width:90vmin;top:calc(50% - 45vmin);left:calc(50% - 45vmin);border-style:solid;border-width:5px;border-color:black;" src="./artwork.jpeg"/> | |
<img id="background" style="/*display:none;*/z-index:-1;height:calc(100vmax + 3rem);width:calc(100vmax + 3rem);top:calc(50% - 50vmax - 1.5rem);left:calc(50% - 50vmax - 1.5rem);filter:blur(2rem)" src="./artwork.jpeg"> | |
<style>img{ | |
position:fixed; | |
}</style> | |
<script> | |
const img = document.getElementById('artwork'); | |
const bg = document.getElementById('background'); | |
window.setInterval(()=>{ | |
img.src=bg.src=`artwork.jpeg?time=${Date.now()}` | |
},10*1000) | |
</script> |
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 nowplayingartwork(){ | |
osascript -l JavaScript<<'END' | |
const spotify = Application('spotify') | |
if(spotify.running()){ | |
try{ | |
const { artworkUrl } = spotify.currentTrack | |
artworkUrl() | |
} | |
catch(e){'💚';e} | |
} | |
else '💚' | |
END | |
} | |
function nowplaying(){ | |
np=$(nowplayingartwork) | |
image="$dir/plashify/artwork.jpeg" | |
url="$dir/plashify/url" | |
touch "$image" | |
touch "$url" | |
if [[ $np ]];then | |
if [ $(head -1 "$url") != $np ];then | |
echo "$np" > "$url" | |
curl "$np" -s --output "$image" | |
fi | |
fi | |
} | |
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd ) | |
# echo "$dir" | |
nowplaying |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For extra dumb-ness, make the artwork look like a vinyl record (and for bonus points, animate it spin)