feat(firefox): add tridactyl yazi image saver, revert portal attempt
This commit is contained in:
@@ -43,6 +43,9 @@
|
|||||||
bind K tabprev
|
bind K tabprev
|
||||||
unbind <C-e>
|
unbind <C-e>
|
||||||
|
|
||||||
|
" Hint images and save using Yazi picker
|
||||||
|
bind ;s 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
|
||||||
'';
|
'';
|
||||||
|
|||||||
+53
-30
@@ -3,36 +3,64 @@
|
|||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
yazi-picker = pkgs.writeShellScriptBin "yazi-picker" ''
|
yazi-img-save = pkgs.writeShellScriptBin "yazi-img-save" ''
|
||||||
echo "--- $(date) ---" >> /tmp/yazi-picker.log
|
url="$1"
|
||||||
echo "Args: $@" >> /tmp/yazi-picker.log
|
if [ -z "$url" ]; then
|
||||||
echo "Env: WAYLAND_DISPLAY=$WAYLAND_DISPLAY DISPLAY=$DISPLAY" >> /tmp/yazi-picker.log
|
${pkgs.libnotify}/bin/notify-send "Yazi Save" "No URL provided"
|
||||||
|
exit 1
|
||||||
path="$1"
|
|
||||||
[ -z "$path" ] && path="."
|
|
||||||
|
|
||||||
if [ "$2" = "true" ]; then
|
|
||||||
echo "Mode: Save" >> /tmp/yazi-picker.log
|
|
||||||
# Future: handle save mode better (maybe prompts?)
|
|
||||||
else
|
|
||||||
echo "Mode: Open" >> /tmp/yazi-picker.log
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
out="$HOME/.cache/yazi-chooser"
|
# Create a temp file to store the chosen directory
|
||||||
rm -f "$out"
|
out=$(mktemp)
|
||||||
|
|
||||||
echo "Launching ghostty..." >> /tmp/yazi-picker.log
|
|
||||||
${pkgs.ghostty}/bin/ghostty --class="yazi-picker" --title="File Picker" -e ${pkgs.yazi}/bin/yazi "$path" --chooser-file="$out"
|
|
||||||
ret=$?
|
|
||||||
echo "Ghostty exited with $ret" >> /tmp/yazi-picker.log
|
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
${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")
|
||||||
echo "Selected: $selected" >> /tmp/yazi-picker.log
|
|
||||||
echo "$selected"
|
|
||||||
rm "$out"
|
rm "$out"
|
||||||
else
|
|
||||||
echo "No selection" >> /tmp/yazi-picker.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
|
||||||
|
|
||||||
|
${pkgs.libnotify}/bin/notify-send "Downloading..." "$url"
|
||||||
|
|
||||||
|
# Download
|
||||||
|
cd "$target_dir"
|
||||||
|
${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"
|
||||||
|
else
|
||||||
|
${pkgs.libnotify}/bin/notify-send -u critical "Download Failed" "wget exit code: $ret"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No selection"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
@@ -50,11 +78,6 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
home.packages = [
|
home.packages = [
|
||||||
yazi-picker
|
yazi-img-save
|
||||||
];
|
];
|
||||||
|
|
||||||
xdg.configFile."xdg-desktop-portal-termfilechooser/config".text = ''
|
|
||||||
[filechooser]
|
|
||||||
cmd=${yazi-picker}/bin/yazi-picker
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,10 @@
|
|||||||
enable = true;
|
enable = true;
|
||||||
extraPortals = [
|
extraPortals = [
|
||||||
pkgs.xdg-desktop-portal-hyprland
|
pkgs.xdg-desktop-portal-hyprland
|
||||||
pkgs.xdg-desktop-portal-termfilechooser
|
|
||||||
];
|
];
|
||||||
config.common = {
|
config.common = {
|
||||||
default = ["hyprland"];
|
default = ["hyprland"];
|
||||||
"org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"];
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user