aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-01 10:28:13 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-01 10:28:13 +1200
commitbb38c41d17ffc1674999591dee6ece0d2b3fe1b7 (patch)
tree555917bf99ce33910bc13d8d057163843c8ac638
parentAdd rndi(1) (diff)
downloaddotfiles-bb38c41d17ffc1674999591dee6ece0d2b3fe1b7.tar.gz
dotfiles-bb38c41d17ffc1674999591dee6ece0d2b3fe1b7.zip
Change xrbg(1) to be POSIX sh
-rwxr-xr-xbin/xrbg38
1 files changed, 8 insertions, 30 deletions
diff --git a/bin/xrbg b/bin/xrbg
index 21ac8fe9..716a12c7 100755
--- a/bin/xrbg
+++ b/bin/xrbg
@@ -1,32 +1,10 @@
-#!/usr/bin/env bash
-
-#
-# xrbg(1) -- Apply a random background image.
-#
-# Author: Tom Ryder <tom@sanctum.geek.nz>
-# Copyright: 2016
-# License: Public domain
-#
-self=xrbg
-
-# Path to the backgrounds directory
-bgd=${XBACKGROUNDS:-$HOME/.xbackgrounds}
-
-# Collect all the background images in an array if they
-# match some kosher extensions
-shopt -s nullglob
-declare -a bgs
-bgs=("$bgd"/*)
-
-# If there are no images, warn explicitly and bail
-if ! ((${#bgs[@]})) ; then
- printf '%s: No background images found in %s\n' \
- "$self" "$bgd"
+#!/bin/sh
+# Apply a random background image. Requires feh(1).
+set -- "${XBACKGROUNDS:-$HOME/.xbackgrounds}"/*
+if ! [ -e "$1" ] ; then
+ printf 'xrbg: No files found in %s\n' "$bgd"
exit 1
fi
-
-# Pick one of the images (note shuf(1) needed)
-rbg=$(shuf -en1 "${bgs[@]}") || exit 1
-
-# Apply it as the background and we're done
-feh --bg-scale --no-fehbg -- "$rbg"
+argi=$(rndi 1 "$#") || exit
+shift "$((argi-1))"
+feh --bg-scale --no-fehbg -- "$1"