aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/chwp
blob: 071bf3ae928bcc6409c0292e3ec220f160cf465f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /usr/bin/env sh

if [ -f "$HOME/.local/etc/x/chwp" ]
then
	. "$HOME/.local/etc/x/chwp"
fi

directory=${CHWP_BASEDIR:-$HOME/pictures/wallpapers}
size=${CHWP_SIZE:-1920x1080}
timeout=${1:-0}
walldir=$directory/$size

if [ ! -d "$walldir" ]
then
	printf "%s\n" "No such directory: $walldir" >&2
fi

# If no timeout was set, just change it once
if [ "$timeout" -eq 0 ]
then
	find "${walldir}" -type f -print0 | shuf -n1 -z | xargs -0 feh --bg-fill
	exit 0
fi

# Otherwise, change it every so often
while :
do
	find "${walldir}" -type f -print0 | shuf -n1 -z | xargs -0 feh --bg-fill
	sleep "${timeout}"
done