From 47b3ab0b3db400a13e4739de983725ef9d76997b Mon Sep 17 00:00:00 2001 From: Matt Watson Date: Mon, 21 Nov 2016 23:30:02 -0800 Subject: [PATCH 1/2] xdg-open: add flatpak support When we are in the flatpak sandbox, use the flatpak portal to open uris. --- scripts/xdg-open.in | 19 +++++++++++++++++++ scripts/xdg-utils-common.in | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/scripts/xdg-open.in b/scripts/xdg-open.in index cb41ac6..f93e005 100644 --- a/scripts/xdg-open.in +++ b/scripts/xdg-open.in @@ -223,6 +223,21 @@ open_enlightenment() fi } +open_flatpak() +{ + gdbus call --session \ + --dest org.freedesktop.portal.Desktop \ + --object-path /org/freedesktop/portal/desktop \ + --method org.freedesktop.portal.OpenURI.OpenURI \ + "" "$1" {} + + if [ $? -eq 0 ]; then + exit_success + else + exit_failure_operation_failed + fi +} + #----------------------------------------- # Recursively search .desktop file @@ -504,6 +519,10 @@ case "$DE" in open_darwin "$url" ;; + flatpak) + open_flatpak "$url" + ;; + generic) open_generic "$url" ;; diff --git a/scripts/xdg-utils-common.in b/scripts/xdg-utils-common.in index cf08cd3..2909f9a 100644 --- a/scripts/xdg-utils-common.in +++ b/scripts/xdg-utils-common.in @@ -332,6 +332,10 @@ detectDE() # but not in GNOME 3.x which gnome-default-applications-properties > /dev/null 2>&1 || DE="gnome3" fi + + if [ -f $XDG_RUNTIME_DIR/flatpak-info ]; then + DE="flatpak" + fi } #---------------------------------------------------------------------------- -- 2.1.4