lua - copy & paste history

How would you copy history of an image and paste (overwrite) to another using only lua scripting? Assume that the source/destination file names are known.
I’m searching right now in lua documentation, unfortunately I don’t have any clue where to start … :slight_smile:
Thanks.

use dt.gui.action() shortcuts

1 Like

Thanks! I see, the action paths are displayed in Preferences/Shortcuts … :slight_smile: I’ll give it a try!

I read in lua documentation (https://docs.darktable.org/lua/stable/lua.api.manual/darktable/gui/action/):

darktable.gui.action

function(
  path : string,
  [instance] : integer,
  element : string,
  [effect] : string,
  [speed] : integer
) : string

Will perform the specified effect on the path, instance, and element of an action, or return the status.

    path - string - The full path of an action, i.e. 'lib/filter/view'.
    [instance] - integer - Optional - The instance of an image processing module to execute action on. If not provided, 1 is used.
    element - string - The element of an action, for example ‘selection’, or leave empty for default.
    [effect] - string - Optional - The effect of an action, for example ’next’, or leave empty for default.
    [speed] - integer - Optional - 1 causes the effect to be performed, 0 or NaN returns the current status.
    return - string - The current status of the action.

My question is: what other possibilities do I have for “element” and “effect”? Where can I find more to read about it?

E.g. I want to set history stack mode to overwrite, using dt.gui.action()

I did some searching in the source code, and I found this info regarding combo box:

/* bauhaus.c */
static const dt_action_element_def_t _action_elements_combo[]
  = { { N_("selection"), dt_action_effect_selection },
      { N_("button"), dt_action_effect_toggle },
      { NULL } };

/* accelerators.c */
const gchar *dt_action_effect_selection[]
  = { N_("popup"),
      N_("next"),
      N_("previous"),
      N_("reset"),
      N_("last"),
      N_("first"),
      NULL };

const gchar *dt_action_effect_toggle[]
  = { N_("toggle"),
      N_("on"),
      N_("off"),
      N_("ctrl-toggle"),
      N_("ctrl-on"),
      N_("right-toggle"),
      N_("right-on"),
      NULL };

If I understand, for combo box the “element” argument could be: selection, toggle.
For selection we can use the following effect: popup, next, …
For toggle we can choose from: toggle, on, off

I can use now dt.gui.action("lib/copy_history/mode", "selection", "last", 1,000)
to set the history stack mode to overwrite (my question in the OP).
It works for now as a workaround, but in the future, if somebody changes the position of the item overwrite in the combo box … I could damage my edits without knowing it! I was hopping to have something like set value = “overwrite”: this will work always, no matter the position of item owerwrite in combo … :wink:

Another thing which is for me confusing: why is toggle used for a combo box? Combo box is not limited to only 2 states, it is a list of elements. :slight_smile: In our particular case, we have only 2, so it could be seen as a toggle button … but it is still confusing.

I will be happy, if someone could bring some light to this topic. I really enjoy automating my image editing and I want to understand, how things are working here … Thanks! :slight_smile:

That would only happen in a release, and those only occur twice a year. So at worst you’d have to check twice a year when you upgrade, or read the release notes.

You can find an action you want to use then assign a shortcut to it. It will then appear in the bottom of the window and you can click on the various fields and see the possible values.

1 Like