Call darktable from command line when instance is already running

I am on macOS Sonoma.

I am trying to call darktable from the command line and show an image in darkroom. When no instance of darktable is running this works. When darktable is already running, I get the message that the database is locked. This makes sense. However it is possible to call darktable from digikam, Finder or XnView (open with) while darktable is running. How do I call darktable and open a specific image when an instance is live ?

Same issue is with darktable-cli to convert raw files to jpg for example.

1 Like

You can run darktable with a separate config directory:
/Applications/darktable.app/Contents/MacOS/darktable --configdir ~/.config/darktable_test

1 Like

Thanks @MStraeten this opens a new instance of darktable which is half of the solution I am looking for. It doesn’t have access to the main database.

I was hoping I could achieve something like selecting an image in Finder and use right click and 'Open with". This allows full access to the database.

Thanks.

There‘s no way to access the libraries with a second instance …

Allowing two instances of darktable write access to the same database is likely to corrupt the database (sooner or later). SQLite is not designed to allow this (unlike a database server like MySQL). So each instance of darktable locks the database it is using against other instances.

Note that this lock may not stop you from using another program to write to the database…

If you want to close an existing instance first, you can use an AppleScript command in front:
osascript -e 'tell application "Darktable" to if it is running then quit' && open -a Darktable /path/to/my/image

Thanks for all the replies. If I understand correctly when calling darktable from Finder, digikam, XnView and the likes could lead to corrupted databases.

If that is the case, then I see the comment from @HIRAM as the only clean solution.

no, since darktable prevents opening a second session with the same database - calling darktable from Finder etc. doesn’t corrupt the database.

darktable-cli can be used to batch process raw files with an existing xmp file in parallel to a interactive darktable session - if you invoke it with a temporary config directory:
/opt/darktable/bin/darktable-cli <RAW to be processed> <XMP to be used> <output directory> --core --configdir ~/.config/darktable_temp

so it’s up to your usecase … a second instance (interactive or cli) needs a second configdir

Thanks @MStraeten. Then I am missing something.

When I have a darktable instance running and then go to Finder and use “Open with” for a photo, the same pid (checked in Activity Monitor) is used for showing me the photo and I have full access to my library in lighttable.

Somehow Finder is “jumping into” the active instance. The same is true for XnView and digikam. This is exactly what I try to achieve.

If there is a way to “jump into” an active instance as it looks to me, does that mean there is the risk for a corrupted database as mentioned by posters above. Then that would render the use of external DAMs like digikam, XnView and Finder risky.

Or there is a way to “jump into” which is supported by darktable.

Thanks for your patience. I am trying to get my head around it and find a way how to solve my issue.

What issue are you trying to solve? I dont understand your end goal with multiple instances.

On Mac just open the file with open -a Darktable /path/to/my/image it should send the file to be opened to the already open instance. If one is not running it will launch the app.

Thanks @HIRAM that is exactly what I was looking for.

What I am trying to solve is the following:

From the time using Lightroom I have exported pictures in tiff and jpg which had the changes I made on the raw files.

I wrote a little script to go over my files and search for instances where I have a raw file with a “companion” tiff or jpg file. The first part of my filenames is always YYMMDD-HHMMSS. Raw files have the canon ending and tiff or jpg files have all kind of different suffixes.

Now I want to check the images and decide if I replicate the changes / improve for some of them in darktable. The script will now call darktable with the raw file and the “companion” is just beside in darktable.

Ok. I was confused by this line:

thinking you were already using the open -a command, but you were doing something else like calling the mac app by running the main executable interior to the bundle.


To open a sencond instance with a new config dir, the proper command would be:

open -n -a Darktable --args --configdir ~/.config/darktable_test