Change wallpaper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# change me | |
root="$HOME/pics/wallpaper" | |
# dependency | |
command -v feh >/dev/null 2>&1 || { echo >&2 "$0 error: missing dependency (\"feh\")"; exit 1; } | |
# reason for this here: http://yhaupenthal.org/1265597121.htm | |
export DISPLAY=:0.0 | |
# get the resolution of all monitors together | |
res=$(xrandr | head -1 | tr -d ' ' | cut -d\, -f 2 | sed 's/current//') | |
src="$root/$res" | |
if [[ ! -d "$src" ]] ; then | |
echo >&2 "$0 error: no such folder (\"$src\")" | |
exit 1 | |
else | |
# how many files in $src | |
lines=$(ls "$src" | wc -l) | |
# get a random number | |
rand=$(shuf -i 1-"$lines" -n 1) | |
# get the pic belonging to the number | |
pic=$(ls "$src" | sed -n "${rand}p") | |
# show it with feh | |
feh --bg-tile "$src/$pic" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment