Created
August 6, 2019 00:51
-
-
Save dunn/db7f8ee70d85cf037912cdc9dbb61252 to your computer and use it in GitHub Desktop.
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
const fs = require('fs') | |
function gifsInDir(dir) { | |
try { | |
return fs.readdirSync(dir).filter(value => { | |
return value.match(/\.gif$/) | |
}) | |
} catch (err) { | |
console.dir(err) | |
return [] | |
} | |
} | |
function writeRandomGif(dir, target) { | |
const gifs = gifsInDir(dir) | |
const randomGif = gifs[Math.floor(Math.random() * gifs.length)] | |
console.log(`Writing ${randomGif} to ${target}`) | |
try { | |
return fs.copyFileSync(randomGif, target) | |
} catch (err) { | |
console.dir(err) | |
return [] | |
} | |
} | |
setInterval( | |
writeRandomGif, | |
10000, | |
process.cwd(), | |
`${process.cwd()}/obs-slideshow.gif` | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment