summaryrefslogtreecommitdiff
path: root/random_wallpaper.sh
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@iohq.net>2015-04-09 23:15:24 -0600
committerAaron Ball <nullspoon@iohq.net>2015-04-09 23:15:24 -0600
commitce00f594b77498b4008b8cbdbffb716b7ab30af7 (patch)
treea4238254a688be9ebb5554dc90e8be94e7964be8 /random_wallpaper.sh
parent55b5a75fb9fce9f01054cff0c302d02970894937 (diff)
downloadbin-ce00f594b77498b4008b8cbdbffb716b7ab30af7.tar.gz
bin-ce00f594b77498b4008b8cbdbffb716b7ab30af7.tar.xz
Added random_wallpaper.sh
Diffstat (limited to 'random_wallpaper.sh')
-rwxr-xr-xrandom_wallpaper.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/random_wallpaper.sh b/random_wallpaper.sh
new file mode 100755
index 0000000..df0624a
--- /dev/null
+++ b/random_wallpaper.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+#
+# Recursively searches the specified directory (the first script argument),
+# randomly selects one image, and set that image as the wallpaper.
+#
+# Usage:
+# random_wallpaper.sh /path/to/wallpapers
+#
+# Requirements:
+# feh
+#
+
+# Check for feh
+which feh 2>/dev/null 1>/dev/null
+if [[ $? == 1 ]]; then
+ echo "Required program 'feh' not found. Please install and run again."
+ exit 1
+fi
+
+# Make sure a wallpaper path was specified
+if [[ -z $1 ]]; then
+ echo "Please specify a wallpaper path."
+ exit 1
+fi
+
+# This needs to be set if scheduling in crontab since crontab don't have
+# displays
+# export DISPLAY=:0
+
+search_path=$1
+
+# Randomly select a wallpaper to set
+picture=$(find ${search_path} -type f -name '*.jpg' -o -name '*.png' | sort -R | head -n 1)
+
+# Set the wallpaper
+feh --bg-fill "${picture}"

Generated by cgit