Hacker News new | ask | show | jobs
by aomega08 2032 days ago
The following will give you "#1 wallpaper of the day" as decided by the wise folks at Reddit:

  curl -A 'random' "https://www.reddit.com/r/wallpaper/top.json?t=day&limit=1 | jq -r '.data.children[0].data.preview.images[0].source.url' | sed 's/preview\./i\./g'
And if you're a Mac user, the following will change the background:

  osascript -e 'tell application "Finder" to set desktop picture to POSIX file "<path to the picture>"'
Glueing these two pieces should be trivial :)
1 comments

The call to curl is missing a closing " pair. Besides, it seems some people submit a low-res image at the post, then post another link as the first reply, which is the case today:

https://preview.redd.it/b2ihaxu2i5261.jpg?width=640&crop=sma...

Care to adjust the jq a bit to look for both, then maybe somehow compare the resolution of the two and download the better one?