Created
July 25, 2018 04:15
-
-
Save yihyang/bc132111c17ba5b438e2225e39fc5d1f to your computer and use it in GitHub Desktop.
Make fun of your friend by changing their wallpaper fast using this program. Start by putting all the wallpapers inside "wallpapers" folder on Desktop.
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
| cd ~/Desktop/wallpapers | |
| # find the available files | |
| photos=`find ${PWD} -type f -maxdepth 2 -name "*.jpg" -o -name "*.png"` | |
| # Select Random photos | |
| numlines="$(printf "%s\n" "${photos}" | wc -l)" | |
| lineno="$((${RANDOM} % ${numlines} + 1))" | |
| random_line="$(printf "%s\n" "${photos}" | sed -n "${lineno}{p;q;}")" | |
| echo $random_line | |
| osascript -e "tell application \"Finder\" to set desktop picture to POSIX file \"${random_line}\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment