{ pkgs, config, ... }: let yazi-img-save = pkgs.writeShellScriptBin "yazi-img-save" '' echo "--- $(date) ---" >> /tmp/yazi-save.log echo "Args: $@" >> /tmp/yazi-save.log url="$1" if [ -z "$url" ]; then ${pkgs.libnotify}/bin/notify-send "Yazi Save" "No URL provided" echo "Error: No URL provided" >> /tmp/yazi-save.log exit 1 fi # Create a temp file to store the chosen directory out=$(mktemp) echo "Launching ghostty..." >> /tmp/yazi-save.log ${pkgs.ghostty}/bin/ghostty --class="yazi-picker" --title="Pick Save Folder" -e ${pkgs.yazi}/bin/yazi . --chooser-file="$out" if [ -f "$out" ]; then selected=$(cat "$out") rm "$out" echo "Selected: $selected" >> /tmp/yazi-save.log if [ -n "$selected" ]; then # If selected is a file, get its directory. if [ -f "$selected" ]; then target_dir=$(dirname "$selected") elif [ -d "$selected" ]; then target_dir="$selected" else # fallback target_dir="$HOME/Downloads" fi echo "Target Dir: $target_dir" >> /tmp/yazi-save.log ${pkgs.libnotify}/bin/notify-send "Downloading..." "$url" # Download cd "$target_dir" echo "Downloading with wget..." >> /tmp/yazi-save.log ${pkgs.wget}/bin/wget --content-disposition --no-clobber "$url" ret=$? if [ $ret -eq 0 ]; then ${pkgs.libnotify}/bin/notify-send "Download Complete" "Saved to $target_dir" echo "Download success" >> /tmp/yazi-save.log else ${pkgs.libnotify}/bin/notify-send -u critical "Download Failed" "wget exit code: $ret" echo "Download failed: $ret" >> /tmp/yazi-save.log fi else echo "No selection made" >> /tmp/yazi-save.log fi else echo "No output file" >> /tmp/yazi-save.log fi ''; in { programs.yazi = { enable = true; enableFishIntegration = true; settings = { manager = { show_hidden = true; sort_by = "natural"; sort_dir_first = true; linemode = "size"; }; }; }; home.packages = [ yazi-img-save ]; }