feh-wallpaper-changer

This commit is contained in:
Sam 2024-06-14 00:39:02 +01:00
parent a9ecc94a77
commit 658744d33c
3 changed files with 29 additions and 1 deletions

View File

@ -17,7 +17,7 @@
recursive = true; recursive = true;
text = '' text = ''
autostart="dwmblocks" autostart="dwmblocks feh-wallpaper-changer"
for program in $autostart; do for program in $autostart; do
pidof -sx "$program" || "$program" & pidof -sx "$program" || "$program" &

View File

@ -1,6 +1,7 @@
{ pkgs, ... }: { pkgs, ... }:
{ {
imports = [ imports = [
./feh-wallpaper-changer.nix
]; ];
home.packages = [ home.packages = [

View File

@ -0,0 +1,27 @@
{ 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
'')
];
}