#!/bin/bash #+SPDX: MIT ## WE NEED SOME DEPENDENCIES depcheck() { if ! command -v "$1" &> /dev/null ; then echo "Missing dependency $1" exit 1 fi } depcheck fzf depcheck swww depcheck wal depcheck foot depcheck bemenu ## Get wallpaper of choice. # The single quoted argument of fzf is like that to preserve the variable # The escaped $ is also there for the same reason # The GSCRIPTS_WALLPAPERS variable is unqouted as globbing is wanted # shellcheck disable=SC2016,SC2086 foot -W150x25 -a WallChooser -e bash -c "find ${GSCRIPTS_WALLPAPERS:-${HOME}/.local/share/backgrounds} -type f | fzf --keep-right --preview='img2sixel {} -w \$((FZF_PREVIEW_COLUMNS*8)) -h \$((FZF_PREVIEW_LINES*16)) --resampling=nearest' > /tmp/WallChooserChoice" WALLPAPER="$(cat /tmp/WallChooserChoice)" ## If no choice leave immediately. [[ -z $WALLPAPER ]] && exit ## First set the wallpaper swww img "$WALLPAPER" & THEMETYPE="$(printf "light\ndark" | bemenu -c -l2 -W 0.1)" ## Now trigger pywal to update theme data to match # -n as we don't need to set the wallpaper if [ "$THEMETYPE" == "light" ]; then wal -i "$WALLPAPER" -lnq else wal -i "$WALLPAPER" -nq fi ## Now Set the "default" wallpaper symlink ln -sf "$WALLPAPER" "${GSCRIPTS_WALLPAPERS:-${HOME}/.local/share/backgrounds}/default"