summaryrefslogtreecommitdiff
path: root/scripts/random_wallpaper.sh
blob: 3d2f803f1e22e147dfaa200a2c8cf664f887db6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
# Reads a given directory and set a random
# wallpaper using the images on that dir.

[ -x /usr/bin/convert ]           || exit 1
[ -x /usr/bin/feh ]               || exit 1

if [ -d "${WALLPAPERDIR}" ]; then
    files=$(ls "${WALLPAPERDIR}")
    file_matrix=($files)
    num_files=${#file_matrix[*]}
    file="${WALLPAPERDIR}/${file_matrix[$((RANDOM%num_files))]}"
else
    file = ${FVWM_USERDIR}/images/default_wall.jpg
fi

convert "${file}" -resize `xdpyinfo |grep dimensions|awk '{print $2}'` "${FVWM_USERDIR}/tmp/current_wall.png"
feh --bg-center "${FVWM_USERDIR}/tmp/current_wall.png"
FvwmCommand Refresh

exit 0