nixos/home/common/optional/desktop/x11/feh-wallpaper-changer.nix

28 lines
1.2 KiB
Nix

{ pkgs, ... }:
{
home.packages = with pkgs; [
(writeShellScriptBin "feh-wallpaper-changer" ''
wallpaper_dir="$HOME/.local/share/bg/"
if [ ! -d "$wallpaper_dir" ]; then
echo "No wallpapers in $wallpaper_dir, cloning from remote"
mkdir -p "$wallpaper_dir"
git clone https://git.bitlab21.com/sam/minimalistic-wallpaper-collection.git "$wallpaper_dir/minimalistic-wallpaper-collection"
[ $? != 0 ] && echo "cloning from gitea failed, exiting" && exit 1
fi
pics_exist=$(find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \))
if [ -z "$pics_exist" ]; then
git clone https://git.bitlab21.com/sam/minimalistic-wallpaper-collection.git "$wallpaper_dir/minimalistic-wallpaper-collection"
[ $? != 0 ] && echo "cloning from gitea failed, exiting" && exit 1
fi
while true; do
find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \) | shuf | while read -r file; do
${feh}/bin/feh --bg-fill "$file"
[ $? != 0 ] && echo "feh failed, exiting" && exit 1
sleep 600
done
done
'')
];
}