diff --git a/pkgs/additional/sane-open/sane-open b/pkgs/additional/sane-open/sane-open index 79b55cc1c..9932f5724 100755 --- a/pkgs/additional/sane-open/sane-open +++ b/pkgs/additional/sane-open/sane-open @@ -12,6 +12,8 @@ usage() { echo "--auto-keyboard: toggle the virtual keyboard state to whatever's preferred by the app" echo "--application : open the desktop file (by name, not path)" echo "--file : open the file using the default mime handler" + echo "--uri : open the URI using the default mime handler" + echo " e.g. --uri https://uninsane.org" exit $1 } @@ -84,16 +86,6 @@ open_application() { --method org.freedesktop.portal.DynamicLauncher.Launch \ "$1" {} } -open_file() { - # open the file, and then pass the fd to dbus - log "open_file: '$1'" - exec 3< "$1" - gdbus call --session --timeout 10 \ - --dest org.freedesktop.portal.Desktop \ - --object-path /org/freedesktop/portal/desktop \ - --method org.freedesktop.portal.OpenURI.OpenFile \ - "" 3 "{'ask': }" -} open_desktopFile() { log "open_desktopFile: '$1'" local target=$(tryAsDesktopFile "$1") @@ -107,6 +99,24 @@ open_desktopFile() { open_application "$target" fi } +open_file() { + # open the file, and then pass the fd to dbus + log "open_file: '$1'" + exec 3< "$1" + gdbus call --session --timeout 10 \ + --dest org.freedesktop.portal.Desktop \ + --object-path /org/freedesktop/portal/desktop \ + --method org.freedesktop.portal.OpenURI.OpenFile \ + "" 3 "{'ask': }" +} +open_uri() { + log "open_uri: '$1'" + gdbus call --session --timeout 10 \ + --dest org.freedesktop.portal.Desktop \ + --object-path /org/freedesktop/portal/desktop \ + --method org.freedesktop.portal.OpenURI.OpenURI \ + "" "$1" "{'ask': }" +} # evaluate truthy and print desktop name as `FOO.desktop` if the provided file is a .desktop file suitable for open_application. tryAsDesktopFile() { @@ -200,6 +210,9 @@ while [ $# -gt 0 ]; do "--file") resourceType="file" ;; + "--uri") + resourceType="uri" + ;; *) if [ $# -ne 0 ]; then usage 1