From 224dce1b765ca4cf561d56e1c875e38995ea1644 Mon Sep 17 00:00:00 2001 From: preklov <63585095+preklov@users.noreply.github.com> Date: Tue, 14 Apr 2020 15:04:31 +0200 Subject: [PATCH 1/9] Delete OpenInExplorer.lua --- contrib/OpenInExplorer.lua | 113 ------------------------------------- 1 file changed, 113 deletions(-) delete mode 100644 contrib/OpenInExplorer.lua diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua deleted file mode 100644 index 11f004f..0000000 --- a/contrib/OpenInExplorer.lua +++ /dev/null @@ -1,113 +0,0 @@ ---[[ -OpenInExplorer plugin for darktable - - copyright (c) 2018 Kevin Ertel - - darktable is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - darktable is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with darktable. If not, see . -]] - ---[[About this plugin -This plugin adds the module "OpenInExplorer" to darktable's lighttable view - -----REQUIRED SOFTWARE---- -Microsoft Windows or Linux with installed Nautilus - -----USAGE---- -Install: (see here for more detail: https://github.com/darktable-org/lua-scripts ) - 1) Copy this file in to your "lua/contrib" folder where all other scripts reside. - 2) Require this file in your luarc file, as with any other dt plug-in - -Select the photo(s) you wish to find in explorer and press "Go to Folder". -A file explorer window will be opened for each selected file at the file's location; the file will be highlighted. - -----KNOWN ISSUES---- -]] - -local dt = require "darktable" -local du = require "lib/dtutils" -local df = require "lib/dtutils.file" -local dsys = require "lib/dtutils.system" - ---Check API version -du.check_min_api_version("5.0.0", "OpenInExplorer") - -local PS = dt.configuration.running_os == "windows" and "\\" or "/" - ---Detect OS and modify accordingly-- -local proper_install = false -if dt.configuration.running_os ~= "macos" then - proper_install = true -else - dt.print_error('OpenInExplorer plug-in only supports Windows and Linux at this time') - return -end - - --- FUNCTIONS -- - -local function open_in_explorer() --Open in Explorer - local images = dt.gui.selection() - local curr_image = "" - if #images == 0 then - dt.print('please select an image') - elseif #images <= 15 then - for _,image in pairs(images) do - curr_image = image.path..PS..image.filename - local run_cmd = "explorer.exe /select, "..curr_image - dt.print_log("OpenInExplorer run_cmd = "..run_cmd) - resp = dsys.external_command(run_cmd) - end - else - dt.print('please select fewer images (max 15)') - end -end - -local function open_in_nautilus() --Open in Nautilus - local images = dt.gui.selection() - local curr_image = "" - if #images == 0 then - dt.print('please select an image') - elseif #images <= 15 then - for _,image in pairs(images) do - curr_image = image.path..PS..image.filename - local run_cmd = [[busctl --user call org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1 ShowItems ass 1 ]] .. df.sanitize_filename("file://"..curr_image) .. [[ ""]] - dt.print_log("OpenInExplorer run_cmd = "..run_cmd) - resp = dsys.external_command(run_cmd) - end - else - dt.print('please select fewer images (max 15)') - end -end - -local function open_in_filemanager() --Open - --Inits-- - if not proper_install then - return - end - - if (dt.configuration.running_os == "windows") then - open_in_explorer() - elseif (dt.configuration.running_os == "linux") then - open_in_nautilus() - end -end - --- GUI -- -if proper_install then - dt.gui.libs.image.register_action( - "show in file explorer", - function() open_in_filemanager() end, - "Opens File Explorer at the selected image's location" - ) -end From fb331710e11ead8fa910ddd18166df32b3bbc41d Mon Sep 17 00:00:00 2001 From: preklov <63585095+preklov@users.noreply.github.com> Date: Tue, 14 Apr 2020 15:07:22 +0200 Subject: [PATCH 2/9] Add files via upload --- contrib/OpenInExplorer.lua | 98 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 contrib/OpenInExplorer.lua diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua new file mode 100644 index 0000000..65449c7 --- /dev/null +++ b/contrib/OpenInExplorer.lua @@ -0,0 +1,98 @@ +--[[ +OpenInExplorer plugin for darktable + + copyright (c) 2018 Kevin Ertel + Update 2020: copyright (c) 2020 Volker Lenhardt + + darktable is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + darktable is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with darktable. If not, see . +]] + +--[[About this plugin +This plugin adds the module "OpenInExplorer" to darktable's lighttable view + +----REQUIRED SOFTWARE---- +Microsoft Windows or Linux with installed Nautilus + +----USAGE---- +Install: (see here for more detail: https://github.com/darktable-org/lua-scripts ) + 1) Copy this file in to your "lua/contrib" folder where all other scripts reside. + 2) Require this file in your luarc file, as with any other dt plug-in + +Select the photo(s) you wish to find in explorer and press "Go to Folder". +A file explorer window will be opened for each selected file at the file's location; the file will be highlighted. + +----KNOWN ISSUES---- +Under macOS the file manager Finder opens only once and selects the file name of the last in DT selected image. +]] + +local dt = require "darktable" +local du = require "lib/dtutils" +local df = require "lib/dtutils.file" +local dsys = require "lib/dtutils.system" +local gettext = dt.gettext + +--Check API version +du.check_min_api_version("5.0.0", "OpenInExplorer") + +gettext.bindtextdomain("OpenInExplorer",dt.configuration.config_dir.."/lua/locale/") + +local function _(msgid) + return gettext.dgettext("OpenInExplorer", msgid) +end + +local act_os = dt.configuration.running_os +local PS = act_os == "windows" and "\\" or "/" + +--Detect OS and modify accordingly-- +local proper_install = true +if act_os ~= "macos" and act_os ~= "windows" and act_os ~= "linux" then + proper_install = false + dt.print_error(_('OpenInExplorer plug-in only supports Windows and Linux at this time')) + return +end + +--The commands to open the OSes' file managers +local fmng_cmd = {} +fmng_cmd.linux = [[busctl --user call org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1 ShowItems ass 1 ]] +fmng_cmd.macos = 'open -R -n ' +fmng_cmd.windows = 'explorer.exe /select, ' + +--The working function that opens the file manager with the image file name selected. +local function open_in_fmanager(os, fmcmd) + local images = dt.gui.selection() + local curr_image = "" + if #images == 0 then + dt.print(_('Please select an image')) + elseif #images <= 15 then + for _,image in pairs(images) do + curr_image = df.sanitize_filename(image.path..PS..image.filename) + local run_cmd = fmcmd..curr_image + if os == 'linux' then run_cmd = run_cmd .. [[ ""]] end + dt.print_log("OpenInExplorer run_cmd = "..run_cmd) + resp = dsys.external_command(run_cmd) + end + else + dt.print(_('Please select fewer images (max 15)')) + end +end + + +-- GUI -- +if proper_install then + dt.gui.libs.image.register_action( + _("Show in file explorer"), + function() open_in_fmanager(act_os, fmng_cmd[act_os]) end, + _("Opens File Explorer at the selected image's location") + ) +end From afa95d5d3419f3ba6e03c9fb3199209ea358251e Mon Sep 17 00:00:00 2001 From: preklov <63585095+preklov@users.noreply.github.com> Date: Tue, 14 Apr 2020 15:26:28 +0200 Subject: [PATCH 3/9] Update OpenInExplorer.lua --- contrib/OpenInExplorer.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua index 65449c7..6f6912f 100644 --- a/contrib/OpenInExplorer.lua +++ b/contrib/OpenInExplorer.lua @@ -65,7 +65,7 @@ end --The commands to open the OSes' file managers local fmng_cmd = {} fmng_cmd.linux = [[busctl --user call org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1 ShowItems ass 1 ]] -fmng_cmd.macos = 'open -R -n ' +fmng_cmd.macos = 'open -R ' fmng_cmd.windows = 'explorer.exe /select, ' --The working function that opens the file manager with the image file name selected. From bd5bef279c53f896277d4f20e4a3a70b88adb994 Mon Sep 17 00:00:00 2001 From: preklov <63585095+preklov@users.noreply.github.com> Date: Tue, 14 Apr 2020 15:36:48 +0200 Subject: [PATCH 4/9] Delete OpenInExplorer.lua --- contrib/OpenInExplorer.lua | 98 -------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 contrib/OpenInExplorer.lua diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua deleted file mode 100644 index 6f6912f..0000000 --- a/contrib/OpenInExplorer.lua +++ /dev/null @@ -1,98 +0,0 @@ ---[[ -OpenInExplorer plugin for darktable - - copyright (c) 2018 Kevin Ertel - Update 2020: copyright (c) 2020 Volker Lenhardt - - darktable is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - darktable is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with darktable. If not, see . -]] - ---[[About this plugin -This plugin adds the module "OpenInExplorer" to darktable's lighttable view - -----REQUIRED SOFTWARE---- -Microsoft Windows or Linux with installed Nautilus - -----USAGE---- -Install: (see here for more detail: https://github.com/darktable-org/lua-scripts ) - 1) Copy this file in to your "lua/contrib" folder where all other scripts reside. - 2) Require this file in your luarc file, as with any other dt plug-in - -Select the photo(s) you wish to find in explorer and press "Go to Folder". -A file explorer window will be opened for each selected file at the file's location; the file will be highlighted. - -----KNOWN ISSUES---- -Under macOS the file manager Finder opens only once and selects the file name of the last in DT selected image. -]] - -local dt = require "darktable" -local du = require "lib/dtutils" -local df = require "lib/dtutils.file" -local dsys = require "lib/dtutils.system" -local gettext = dt.gettext - ---Check API version -du.check_min_api_version("5.0.0", "OpenInExplorer") - -gettext.bindtextdomain("OpenInExplorer",dt.configuration.config_dir.."/lua/locale/") - -local function _(msgid) - return gettext.dgettext("OpenInExplorer", msgid) -end - -local act_os = dt.configuration.running_os -local PS = act_os == "windows" and "\\" or "/" - ---Detect OS and modify accordingly-- -local proper_install = true -if act_os ~= "macos" and act_os ~= "windows" and act_os ~= "linux" then - proper_install = false - dt.print_error(_('OpenInExplorer plug-in only supports Windows and Linux at this time')) - return -end - ---The commands to open the OSes' file managers -local fmng_cmd = {} -fmng_cmd.linux = [[busctl --user call org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1 ShowItems ass 1 ]] -fmng_cmd.macos = 'open -R ' -fmng_cmd.windows = 'explorer.exe /select, ' - ---The working function that opens the file manager with the image file name selected. -local function open_in_fmanager(os, fmcmd) - local images = dt.gui.selection() - local curr_image = "" - if #images == 0 then - dt.print(_('Please select an image')) - elseif #images <= 15 then - for _,image in pairs(images) do - curr_image = df.sanitize_filename(image.path..PS..image.filename) - local run_cmd = fmcmd..curr_image - if os == 'linux' then run_cmd = run_cmd .. [[ ""]] end - dt.print_log("OpenInExplorer run_cmd = "..run_cmd) - resp = dsys.external_command(run_cmd) - end - else - dt.print(_('Please select fewer images (max 15)')) - end -end - - --- GUI -- -if proper_install then - dt.gui.libs.image.register_action( - _("Show in file explorer"), - function() open_in_fmanager(act_os, fmng_cmd[act_os]) end, - _("Opens File Explorer at the selected image's location") - ) -end From bbfa81f0514d9dac617baced03d84ae8072bfce5 Mon Sep 17 00:00:00 2001 From: preklov <63585095+preklov@users.noreply.github.com> Date: Tue, 14 Apr 2020 15:46:41 +0200 Subject: [PATCH 5/9] Add files via upload --- OpenInExplorer.lua | 98 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 OpenInExplorer.lua diff --git a/OpenInExplorer.lua b/OpenInExplorer.lua new file mode 100644 index 0000000..d9652fa --- /dev/null +++ b/OpenInExplorer.lua @@ -0,0 +1,98 @@ +--[[ +OpenInExplorer plugin for darktable + + copyright (c) 2018 Kevin Ertel + Update 2020: copyright (c) 2020 Volker Lenhardt + + darktable is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + darktable is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with darktable. If not, see . +]] + +--[[About this plugin +This plugin adds the module "OpenInExplorer" to darktable's lighttable view + +----REQUIRED SOFTWARE---- +Apple macOS, Microsoft Windows or Linux with installed Nautilus + +----USAGE---- +Install: (see here for more detail: https://github.com/darktable-org/lua-scripts ) + 1) Copy this file in to your "lua/contrib" folder where all other scripts reside. + 2) Require this file in your luarc file, as with any other dt plug-in + +Select the photo(s) you wish to find in explorer and press "Go to Folder". +A file explorer window will be opened for each selected file at the file's location; the file will be highlighted. + +----KNOWN ISSUES---- +Under macOS the file manager Finder opens only once and selects the file name of the last in DT selected image. +]] + +local dt = require "darktable" +local du = require "lib/dtutils" +local df = require "lib/dtutils.file" +local dsys = require "lib/dtutils.system" +local gettext = dt.gettext + +--Check API version +du.check_min_api_version("5.0.0", "OpenInExplorer") + +gettext.bindtextdomain("OpenInExplorer",dt.configuration.config_dir.."/lua/locale/") + +local function _(msgid) + return gettext.dgettext("OpenInExplorer", msgid) +end + +local act_os = dt.configuration.running_os +local PS = act_os == "windows" and "\\" or "/" + +--Detect OS and modify accordingly-- +local proper_install = true +if act_os ~= "macos" and act_os ~= "windows" and act_os ~= "linux" then + proper_install = false + dt.print_error(_('OpenInExplorer plug-in only supports Windows and Linux at this time')) + return +end + +--The commands to open the OSes' file managers +local fmng_cmd = {} +fmng_cmd.linux = [[busctl --user call org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1 ShowItems ass 1 ]] +fmng_cmd.macos = 'open -R ' +fmng_cmd.windows = 'explorer.exe /select, ' + +--The working function that opens the file manager with the image file name selected. +local function open_in_fmanager(os, fmcmd) + local images = dt.gui.selection() + local curr_image = "" + if #images == 0 then + dt.print(_('Please select an image')) + elseif #images <= 15 then + for _,image in pairs(images) do + curr_image = df.sanitize_filename(image.path..PS..image.filename) + local run_cmd = fmcmd..curr_image + if os == 'linux' then run_cmd = run_cmd .. [[ ""]] end + dt.print_log("OpenInExplorer run_cmd = "..run_cmd) + resp = dsys.external_command(run_cmd) + end + else + dt.print(_('Please select fewer images (max 15)')) + end +end + + +-- GUI -- +if proper_install then + dt.gui.libs.image.register_action( + _("Show in file explorer"), + function() open_in_fmanager(act_os, fmng_cmd[act_os]) end, + _("Opens File Explorer at the selected image's location") + ) +end From ec0fe0b04751f8b55b530e179121559f4a32091e Mon Sep 17 00:00:00 2001 From: preklov <63585095+preklov@users.noreply.github.com> Date: Tue, 14 Apr 2020 16:15:45 +0200 Subject: [PATCH 6/9] Rename OpenInExplorer.lua to contrib/OpenInExplorer.lua --- OpenInExplorer.lua => contrib/OpenInExplorer.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename OpenInExplorer.lua => contrib/OpenInExplorer.lua (100%) diff --git a/OpenInExplorer.lua b/contrib/OpenInExplorer.lua similarity index 100% rename from OpenInExplorer.lua rename to contrib/OpenInExplorer.lua From 91ab85c82503dfa0a20a0ef10307815b09a59faa Mon Sep 17 00:00:00 2001 From: preklov <63585095+preklov@users.noreply.github.com> Date: Thu, 16 Apr 2020 14:07:41 +0200 Subject: [PATCH 7/9] Update OpenInExplorer.lua --- contrib/OpenInExplorer.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua index d9652fa..2766fb2 100644 --- a/contrib/OpenInExplorer.lua +++ b/contrib/OpenInExplorer.lua @@ -54,11 +54,11 @@ end local act_os = dt.configuration.running_os local PS = act_os == "windows" and "\\" or "/" ---Detect OS and modify accordingly-- +--Detect OS and quit if not one of macOS, Windows or Linux-- local proper_install = true if act_os ~= "macos" and act_os ~= "windows" and act_os ~= "linux" then proper_install = false - dt.print_error(_('OpenInExplorer plug-in only supports Windows and Linux at this time')) + dt.print_error(_('OpenInExplorer plug-in only supports macOS, Windows and Linux at this time')) return end @@ -72,13 +72,17 @@ fmng_cmd.windows = 'explorer.exe /select, ' local function open_in_fmanager(os, fmcmd) local images = dt.gui.selection() local curr_image = "" + local run_cmd = "" if #images == 0 then dt.print(_('Please select an image')) elseif #images <= 15 then - for _,image in pairs(images) do - curr_image = df.sanitize_filename(image.path..PS..image.filename) - local run_cmd = fmcmd..curr_image - if os == 'linux' then run_cmd = run_cmd .. [[ ""]] end + for _,image in pairs(images) do + curr_image = image.path..PS..image.filename + if os == 'linux' then + run_cmd = fmcmd .. df.sanitize_filename("file://"..curr_image) .. [[ ""]] + else + run_cmd = fmcmd .. df.sanitize_filename(curr_image) + end dt.print_log("OpenInExplorer run_cmd = "..run_cmd) resp = dsys.external_command(run_cmd) end @@ -91,7 +95,7 @@ end -- GUI -- if proper_install then dt.gui.libs.image.register_action( - _("Show in file explorer"), + _("show in file explorer"), function() open_in_fmanager(act_os, fmng_cmd[act_os]) end, _("Opens File Explorer at the selected image's location") ) From 90880ff4d19c99f43f9b479818cf267850a1c29c Mon Sep 17 00:00:00 2001 From: preklov <63585095+preklov@users.noreply.github.com> Date: Mon, 20 Apr 2020 16:03:25 +0200 Subject: [PATCH 8/9] Delete OpenInExplorer.lua --- contrib/OpenInExplorer.lua | 102 ------------------------------------- 1 file changed, 102 deletions(-) delete mode 100644 contrib/OpenInExplorer.lua diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua deleted file mode 100644 index 2766fb2..0000000 --- a/contrib/OpenInExplorer.lua +++ /dev/null @@ -1,102 +0,0 @@ ---[[ -OpenInExplorer plugin for darktable - - copyright (c) 2018 Kevin Ertel - Update 2020: copyright (c) 2020 Volker Lenhardt - - darktable is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - darktable is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with darktable. If not, see . -]] - ---[[About this plugin -This plugin adds the module "OpenInExplorer" to darktable's lighttable view - -----REQUIRED SOFTWARE---- -Apple macOS, Microsoft Windows or Linux with installed Nautilus - -----USAGE---- -Install: (see here for more detail: https://github.com/darktable-org/lua-scripts ) - 1) Copy this file in to your "lua/contrib" folder where all other scripts reside. - 2) Require this file in your luarc file, as with any other dt plug-in - -Select the photo(s) you wish to find in explorer and press "Go to Folder". -A file explorer window will be opened for each selected file at the file's location; the file will be highlighted. - -----KNOWN ISSUES---- -Under macOS the file manager Finder opens only once and selects the file name of the last in DT selected image. -]] - -local dt = require "darktable" -local du = require "lib/dtutils" -local df = require "lib/dtutils.file" -local dsys = require "lib/dtutils.system" -local gettext = dt.gettext - ---Check API version -du.check_min_api_version("5.0.0", "OpenInExplorer") - -gettext.bindtextdomain("OpenInExplorer",dt.configuration.config_dir.."/lua/locale/") - -local function _(msgid) - return gettext.dgettext("OpenInExplorer", msgid) -end - -local act_os = dt.configuration.running_os -local PS = act_os == "windows" and "\\" or "/" - ---Detect OS and quit if not one of macOS, Windows or Linux-- -local proper_install = true -if act_os ~= "macos" and act_os ~= "windows" and act_os ~= "linux" then - proper_install = false - dt.print_error(_('OpenInExplorer plug-in only supports macOS, Windows and Linux at this time')) - return -end - ---The commands to open the OSes' file managers -local fmng_cmd = {} -fmng_cmd.linux = [[busctl --user call org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1 ShowItems ass 1 ]] -fmng_cmd.macos = 'open -R ' -fmng_cmd.windows = 'explorer.exe /select, ' - ---The working function that opens the file manager with the image file name selected. -local function open_in_fmanager(os, fmcmd) - local images = dt.gui.selection() - local curr_image = "" - local run_cmd = "" - if #images == 0 then - dt.print(_('Please select an image')) - elseif #images <= 15 then - for _,image in pairs(images) do - curr_image = image.path..PS..image.filename - if os == 'linux' then - run_cmd = fmcmd .. df.sanitize_filename("file://"..curr_image) .. [[ ""]] - else - run_cmd = fmcmd .. df.sanitize_filename(curr_image) - end - dt.print_log("OpenInExplorer run_cmd = "..run_cmd) - resp = dsys.external_command(run_cmd) - end - else - dt.print(_('Please select fewer images (max 15)')) - end -end - - --- GUI -- -if proper_install then - dt.gui.libs.image.register_action( - _("show in file explorer"), - function() open_in_fmanager(act_os, fmng_cmd[act_os]) end, - _("Opens File Explorer at the selected image's location") - ) -end From b8d29ca831ebda328e16e0de575346aaa582ac92 Mon Sep 17 00:00:00 2001 From: preklov <63585095+preklov@users.noreply.github.com> Date: Mon, 20 Apr 2020 16:06:38 +0200 Subject: [PATCH 9/9] Add files via upload The new and I hope the finished version for now. --- contrib/OpenInExplorer.lua | 111 +++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 contrib/OpenInExplorer.lua diff --git a/contrib/OpenInExplorer.lua b/contrib/OpenInExplorer.lua new file mode 100644 index 0000000..d456911 --- /dev/null +++ b/contrib/OpenInExplorer.lua @@ -0,0 +1,111 @@ +--[[ +OpenInExplorer plugin for darktable + + copyright (c) 2018 Kevin Ertel + Update 2020 and macOS support by Volker Lenhardt + Linux support 2020 by Bill Ferguson + + darktable is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + darktable is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with darktable. If not, see . +]] + +--[[About this plugin +This plugin adds the module "OpenInExplorer" to darktable's lighttable view. + +----REQUIRED SOFTWARE---- +Apple macOS, Microsoft Windows or Linux + +----USAGE---- +Install: (see here for more detail: https://github.com/darktable-org/lua-scripts ) + 1) Copy this file into your "lua/contrib" folder where all other scripts reside. + 2) Require this file in your luarc file, as with any other dt plug-in + +Select the photo(s) you wish to find in your operating system's file manager and press "show in file explorer" in the "selected images" section. + +- Nautilus (Linux), Explorer (Windows), and Finder (macOS before Catalina) will open one window for each selected image at the file's location. The file name will be highlighted. + +- On macOS Catalina the Finder will open one window for each different directory. In these windows only the last one of the corresponding files will be highlighted (bug or feature?). + +- Dolphin (Linux) will open one window with tabs for the different directories. All the selected images' file names are highlighted in their respective directories. + +----KNOWN ISSUES---- +]] + +local dt = require "darktable" +local du = require "lib/dtutils" +local df = require "lib/dtutils.file" +local dsys = require "lib/dtutils.system" +local gettext = dt.gettext + +--Check API version +du.check_min_api_version("5.0.0", "OpenInExplorer") + +gettext.bindtextdomain("OpenInExplorer",dt.configuration.config_dir.."/lua/locale/") + +local function _(msgid) + return gettext.dgettext("OpenInExplorer", msgid) +end + +local act_os = dt.configuration.running_os +local PS = act_os == "windows" and "\\" or "/" + +--Detect OS and quit if it is not supported-- +local proper_install = true +if act_os ~= "macos" and act_os ~= "windows" and act_os ~= "linux" then + proper_install = false + dt.print_error(_('OpenInExplorer plug-in only supports Linux, macOS, and Windows at this time')) + return +end + +--Format strings for the commands to open the corresponding OS' file manager +local fmng_cmd = {} +fmng_cmd.linux = [[busctl --user call org.freedesktop.FileManager1 /org/freedesktop/FileManager1 org.freedesktop.FileManager1 ShowItems ass %d %s""]] +fmng_cmd.macos = 'open -Rn %s' +fmng_cmd.windows = 'explorer.exe /select, %s' + +--The working function that opens the file manager windows with the selected image file names highlighted. +local function open_in_fmanager(op_sys, fmcmd) + local images = dt.gui.selection() + local curr_image, run_cmd, file_uris = '', '', '' + if #images == 0 then + dt.print(_('Please select an image')) + elseif #images <= 15 then + for _,image in pairs(images) do + curr_image = image.path..PS..image.filename + if op_sys == 'linux' then + file_uris = file_uris .. df.sanitize_filename("file://" .. curr_image) .. " " + dt.print_log("file_uris is " .. file_uris) + else + run_cmd = string.format(fmcmd, df.sanitize_filename(curr_image)) + dt.print_log("OpenInExplorer run_cmd = "..run_cmd) + dsys.external_command(run_cmd) + end + end + if op_sys == 'linux' then + run_cmd = string.format(fmcmd, #images, file_uris) + dt.print_log("OpenInExplorer run_cmd = "..run_cmd) + dsys.external_command(run_cmd) + end + else + dt.print(_('Please select fewer images (max 15)')) + end +end + +-- GUI -- +if proper_install then + dt.gui.libs.image.register_action( + _("show in file explorer"), + function() open_in_fmanager(act_os, fmng_cmd[act_os]) end, + _("Opens the file manager at the selected image's location") + ) +end