Order Randomly Wallpapers

Share your own howto's etc. Not for support questions!
Post Reply
Message
Author
User avatar
bester69
Posts: 1900
Joined: 2015-04-02 13:15
Been thanked: 1 time

Order Randomly Wallpapers

#1 Post by bester69 »

You have hundreds or thousands of Wallpapers and you'd like to enjoy most of them, without having to repeat them.

To achieve this, We link all of them to a target folder, where we'll rename all of them every time in while..
WALL=/home/user/Imágenes/WALLPAPERS/
cd /media/sda4/Imágenes/WALLRANDOM/
rm *

find $WALL -type f -name "*.jpg" -exec ln -s {} \;
find $WALL -type f -name "*.png" -exec ln -s {} \;
for i in *.jpg; do mv "$i" $RANDOM$RANDOM.jpg;done
for i in *.png; do mv "$i" $RANDOM$RANDOM.png;done
bester69 wrote:You wont change my mind when I know Im right, Im not an ...

User avatar
Head_on_a_Stick
Posts: 13450
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Order Randomly Wallpapers

#2 Post by Head_on_a_Stick »

bester69 wrote:You have hundreds or thousands of Wallpapers and you'd like to enjoy most of them, without having to repeat them.
I use this line in my startup script to change to a different random wallpaper every 5 minutes (I get bored easily):

Code: Select all

while true;do feh --randomize --bg-fill $HOME/Pictures/Wallpapers;sleep 300;done &
https://packages.debian.org/jessie/feh

:)
Black Lives Matter

Debian buster-backports ISO image: for new hardware support

User avatar
bester69
Posts: 1900
Joined: 2015-04-02 13:15
Been thanked: 1 time

Re: Order Randomly Wallpapers

#3 Post by bester69 »

Mate Desktop

Code: Select all

# Script to randomly set Background from files in a directory

while true;do

# Directory Containing Pictures
DIR="/home/user/Imágenes/WALLPAPERS"

# Make sure spaces do not break our script.
IFS='
'
# Command to Select a random jpg file from directory
# Delete the *.jpg to select any file but it may return a folder
PIC=$(ls $DIR/*.jpg | shuf -n1)

# Command to set Background Image
gsettings set org.mate.background picture-filename $PIC

# specify how long to wait in seconds between changes
sleep 30000

done

bester69 wrote:You wont change my mind when I know Im right, Im not an ...

tezzeret
Posts: 12
Joined: 2015-06-24 08:19

Re: Order Randomly Wallpapers

#4 Post by tezzeret »

Using the window manager Awesome, I run this after setting the background so that next time awesome starts I have a new background. I wrote it in Lua to stay with Awesome's lua "theme" and because I am already familiar with that and not at all with bash.
The first bit gets a json response with all the url's of pictures in the "epic" gallery from that site. I then convert the json into a table. Its a POST request rather then a GET as I noticed that the AJAX call on that site is also a POST. It probably doesn't matter though if it was a GET or POST.
After that it selects 2 pictures to be downloaded. I download 2 because I have 2 monitors. I probably should change the paths it uses one day so it stays in ~/.config/awesome and maybe I will make it change the wallpaper automatically as well.

Code: Select all

function getBackground()
	local JSON = assert(loadfile "/home/lenscas/.config/awesome/default/extraLua/JSON.lua")() -- one-time load of the routines
	
	local f = assert (io.popen ('curl --data "" http://chillstep.info/jsonLoadGal.php?gal=gal-epic'))
	local rawText="";
	for line in f:lines() do
		rawText=rawText..line
	end -- for loop

	f:close()
	local inJson = JSON:decode(rawText)
	math.randomseed(os.time())
	local key=math.random(1,#inJson)
	--print(table.concat(inJson))
	os.execute('wget http://chillstep.info'..inJson[key]..' -O /home/lenscas/backgrounds/awesome/background1')
	local key=math.random(1,#inJson)
	os.execute('wget http://chillstep.info'..inJson[key]..' -O /home/lenscas/backgrounds/awesome/background2')
end
getBackground()

Post Reply