Darktable Keyboard-Shortcut-Lua-Scripting

I wanted to be able to quickly get to AgX primaries-panel after doing some initial edits from the Quick Access Panel. This seems to require some scripting and I have hacked together the following. It works…sort of unreliably.

local dt = require "darktable"

local function agx_primaries_shortcut(event, shortcut)
-- Toggle AGX Modul anzeigen
dt.gui.action("iop/agx", "show", "on", 1.000, 0)
-- Primaries-Tab innerhalb von AGX aktivieren
dt.gui.action("iop/agx/page", "primaries", "activate", 1.000, 0)
end

dt.register_event("agx_primaries_shortcut",
                  "shortcut",
                  agx_primaries_shortcut,
                  "A shortcut that toggles AGX and opens Primaries tab")

On the matter of reliablitiy: No matter whether dt.gui.action("iop/agx", "show", "toggle", 1.000, 0) is set to toggle or on it will always toggle. This means, if AgX is expanded in some module-panel and you are e.g. coming from the QAP, the script will actually collapse the module. This behaviour is consistent through all module, not limited to lua scripts and applies to keyboard shortcuts in general. Might this be a bug…?

How to use: This needs to go into your lua folder and be referenced in luarc. If you are using the appimage or a package-install it will probably be ~./config/darktable/lua. Just plop the file down there and add require "agx_primaries" to ~/.config/darktable/luarc. Also see the documentation. After setting up the file you can set the shortcut from “options/shortcuts/Lua scripts”

You can check this with dt.gui.action("iop/agx", "show", "on", 0, 0). If it’s on then the return should be 1 otherwise 0.

1 Like

You mean I could setup if/then in the script to check the current status? I’ll look into it but also opened a bug report since I believe there is a bug in the shortcut-settings.

You might want "enable" instead of "show". If you use "enable", "on" then if should turn on if it’s off, and do nothing if it’s already on.

I gave your hint a try: This unfortunately doesn’t work. My goal is to get to AgX primaries sliders. enable/on will activate the module but won’t e.g. switch from the QAP to the full processing module.

Also with repeated actuations it will deactivate/activate the module. Similarily to how show/enable actually toggles expanding/collapsing the module.