2

Android has a convenient feature: certain https links that have associated local apps installed are opened directly in these apps, skipping the browser page. How do I achieve this in Linux?

I have Zoom installed on my computer. When someone shares a https://zoom.us/j/NNNN link with me and I click it in e.g. Thunderbird, this link is passed to xdg-open. Xdg-open looks at the URI schema "https" and starts the default browser. The browser navigates to this URI and displays a page whose only function is to transform this URI into a different one: zoommtg://zoom.us/join?confno=NNNN. This new URI is in turn passed to xdg-open who launches Zoom.

I could not find a ready-made solution so far. I imagine a script that looks beyond the URI schema. For example, if it receives a parameter starting with https://zoom.us/j/, it ensures that a handler for zoommtg is configured, in which case it rewrites the URI by itself and passes it to the handler. There is supposedly a limited number of popular schemes, so such a script should be relatively simple to maintain.

The script could be used either as a wrapper for xdg-open or as a handler for https links.

At best I would appreciate a link to an existing software which does that. I’d hate to write a script only for my personal use. If such software doesn’t exist so far, I welcome advice on implementing this in a portable way with a goal to publish it.

1 Answer 1

1

In the end, I have rolled my own: open-uri-in-native-app. A short bash script and a desktop file.

Here’s an excerpt of the script to be set as the handler for https links:

#!/usr/bin/env bash
URI=$1
if [[ $URI =~ ^https://zoom.us/j/ ]]; then
  ZOOM=$(xdg-mime query default x-scheme-handler/zoommtg)
  if [[ -n $ZOOM ]]; then
    NEW=$(echo $URI | sed -E 's@https://zoom.us/j/@zoommtg://zoom.us/join?confno=@; s@\?pwd=@\&pwd=@')
    gtk-launch $ZOOM $NEW
    exit 0;
  fi
fi
BROWSER=$(xdg-mime query default x-scheme-handler/http)
gtk-launch $BROWSER $URI
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .