fix(firefox): change yazi bind to ;y and add logging
This commit is contained in:
@@ -44,7 +44,7 @@
|
|||||||
unbind <C-e>
|
unbind <C-e>
|
||||||
|
|
||||||
" Hint images and save using Yazi picker
|
" 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
|
" Force Tridactyl to yield new tab control to Firefox/Extensions
|
||||||
set newtab about:newtab
|
set newtab about:newtab
|
||||||
|
|||||||
+15
-17
@@ -4,37 +4,28 @@
|
|||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
yazi-img-save = pkgs.writeShellScriptBin "yazi-img-save" ''
|
yazi-img-save = pkgs.writeShellScriptBin "yazi-img-save" ''
|
||||||
|
echo "--- $(date) ---" >> /tmp/yazi-save.log
|
||||||
|
echo "Args: $@" >> /tmp/yazi-save.log
|
||||||
|
|
||||||
url="$1"
|
url="$1"
|
||||||
if [ -z "$url" ]; then
|
if [ -z "$url" ]; then
|
||||||
${pkgs.libnotify}/bin/notify-send "Yazi Save" "No URL provided"
|
${pkgs.libnotify}/bin/notify-send "Yazi Save" "No URL provided"
|
||||||
|
echo "Error: No URL provided" >> /tmp/yazi-save.log
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a temp file to store the chosen directory
|
# Create a temp file to store the chosen directory
|
||||||
out=$(mktemp)
|
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"
|
${pkgs.ghostty}/bin/ghostty --class="yazi-picker" --title="Pick Save Folder" -e ${pkgs.yazi}/bin/yazi . --chooser-file="$out"
|
||||||
|
|
||||||
if [ -f "$out" ]; then
|
if [ -f "$out" ]; then
|
||||||
selected=$(cat "$out")
|
selected=$(cat "$out")
|
||||||
rm "$out"
|
rm "$out"
|
||||||
|
|
||||||
|
echo "Selected: $selected" >> /tmp/yazi-save.log
|
||||||
|
|
||||||
if [ -n "$selected" ]; then
|
if [ -n "$selected" ]; then
|
||||||
# If selected is a file, get its directory.
|
# If selected is a file, get its directory.
|
||||||
if [ -f "$selected" ]; then
|
if [ -f "$selected" ]; then
|
||||||
@@ -45,22 +36,29 @@
|
|||||||
# fallback
|
# fallback
|
||||||
target_dir="$HOME/Downloads"
|
target_dir="$HOME/Downloads"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Target Dir: $target_dir" >> /tmp/yazi-save.log
|
||||||
|
|
||||||
${pkgs.libnotify}/bin/notify-send "Downloading..." "$url"
|
${pkgs.libnotify}/bin/notify-send "Downloading..." "$url"
|
||||||
|
|
||||||
# Download
|
# Download
|
||||||
cd "$target_dir"
|
cd "$target_dir"
|
||||||
|
echo "Downloading with wget..." >> /tmp/yazi-save.log
|
||||||
${pkgs.wget}/bin/wget --content-disposition --no-clobber "$url"
|
${pkgs.wget}/bin/wget --content-disposition --no-clobber "$url"
|
||||||
ret=$?
|
ret=$?
|
||||||
|
|
||||||
if [ $ret -eq 0 ]; then
|
if [ $ret -eq 0 ]; then
|
||||||
${pkgs.libnotify}/bin/notify-send "Download Complete" "Saved to $target_dir"
|
${pkgs.libnotify}/bin/notify-send "Download Complete" "Saved to $target_dir"
|
||||||
|
echo "Download success" >> /tmp/yazi-save.log
|
||||||
else
|
else
|
||||||
${pkgs.libnotify}/bin/notify-send -u critical "Download Failed" "wget exit code: $ret"
|
${pkgs.libnotify}/bin/notify-send -u critical "Download Failed" "wget exit code: $ret"
|
||||||
|
echo "Download failed: $ret" >> /tmp/yazi-save.log
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "No selection"
|
echo "No selection made" >> /tmp/yazi-save.log
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "No output file" >> /tmp/yazi-save.log
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
|
|||||||
Reference in New Issue
Block a user