Ensure wallsetter script doesn't eat up memory or cpu if wallpaper dir not setup properly

This commit is contained in:
Tyler Kelley 2024-03-01 17:00:32 -06:00
parent c70965ce81
commit 870b06ea32

View File

@ -12,15 +12,16 @@ pkgs.writeShellScriptBin "wallsetter" ''
if [ -d ${wallpaperDir} ]; then if [ -d ${wallpaperDir} ]; then
num_files=$(ls -1 ${wallpaperDir} | wc -l) num_files=$(ls -1 ${wallpaperDir} | wc -l)
if [ "$num_files" -eq 0 ]; then if [ "$num_files" -lt 1 ]; then
notify-send "The wallpaper folder is empty. Exiting Wallsetter." notify-send -t 900 "The wallpaper folder is empty. Exiting Wallsetter."
exit
elif [ "$num_files" -eq 1 ]; then
notify-send "The wallpaper folder has only one file. Exiting Wallsetter."
exit exit
else else
cd ${wallpaperDir} cd ${wallpaperDir}
git pull if [ -d ".git" ]; then
git pull
else
notify-send -t 900 "The wallpaper directory is expected to be a Git repository. Exiting Wallsetter."
exit
fi fi
else else
${pkgs.git}/bin/git clone ${wallpaperGit} ${wallpaperDir} ${pkgs.git}/bin/git clone ${wallpaperGit} ${wallpaperDir}