You are not logged in.
Hi everyone, im new in this forum and i want share a little script, but very useful with the community.
The Script change the wallpaper using feh, for example, is very useful for openbox, i3wm etc... the script is:
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ] || [ "$1" == "--help" ]; then
echo "cw 0.1"
echo "changes your wallpaper every x seconds"
echo ""
echo "Use: cw /path/of/wallpapers/directory seconds"
echo "Example: cw /home/charlie/wallpapers 120"
exit
fi
if ! [ -e "$1" ]; then
echo "El directorio $1 no existe"
exit
fi
cd $1
function comprobar() {
num=1
for x in *;
do
let num=$num+1
done
}
while [ 1 ]; do
comprobar
var_ran=$(($RANDOM%$num))
var_aum=1
for y in *; do
if [ "$var_ran" -eq "$var_aum" ]; then
feh --bg-scale $y
sleep $2
break
fi
let var_aum=$var_aum+1
done
done
To run the script is very simple:
cw /wallpapers/folder seconds-to-change
Archist.
Offline
Or just
#!/usr/bin/env bash
while true; do
feh --randomize --bg-fill $1/*
sleep $2
done
Or even better, put `feh --randomize --bg-fill <yourpath>/*` to your crontab or into a systemd timer
Offline
Or just
#!/usr/bin/env bash while true; do feh --randomize --bg-fill $1/* sleep $2 done
Or even better, put `feh --randomize --bg-fill <yourpath>/*` to your crontab or into a systemd timer
Thanks for reply, i did not know the "randomize" option.
Offline
I also have a script that randomly selects a file. It doesn't use loops, only three lines:
# show random picture
set -- *.png
rnd="$RANDOM$RANDOM$RANDOM"
file="$(eval 'echo "${'$((1 + $rnd % $#))'}"')"
But it has an `eval` in it and `set` replaces $1 $2 $3 ... with filenames so may not be everyones cup of tea. It might also break if there are just too many files to choose from.
Alternatively you can use find and shuf: (shuf randomizes much faster than sort -R)
file=$(find images/ -type f -print0 | shuf -z -n 1)
Offline
I actually like your script better then those with the randomize flag, because when you have two screens like me, randomize will put a random wallpaper on each screen.
I'd rather have the same wallpaper on each screen.
Offline