KDE Random wallpaper or script to create symbolic links to random files
I see KDE is able to make slideshows with an interval before changing a wallpaper to a random one from a list. I want it to select random wallpapers every time it starts, and remain with that picture until the system is rebooted, but I just can't find any option and setting the slideshow interval to 0 just makes a 1 minute interval (and setting a high value is not a solucion, since I don't know how much time the PC will be on). Besides, I don't want to import ALL the wallpapers I want to use, in different directories, so I'd appreciate a PERL script (or something like that) that changes a symbolic link to a random file selected from a list of paths (I can't do it, if you can help me with BASH it would be great, is a scripting language I know and use very much), I haven't find anything.
|
I think the script below does the sort of thing you want. This script uses a separate file with the list of possible symlink targets, but it illustrates how to use bash's built in variable $RANDOM to do the selection.
$RANDOM is automatically seeded when bash is invoked by (I believe) the sum of the system time and the PID. I imagine this is good enough for your purposes. If you wanted to get fancier, you could either seed $RANDOM using /dev/urandom or use the output of /dev/urandom (one or two bytes worth, probably) directly for your random number. As the comments indicate, I wasn't trying to anticipate all possible faults or allow for a fancy $TARGETS file, so feel free to flesh it out as you wish. And of course, change the definitions of TARGETS and LINK to suit your needs. Code:
#!/bin/sh Code:
/home/user/wallpaper/file1 |
It works, thanks you a lot, I had no idea how it could be done. Thanks!
|
All times are GMT -5. The time now is 11:44 PM. |