dot_testing/sh/wallpaper
2022-02-22 12:38:53 -06:00

45 lines
768 B
Bash
Executable File

#!/bin/sh
WALLDIR="${HOME}/.local/share/wallpapers"
TEEFILE="${WALLDIR}/.hist"
BASECMD="feh --no-fehbg --bg-fill"
generate_wall () {
GENWALL=$( \
ls $WALLDIR | \
grep "." | \
shuf -n 1
)
GENWALL="${WALLDIR}/${GENWALL}"
}
wall () {
generate_wall
while [ "${GENWALL}" = "${1}" ]; do
generate_wall
done
}
displays () {
displays=$(xrandr | grep ' connected' | wc -l)
}
check () {
which $1 &>/dev/null
}
cmd=""
check "feh" || exit 1
if check "xrandr"; then
displays
for i in $(seq 1 $displays); do
wall ${tmp}
tmp=${GENWALL}
echo ${GENWALL} ${i} | tee $TEEFILE
cmd="${cmd} ${GENWALL}"
done
eval ${BASECMD} ${cmd}
else
generate_wall
eval ${BASECMD} ${GENWALL}
fi
unset GENWALL BASECMD tmp cmd displays i
exit 0