Assign shortcut to "narrow down search" in Collections module

I often want to display only the thumbnails for pictures that are either untagged or not geotagged, so that I can tag and geotag them. I do this in the Collections module with the “narrow down search” item then select the appropriate metadata item to search on. It seems like I ought to be able to assign a shortcut to this but I don’t see a way to do it. I tried using a collections preset, but it ends up being specific to the particular film roll that the preset was created on. The “collection filters” module doesn’t have a rule for either of these so I haven’t been able to use that.

Is there some way to assign a shortcut to this? Is there a way to do it with a preset that I haven’t found? It takes five mouse clicks every time I do it, and since I do this for every film roll I’d really like to be able to do it more efficiently.

I have tried to do something similar, but simpler: a preset to add exclude → tags → darktable → exported to the currently active film roll.

I gave up. But if anyone can give a solution to your requirement, it will probably adapt to mine too.

Time for my standard pat answer :grin:, you can do that with a Lua script. I wonder if I should trademark that? :rofl:

Anyway…

There is already a Lua script, select_untagged.lua, that provides another button in the image selection module to select all untagged images. I’m not sure if it can be shortcut or not, but if not it’s trivial to add.

There is another Lua script, geoToolBox.lua that has shortcuts to select images with and without GPS information. It will also allow you to assign GPS information.

So now we need a way to make a collection of just the selected images. It just so happens that a couple of nights ago I was working on a similar problem with selecting duplicates and got to this point so I created a script, selection2collection.lua, that adds a button to the selected images module to create temporary collections that last until you close darktable. You can choose to make them last across darktable instances if you want. The script needs a little polishing before I turn it loose.

The secret to the selection2collection script is that it creates a “temporary” tag and assigns it to the selected images. Then it simply uses the collection module to filter on the tag. So, if you’re in a hurry you can do it this way and then just delete the tag from the tagging module, which will remove it from all the images, when you’re done.

2 Likes

Lua that, luv! ™

1 Like

Thanks for the detailed response. I suspected Lua might be the answer. I would be very interested in testing your selection2collection script, even as an alpha tester.

selection2collection.zip (2.8 KB)

Thank you Bill.

LUA is still an unexplored continent for me.

I’m just thinking, slightly sadly… Twenty-five years ago, I would have jumped on a scripting language. Hmmm…

This works great, thanks!

I was able to assign shortcut keys to both selection2collection as well as geotoolbox “select non-geo images”. I also wanted one for select_untagged, but it doesn’t appear to have registered a shortcut function. I tried to create one myself, but while it does run it doesn’t select any images. Clicking the UI button does. I think it’s because the function that does all the work in select_untagged returns a selection while the shortcut function doesn’t allow for this. Or if it does I don’t know how to do it.

Is this something you could help me with? Here’s the code I added to select_untagged:

local function just_doit()
  images = dt.collection
  select_untagged_images("shortcut", images)
end

dt.register_event("select_untagged", "shortcut", 
  function(event, shortcut)
    selection = just_doit()
    dt.gui.selection(selection)
  end, _("select all images containing no tags or only tags added by darktable")
)

I’m an idiot. I wasn’t returning the selection returned by select_untagged_images. Once I did that it worked fine.

local function just_doit()
  images = dt.collection
  selection = select_untagged_images("shortcut", images)
  return selection
end

Thanks again for making this possible.

1 Like

I’m always amazed at how much better I am at finding my errors once I’ve showed the problem to everyone :rofl:

1 Like