diff options
author | Aaron Ball <nullspoon@iohq.net> | 2015-04-09 23:15:24 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@iohq.net> | 2015-04-09 23:15:24 -0600 |
commit | ce00f594b77498b4008b8cbdbffb716b7ab30af7 (patch) | |
tree | a4238254a688be9ebb5554dc90e8be94e7964be8 | |
parent | 55b5a75fb9fce9f01054cff0c302d02970894937 (diff) | |
download | bin-ce00f594b77498b4008b8cbdbffb716b7ab30af7.tar.gz bin-ce00f594b77498b4008b8cbdbffb716b7ab30af7.tar.xz |
Added random_wallpaper.sh
-rw-r--r-- | README.md | 3 | ||||
-rwxr-xr-x | random_wallpaper.sh | 36 |
2 files changed, 39 insertions, 0 deletions
@@ -6,6 +6,9 @@ Provides a collection of handy ~/bin scripts. i3lock. Takes a screenshot of the current screen, blurs and desaturates, then sets as the lock screen background. +* **random_wallpaper.sh**: Randomly selects an image from the given path + (presumably a wallpapers directory) and sets that image as the wallpaper. + * **screenshot.sh**: Takes a three-second-delayed drag select screenshot from the command line. Useful for i3 users who set up hotkeys that call scripts. 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}" |