From 07a91ea1364b3eb90b977aa903addc9b3750887d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= <v.code.ngyvz7vf@what.tf>
Date: Sat, 4 Jan 2025 11:31:43 +0100
Subject: [PATCH] Improve the wallpaper script

---
 .config/hypr/hyprland.conf |  2 +-
 bin/set_wallpaper          | 20 +++++++++++++++++---
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/.config/hypr/hyprland.conf b/.config/hypr/hyprland.conf
index 8cd5583..e68627e 100644
--- a/.config/hypr/hyprland.conf
+++ b/.config/hypr/hyprland.conf
@@ -43,7 +43,7 @@ $lock = swaylock --color=000000 --daemonize
 # exec-once = $terminal
 # exec-once = nm-applet &
 # exec-once = waybar & hyprpaper & firefox
-exec-once = ~/.local/bin/set_wallpaper && hyprpaper
+exec-once = ~/.local/bin/set_wallpaper
 exec-once = waybar
 
 
diff --git a/bin/set_wallpaper b/bin/set_wallpaper
index eeb509f..014518d 100755
--- a/bin/set_wallpaper
+++ b/bin/set_wallpaper
@@ -3,11 +3,22 @@
 set -euo pipefail
 IFS=$'\n\t'
 
-WALLPAPER_DIRECTORY="$HOME/pictures/wallpapers/enabled"
 HYPRPAPER_CNF="$HOME/.config/hypr/hyprpaper.conf"
+WALLPAPER_DIR="$HOME/pictures/wallpapers/enabled"
+WALLPAPER_DIR_WINTER="$WALLPAPER_DIR/winter"
 
-if [ -d "$WALLPAPER_DIRECTORY" ]; then
-	WALLPAPER_FILE="$(find "$WALLPAPER_DIRECTORY" -type l -print | shuf | head -n 1)"
+# Set the wallpaper directory based on the current month
+case "$(date '+%m')" in
+	"01"|"02"|"11"|"12")
+		if [ -d "$WALLPAPER_DIR_WINTER" ]; then
+			WALLPAPER_DIR="$WALLPAPER_DIR_WINTER"
+		fi
+		;;
+esac
+
+# Generate the configuration
+if [ -d "$WALLPAPER_DIR" ]; then
+	WALLPAPER_FILE="$(find "$WALLPAPER_DIR" -maxdepth 1 -type f -print | shuf | head -n 1)"
 	if [ -L "$WALLPAPER_FILE" ]; then
 		WALLPAPER_FILE="$(readlink -f "$WALLPAPER_FILE")"
 	fi
@@ -17,3 +28,6 @@ wallpaper = ,$WALLPAPER_FILE
 splash = false
 EOF
 fi
+
+# Set the wallpaper
+hyprpaper