From 870b06ea32ce24cd7e51fa744e0ed2c60d6c8f6b Mon Sep 17 00:00:00 2001 From: Tyler Kelley Date: Fri, 1 Mar 2024 17:00:32 -0600 Subject: [PATCH] Ensure wallsetter script doesn't eat up memory or cpu if wallpaper dir not setup properly --- config/scripts/wallsetter.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/config/scripts/wallsetter.nix b/config/scripts/wallsetter.nix index f1d0760..4b2c746 100644 --- a/config/scripts/wallsetter.nix +++ b/config/scripts/wallsetter.nix @@ -12,15 +12,16 @@ pkgs.writeShellScriptBin "wallsetter" '' if [ -d ${wallpaperDir} ]; then num_files=$(ls -1 ${wallpaperDir} | wc -l) - if [ "$num_files" -eq 0 ]; then - notify-send "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." + if [ "$num_files" -lt 1 ]; then + notify-send -t 900 "The wallpaper folder is empty. Exiting Wallsetter." exit else 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 else ${pkgs.git}/bin/git clone ${wallpaperGit} ${wallpaperDir}