Last active
July 25, 2018 02:51
-
-
Save st44100/158fa67653373648fdda0451a93337a7 to your computer and use it in GitHub Desktop.
Change wallpeper from CLI
This file contains hidden or 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 | |
# resolve $PATH | |
export PATH=$HOME/.nvm/versions/node/v8.9.2/bin/:$PATH | |
export PATH=$HOME/bin/:$PATH | |
export PATH=/usr/local/bin/:$PATH | |
# Fetch current song picture from spotify. | |
spotify share | sed -e '2d' -e 's/^SpotifyURI://' | xargs -ISONG_URL curl -X GET https://open.spotify.com/oembed\?url\=SONG_URL | jq '.thumbnail_url' | xargs -IIMAGE_URL wget IMAGE_URL -O ~/Pictures/spotify-wallpaper.jpg | |
# デスクトップピクチャは同一ファイル名への変更ができないので、一度別のものに変える | |
osascript<<END | |
tell application "System Events" | |
tell current desktop | |
set picture to "~/Pictures/placeholder.png" | |
end tell | |
end tell | |
END | |
# Sleepなしで実行すると、どちらかのピクチャ変更処理がキャンセルされる | |
sleep 1 | |
osascript<<END | |
tell application "System Events" | |
tell current desktop | |
set picture to "~/Pictures/spotify-wallpaper.jpg" | |
end tell | |
end tell | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment