fix(firefox): change yazi bind to ;y and add logging

This commit is contained in:
kenji
2026-01-11 11:17:23 -06:00
parent 2d77a5d42e
commit d9f848f626
2 changed files with 16 additions and 18 deletions
+1 -1
View File
@@ -44,7 +44,7 @@
unbind <C-e>
" Hint images and save using Yazi picker
bind ;s hint -i -c native yazi-img-save
bind ;y hint -i -c native yazi-img-save
" Force Tridactyl to yield new tab control to Firefox/Extensions
set newtab about:newtab
+15 -17
View File
@@ -4,37 +4,28 @@
...
}: 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)
# Launch Yazi in a terminal to pick a directory.
# We use a trick: --chooser-file normally picks a file.
# But if we want a directory, we can select a directory entry (if inside parent)
# OR we can just use the current directory when yazi exits?
#
# Better approach: Use a specific yazi command or just open yazi
# and have a keybind to "pick here"?
#
# Simplest valid approach with stock Yazi:
# Use --chooser-file. User navigates to the folder they want,
# enters it, then selects "current directory" (.) if possible?
# Standard Yazi chooser doesn't easily return "current dir".
#
# Alternative: The user selects a FILE in the directory they want,
# and we save alongside it.
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
@@ -45,22 +36,29 @@
# 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"
echo "No selection made" >> /tmp/yazi-save.log
fi
else
echo "No output file" >> /tmp/yazi-save.log
fi
'';
in {