This commit is contained in:
Florian Tham
2025-04-10 11:25:20 +02:00
parent c00038b63c
commit bc308b4845
3 changed files with 71 additions and 11 deletions

View File

@@ -73,8 +73,8 @@ end
local script_data = {}
script_data.metadata = {
name = _("open OoC JPEG"),
purpose = _("open associated OoC JPEGs for selected RAW files"),
name = _("open ooc jpeg"),
purpose = _("open associated ooc jpegs for selected raw files"),
author = "Florian Tham <fgtham@gmail.com>",
help = "https://docs.darktable.org/lua/stable/lua.scripts.manual/scripts/contrib/open_ooc"
}
@@ -84,20 +84,38 @@ script_data.destroy_method = nil -- set to hide for libs since we can't destroy
script_data.restart = nil -- how to restart the (lib) script after it's been hidden - i.e. make it visible again
script_data.show = nil -- only required for libs since the destroy_method only hides them
local viewer = {}
viewer.executable = "sxiv"
viewer.args = ""
local function open_ooc() --finalize
local images = dt.gui.selection()
local selected_images = dt.gui.selection()
local file_list = ""
if #images == 0 then
if #selected_images == 0 then
dt.print(_("please select an image"))
return
end
for _, image in pairs(images) do
file_list = file_list .. image .. " "
dt.print(image)
for _, image in pairs(selected_images) do
if df.get_filetype(image.filename) == "CR3" then
current_image = image.path .. os_path_seperator .. image.filename
current_image = string.gsub(current_image, ".CR3", ".JPG")
if df.check_if_file_exists(current_image) then
file_list = file_list .. current_image .. " "
end
end
end
dt.print(file_list)
if file_list == "" then
dt.print(_("selection empty, or no jpeg available"))
return
end
cmd = viewer.executable .. " " .. viewer.args .. " " .. file_list
dt.print_log("open_ooc: " .. cmd)
dtsys.external_command(cmd)
end
@@ -109,15 +127,15 @@ end
-- Register
dt.gui.libs.image.register_action(
MODULE, _("open associated OoC JPEGs"),
MODULE, _("open jpeg"),
function() open_ooc() end,
_("open associated OoC JPEGs for the selected raw files")
_("open associated ooc jpegs for the selected raw files")
)
dt.register_event(
MODULE,
"shortcut",
function(event, shortcut), open_ooc() end,
function(event, shortcut) open_ooc() end,
MODULE
)