Created
June 16, 2015 14:31
-
-
Save qrohlf/66537a22ea0a00b1640b to your computer and use it in GitHub Desktop.
Trianglify Wallpaper set
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
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
var Trianglify = require('trianglify'); | |
var fs = require('fs'); | |
var exec = require('child_process').exec; | |
// Generate a pattern and then grab the PNG data uri | |
var pngURI = Trianglify({ | |
width: 1440, | |
height: 900, | |
cell_size: Math.random()*200 + 30, | |
x_colors: 'random', | |
variance: Math.random(), | |
}).png(); | |
// Strip off the uri part of the data uri, leaving the data | |
var data = pngURI.substr(pngURI.indexOf('base64') + 7); | |
// Decode the base64 encoded blob into a buffer | |
var buffer = new Buffer(data, 'base64'); | |
// Save the buffer to a file | |
fs.writeFileSync('/tmp/wallpaper.png', buffer); | |
// Change the wallpaper | |
exec("osascript -e 'tell application \"Finder\" to set desktop picture to POSIX file \"/tmp/wallpaper.png\"'") |
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
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/Users/qrohlf/Projects/trianglify/examples/wallpaper.png"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment