Shuffling Wallpaper

| 1 TrackBack
English: PNG transparency demonstration 24bit ...
I was looking into getting a little more random for my wallpaper and decided to write a quickie little commandline to get a couple new random pictures from my wallpaper directory. Looking at how the conkyPhotoRandom script from conky-colors does it, I came up with:

$ find /home/jdarnold/data/wallpapers -type f \( -name "*.jpg" -or -name "*.png" -or  -name "*.JPG" \) -print0 | shuf -z -n2 |xargs -0 feh --bg-scale

The cool part of this is the shuf command, which I didn't know about (or, just as likely, knew but forgot about). So this feeds a list of files from my wallpaper folder and randomly chooses two of them. I use 2 because I have 2 monitors, each displaying 1920x1080 and the 'feh' command takes two files and scales them for my background. Maybe I'll just set this as an alias and do it whenever I think of it.

Edited: Of course, you have to take into account spaces in the filenames. So I had to add the various options that use \0 as a line delimiter, rather than \n. In this case, -print0 tells find to end each line with a \0, -z tells shuf the lines end in \0, as does the -0 option for xargs.

shuf(1): make random permutations - Linux man page

Enhanced by Zemanta

1 TrackBack

TrackBack URL: http://linux.amazingdev.com/cgi-bin/mt/mt-tb.cgi/557

Shuffling Wallpaper - Daemon Dancing in the Dark Read More

About this Entry

This page contains a single entry by Jonathan published on October 10, 2012 11:16 AM.

Off To Goomwwm Land was the previous entry in this blog.

chvt magic is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.