nix-config/.config/feh/tile.sh
Donovan Glover 9b9a7b1768
Switch from base16 to pywal
pywal (also known as wal) lets us change color schemes with a cache
directory instead of editing config files directly. This helps us
separate the dotfiles from the color schemes.

This commit removes explicit color settings from my dotfiles, which are
now managed by pywal. Dunst has been added to show any notifications
that I may want to use in the future. The colors.Xresources file is used
to prevent urxvt from using a depth of 32.

My custom colors.vim file has been removed in favor of wal.vim, which
solves some problems I had to manually resolve myself and should make
things easier to maintain in the long term.

Note that pywal also supports base16 color schemes, as well as any other
color scheme you can think of.
2018-10-12 23:13:15 -04:00

44 lines
1.3 KiB
Bash

#!/bin/sh
# End the script if an error occurs.
set -e
# Change the working directory to a cache directory.
mkdir -p "$HOME/.cache/feh"
cd "$HOME/.cache/feh"
# If $1 is not defined, raise an error.
if [ -z "$1" ]; then
echo 'error: No color specified.'
echo 'usage: ./path/to/tile.sh <color> where color is hexadecimal'
exit 1
fi
# If $1 contains something other than 0-9 and A-F, raise an error.
if [[ -n "${1//[0-9A-F]/}" ]]; then
echo 'error: Invalid color specified. Colors must use 0-9 and A-F only.'
echo ' Colors should not use a-f since file names are case sensitive.'
exit 1
fi
# If $1 is not exactly six characters long, raise an error.
if ! [ "${#1}" -eq 6 ]; then
echo 'error: Invalid color specified. Colors must be of length 6.'
echo ' This is for the convert function, and is used to help'
echo ' prevent duplicate colors.'
exit 1
fi
# If the color doesn't exist yet, make it.
if ! test -e "$1.png"; then
echo 'status: Color file does not exist yet. Making it...'
convert -size 1x1 "xc:#$1" "$1.png"
fi
# Finally, set the specified color as the background.
echo 'status: Setting the desktop background as the specified color...'
feh --no-fehbg --bg-tile "$1.png"
# We're done here.
echo 'status: Successfully changed the background to the color specified!'