Lack of documentation about Darktable and Lua scripting is no secret. Anyway, here is how I managed to write an effective custom shortcut that comes in handy for my photos.

Now I started to take photos more seriously. I’ve been snapping photos since decades and it’s always been a great fun.

For photos on the go my smartphone and its software are very valuable. But recently I began taking raw photos using my two digital cameras. In order to develop and export these photos into high-quality JPEG files I chose to use the latest AppImage of Darktable for Ubuntu (version 4.8.0).

I also bought a brand new SSD USB disk dedicated for my new raw-photo production. More in detail, I’m using this disk for the following:

  • extra-backup for imported RAW files an their corresponding .xmp files;
  • extra-backup for final exported JPEG files;
  • saving Darktable configuration and status on the SSD disk, so I can keep working on my photos switching between my home computer and my laptop, seamlessly, having installed the same version of the software on both computers.

About this last point, I moved ~/.config/darktable/ under /PATH/TO/SSD/.config/darktable/ and ~/.local/lensfun/ under /PATH/TO/SSD/.local/lensfun/ (I manually installed lensfun with latest upgrades). Then, I created ~/.config/darktable and ~/.local/lensfun as symbolic links to their respective destinations.

Having started to process raw files, I found some useful initial settings, valid for almost every photo of mine but a good starting point for further processing. Quite time-consuming indeed. So I decided to write a Lua script to be executed with a keyboard shortcut, in order to apply all initial settings at once. And this was the hard part because there is not much documentation online in order to do so.

I managed to write an accettable and working script after hours/days of trials and errors. dt.gui.action() is powerful, but what are valid actions for a specific module? Is it possible/legit to enable a module as I was switching the on/off button (I still cannot switch lens correction on)? Anyway, here is my script: no error checking (you may want to add the -debug lua switch from command line) and it could only work under certain conditions. It’s been written for my current Darktable GUI configuration and according to my favourite initial settings, but I hope you can use it to find some suggestions for your scripts, just in case.

-- workaround: enable a module by changing some values
dt = require "darktable"

local function sony_basic_settings(event, shortcut)
    -- darkroom view only
    if dt.gui.current_view() ~= dt.gui.views.darkroom then
        return 0/0
    end

    --- ### color balance rgb - global vibrance, global chroma, global brilliance
    dt.gui.action("iop/colorbalancergb/global vibrance", 0, "value", "set", 0.05)
    dt.gui.action("iop/colorbalancergb/global chroma", 0, "value", "set", 0.2)
    dt.gui.action("iop/colorbalancergb/global brilliance", 0, "value", "set", 0.12)

    -- ### sharpen - radius, amount
    dt.gui.action("iop/sharpen/radius", 0, "value", "set", 3.0)
    dt.gui.action("iop/sharpen/amount", 0, "value", "set", 0.6)

    -- ### color look up table - Fuji Astia - (force enable) ###
    dt.gui.action("iop/colorchecker/preset/Fuji Classic Chrome emulation", 0, "value", "set", 1.0)
    dt.gui.action("iop/colorchecker/preset/Fuji Astia emulation", 0, "value", "set", 1.0)

    -- ### denoise (profile) - (force enable) ###
    dt.gui.action("iop/denoiseprofile", 0, "enable", "off", 1.0)
    dt.gui.action("iop/denoiseprofile", 0, "enable", "on", 1.0)

    dt.print("Sony ZV-1 basic settings applied")
end

dt.register_event("sony_basic_settings", "shortcut", sony_basic_settings,
        "Set basic settings for RAW photos by Sony ZV-1")