blob: 9250b20a4591da885b753e1a8861aff80695a880 (
plain) (
blame)
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
31
32
33
|
#!/usr/bin/env bash
#
# xrbg(1) -- Apply a random background image.
#
# Author: Tom Ryder <tom@sanctum.geek.nz>
# Copyright: 2016
# License: Public domain
#
self=xrbg
# Path to the backgrounds directory
bgd=${XBACKGROUNDS:-$HOME/.xbackgrounds}
# Collect all the background images in an array if they
# match some kosher extensions
shopt -s nullglob
declare -a bgs
bgs=("$bgd"/*)
# If there are no images, warn explicitly and bail
if ! ((${#bgs[@]})) ; then
printf '%s: No background images found in %s\n' \
"$self" "$bgd"
exit 1
fi
# Pick one of the images (note shuf(1) needed)
rbg=$(shuf -en1 "${bgs[@]}") || exit 1
# Apply it as the background and we're done
feh --bg-scale --no-fehbg -- "$rbg"
|