Hi,

On Fri, Oct 25, 2024 at 10:00:44PM +0200, Rodrigo Arias wrote:
> Yeah, maybe I could also make it like this so you can specify a 
> program directly:
> 
> actions="Open with external tool:/path/to/the/handler.sh default $URL"
> actions="Open as audio:/path/to/the/handler.sh audio \"$URL\""
> actions="Open with MPV:mpv $URL"
> actions="Open with Firefox:firefox $URL"

I implemented this here using the option "link_action" which will *only* 
add new entries to the Link menu:

https://github.com/dillo-browser/dillo/pull/326

https://github.com/dillo-browser/dillo/pull/326.patch

I set the $url environment variable to hold the link URL and $origin to 
hold the current page URL, in case you want to handle links different 
based on which page you where clicking from.

It would be nice if it gets some testing, specially with strange URL 
looking cases. Hopefully it covers all your use cases, Alex.

> But this won't work well when the URL has characters that are interpreted by
> the shell.
> 
> It "should" be like:
> 
> actions="Open with external tool:/path/to/the/handler.sh default \"$URL\""
> actions="Open as audio:/path/to/the/handler.sh audio \"$URL\""
> actions="Open with MPV:mpv \"$URL\""
> actions="Open with Firefox:firefox \"$URL\""
> 
> But is quite ugly. And I'll have to check if you can still inject some
> command in the URL, which would be dangerous.

This doesn't seem to be necessary, $() or $foo are not expanded when 
they appear in the $url.

> > > Then, your handler will be invoked using the label as:
> > > 
> > > /bin/the-handler <URL> <action-label>
> > > 
> > > And you do whatever you find convenient in your handler, so you have
> > > more context to decide the proper action based on the label. I think
> > > this would cover most of the use cases of opening URLs with other
> > > programs without being too convoluted.
> > 
> > What would the default behaviour be? Will Dillo install a default
> > handler with its own separate configuration file for setting up the
> > default 'action' behaviours? Or does the feature only appear after
> > each user has created their own handler?
> 
> By default, no extra options. As you add the actions they appear on the
> menu. We may want to distribute an example handler for users to have a
> reference.

The current design also covers this "tag" mechanism as a specific case:

  link_action="Open video:my-handler video"
  link_action="Open audio:my-handler audio"

And in my opinion is more simple, as it can be used directly without any 
script:

  link_action="Open with MPV:mpv $url"
  link_action="Open with Firefox:firefox $url"

In the future we can also add a similar thing for when Dillo opens an 
URL but the content type is unknown, so that it offers more options than 
a download. At that point we will know the content type, so we can do 
better handling. But let's keep it simple for 3.2.0.

Best,
Rodrigo.
_______________________________________________
Dillo-dev mailing list -- dillo-dev@mailman3.com
To unsubscribe send an email to dillo-dev-le...@mailman3.com

Reply via email to