Share files and folders with the desktop file chooser (#6707)
Sharing a file or folder over LocalSend opened a terminal to run an fzf pick over a find of the whole home directory, which is slow on a large home, shows no previews, and looks nothing like the rest of the desktop. The portal chooser is already how the other pickers here ask. The chooser has a directory mode, so folder sharing asks for one the same way, and neither entry needs a terminal to host a picker anymore. A chooser that never opens is told apart from nobody picking anything, so a portal failure says so rather than passing for a cancelled share. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
27d1b6bebc
commit
77bf2ef704
+14
-5
@@ -22,13 +22,22 @@ elif (($# > 0)); then
|
||||
FILE_ARRAY=("$@")
|
||||
else
|
||||
if [[ $MODE == "folder" ]]; then
|
||||
# Pick a single folder from home directory
|
||||
picked=$(find "$HOME" -type d 2>/dev/null | fzf)
|
||||
select_args=(--title "Share folder" --directory)
|
||||
else
|
||||
# Pick one or more files from home directory
|
||||
picked=$(find "$HOME" -type f 2>/dev/null | fzf --multi)
|
||||
select_args=(--title "Share files" --multiple)
|
||||
fi
|
||||
[[ -z $picked ]] && exit 0
|
||||
|
||||
# Command substitution so the chooser's exit status survives: reading it
|
||||
# through a process substitution reports success for a chooser that never
|
||||
# opened, which is indistinguishable here from someone deciding not to share.
|
||||
picked=$(omarchy-file-select "${select_args[@]}") || status=$?
|
||||
|
||||
if ((${status:-0} > 1)); then
|
||||
omarchy-notification-send -g "" -u critical "Could not share" "The file chooser did not open"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[[ -n $picked ]] || exit 0
|
||||
readarray -t FILE_ARRAY <<<"$picked"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user