From d7a4c3a24dafd8173145ea499d8e9f93bee028b1 Mon Sep 17 00:00:00 2001 From: tinywrkb Date: Wed, 12 Jan 2022 14:33:47 +0200 Subject: userscripts/open_download: Flatpak compatibility --- misc/userscripts/open_download | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/misc/userscripts/open_download b/misc/userscripts/open_download index 62730f37c..8a1439fa1 100755 --- a/misc/userscripts/open_download +++ b/misc/userscripts/open_download @@ -103,13 +103,22 @@ fi file="${entries[$line]}" file="${file%%$'\t'*}" path="$DOWNLOAD_DIR/$file" -filetype=$(xdg-mime query filetype "$path") -application=$(xdg-mime query default "$filetype") -if [ -z "$application" ] ; then - die "Do not know how to open »$file« of type $filetype" -fi +if [ -f /.flatpak-info ]; then + # with the help of the appchooser portal, flatpak let the user select the + # app associated with a mime type after executing xdg-open. + # we can't know ahead of time which app will be launched, and the sandbox + # doesn't have access to mime types known to the host. + msg info "Opening »$file« with XDG Desktop Portal" +else + filetype=$(xdg-mime query filetype "$path") + application=$(xdg-mime query default "$filetype") + + if [ -z "$application" ] ; then + die "Do not know how to open »$file« of type $filetype" + fi -msg info "Opening »$file« (of type $filetype) with ${application%.desktop}" + msg info "Opening »$file« (of type $filetype) with ${application%.desktop}" +fi xdg-open "$path" & -- cgit v1.2.3-54-g00ecf From 2d44db28e2f87b2d28a96299d5339ff04efb05c5 Mon Sep 17 00:00:00 2001 From: tinywrkb Date: Wed, 12 Jan 2022 14:36:13 +0200 Subject: userscripts/open_download: Wait for xdg-open exit code --- misc/userscripts/open_download | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/userscripts/open_download b/misc/userscripts/open_download index 8a1439fa1..e118765f7 100755 --- a/misc/userscripts/open_download +++ b/misc/userscripts/open_download @@ -121,4 +121,4 @@ else msg info "Opening »$file« (of type $filetype) with ${application%.desktop}" fi -xdg-open "$path" & +xdg-open "$path" -- cgit v1.2.3-54-g00ecf