From 140d9ebd912ed803dd916c6ab3783a79a2a724e3 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Fri, 14 Jun 2024 22:27:18 +0200 Subject: [PATCH] Add support for user actions in the link menu Allows the user to define additional entries in the link menu which will execute the given program/script. Each actions is defined using the "link_action" option. The link URL is stored in the $url enviroment variable and the current page in $origin, so the user can customize how do the handling. Here is a simple example to add three new entries: link_action="Debug variables:echo url=$url origin=$origin" link_action="Open in MPV:mpv $url" link_action="Open in Firefox:firefox $url" The command is spawned in a forked process using the system() call, which uses the shell to expand any variable. In particular, the $url variable is set to the current URL being opened. Fixes: https://github.com/dillo-browser/dillo/issues/3 --- ChangeLog | 2 + dillorc | 11 +++++ src/Makefile.am | 2 + src/actions.c | 65 ++++++++++++++++++++++++ src/actions.h | 32 ++++++++++++ src/dillo.cc | 2 + src/html.cc | 2 +- src/menu.cc | 121 ++++++++++++++++++++++++++++++++++++++++----- src/menu.hh | 3 +- src/prefs.c | 1 + src/prefs.h | 1 + src/prefsparser.cc | 1 + src/uicmd.cc | 4 +- src/uicmd.hh | 2 +- 14 files changed, 233 insertions(+), 16 deletions(-) create mode 100644 src/actions.c create mode 100644 src/actions.h diff --git a/ChangeLog b/ChangeLog index 4f1d23ac0..89348d3ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,6 +29,8 @@ dillo-3.2.0 [Not released yet] - Reload current page on SIGUSR1 signal - Print library versions and enabled features with dillo -v. - Allow image formats to be ignored with the "ignore_image_formats" option. + - Add the "link_action" option to define custom menu entries to open links + with external programs or scripts. Patches: Rodrigo Arias Mallo +- Add primitive support for SVG using the nanosvg.h library. - Add support for ch, rem, vw, vh, vmin and vmax CSS units. diff --git a/dillorc b/dillorc index 88afe11a8..484185c21 100644 --- a/dillorc +++ b/dillorc @@ -64,6 +64,17 @@ # jump to a given position. #scrollbar_page_mode=NO +# Define custom actions for the link menu. The format is