diff --git a/apps/hyprpaper/default.nix b/apps/hyprpaper/default.nix index d0c92ad..e3ccb0f 100644 --- a/apps/hyprpaper/default.nix +++ b/apps/hyprpaper/default.nix @@ -22,13 +22,24 @@ fi tmp_file=$(mktemp) - target_dir="$HOME/Pictures/Wallpapers" - if [ ! -d "$target_dir" ]; then - target_dir="$HOME" + LAST_WALLPAPER_FILE="$HOME/.cache/last_wallpaper_path" + + if [ -f "$LAST_WALLPAPER_FILE" ]; then + last_path=$(cat "$LAST_WALLPAPER_FILE") + if [ -f "$last_path" ]; then + yazi_target="$last_path" + fi + fi + + if [ -z "$yazi_target" ]; then + yazi_target="$HOME/Pictures/Wallpapers" + if [ ! -d "$yazi_target" ]; then + yazi_target="$HOME" + fi fi # Ensure we are in a terminal that supports yazi - ${pkgs.yazi}/bin/yazi "$target_dir" --chooser-file="$tmp_file" + ${pkgs.yazi}/bin/yazi "$yazi_target" --chooser-file="$tmp_file" if [ ! -f "$tmp_file" ]; then echo "No selection file created." @@ -46,6 +57,7 @@ # Persistence logic CACHE_FILE="$HOME/.cache/current_wallpaper" cp "$WALLPAPER" "$CACHE_FILE" + echo "$WALLPAPER" > "$HOME/.cache/last_wallpaper_path" # Reload hyprpaper ${pkgs.hyprland}/bin/hyprctl hyprpaper unload all