diff options
-rw-r--r-- | X/xinitrc | 5 | ||||
-rwxr-xr-x | bin/xrbg | 33 | ||||
-rw-r--r-- | man/man1/xrbg.1 | 20 |
3 files changed, 55 insertions, 3 deletions
@@ -6,9 +6,8 @@ xrdb "${XRESOURCES:-$HOME/.Xresources}" # <https://en.wikipedia.org/wiki/Compose_key#Common_compose_combinations> setxkbmap -option compose:ralt,ctrl:nocaps,terminate:ctrl_alt_bksp -# Apply background image -# Edited cover of Darkthrone's 1994 album "Transilvanian Hunger" -feh --bg-scale --no-fehbg -- "$HOME"/.xbackgrounds/hunger.jpg +# Apply a random background image +xrbg # Start dunst(1) to display libnotify messages dunst & diff --git a/bin/xrbg b/bin/xrbg new file mode 100755 index 00000000..9250b20a --- /dev/null +++ b/bin/xrbg @@ -0,0 +1,33 @@ +#!/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" + 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" + diff --git a/man/man1/xrbg.1 b/man/man1/xrbg.1 new file mode 100644 index 00000000..04e3c2b5 --- /dev/null +++ b/man/man1/xrbg.1 @@ -0,0 +1,20 @@ +.TH XRBG 1 "March 2016" "Manual page for xrbg" +.SH NAME +.B xrbg +\- apply a random X background image with feh(1) +.SH SYNOPSIS +.B xrbg +.br +XBACKGROUNDS=/path/to/images +.B xrbg +.SH DESCRIPTION +.B xrbg +searches for images in the directory named in the XBACKGROUNDS environment +variable (defaults to ~/.xbackgrounds), chooses a random one with shuf(1), and +applies it with feh(1). It's designed for use in ~/.xinitrc, but it seems to +work when called manually from within an X session too. +.SH SEE ALSO +feh(1), shuf(1) +.SH AUTHOR +Tom Ryder <tom@sanctum.geek.nz> + |