summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2022-03-31 14:40:33 +0200
committerFlorian Bruhin <me@the-compiler.org>2022-03-31 14:40:33 +0200
commit50922bf6206c9fffd04821b5e29be6be42072285 (patch)
tree4ef0addd7e176a2b533109a25539f7911eaf884a
parent887253f70c5adeaae9e94b28c96b42e1009de515 (diff)
parent2d44db28e2f87b2d28a96299d5339ff04efb05c5 (diff)
downloadqutebrowser-50922bf6206c9fffd04821b5e29be6be42072285.tar.gz
qutebrowser-50922bf6206c9fffd04821b5e29be6be42072285.zip
Merge remote-tracking branch 'origin/pr/6957'
-rwxr-xr-xmisc/userscripts/open_download23
1 files changed, 16 insertions, 7 deletions
diff --git a/misc/userscripts/open_download b/misc/userscripts/open_download
index 62730f37c..e118765f7 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" &
+xdg-open "$path"