1
- --[[ OpenInExplorer plugin for darktable
1
+ --[[
2
+ OpenInExplorer plugin for darktable
2
3
3
4
copyright (c) 2018 Kevin Ertel
4
5
20
21
This plugin adds the module "OpenInExplorer" to darktable's lighttable view
21
22
22
23
----REQUIRED SOFTWARE----
23
- Microsoft Windows Operating System
24
+ Microsoft Windows or Linux with installed Nautilus
24
25
25
26
----USAGE----
26
27
Install: (see here for more detail: https://github.com/darktable-org/lua-scripts )
@@ -35,33 +36,34 @@ A file explorer window will be opened for each selected file at the file's locat
35
36
36
37
local dt = require " darktable"
37
38
local du = require " lib/dtutils"
39
+ local df = require " lib/dtutils.file"
38
40
local dsys = require " lib/dtutils.system"
39
41
40
42
-- Check API version
41
43
du .check_min_api_version (" 5.0.0" , " OpenInExplorer" )
42
44
45
+ local PS = dt .configuration .running_os == " windows" and " \\ " or " /"
46
+
43
47
-- Detect OS and modify accordingly--
44
48
local proper_install = false
45
- if dt .configuration .running_os == " windows " then
49
+ if dt .configuration .running_os ~= " macos " then
46
50
proper_install = true
47
51
else
48
- dt .print_error (' OpenInExplorer plug-in only supports Windows OS at this time' )
52
+ dt .print_error (' OpenInExplorer plug-in only supports Windows and Linux at this time' )
49
53
return
50
54
end
51
55
52
- -- FUNCTION --
53
- local function OpenInExplorer () -- Open in Explorer
54
- -- Inits--
55
- if not proper_install then
56
- return
57
- end
56
+
57
+ -- FUNCTIONS --
58
+
59
+ local function open_in_explorer () -- Open in Explorer
58
60
local images = dt .gui .selection ()
59
61
local curr_image = " "
60
62
if # images == 0 then
61
63
dt .print (' please select an image' )
62
64
elseif # images <= 15 then
63
65
for _ ,image in pairs (images ) do
64
- curr_image = image .path .. ' \\ ' .. image .filename
66
+ curr_image = image .path .. PS .. image .filename
65
67
local run_cmd = " explorer.exe /select, " .. curr_image
66
68
dt .print_log (" OpenInExplorer run_cmd = " .. run_cmd )
67
69
resp = dsys .external_command (run_cmd )
@@ -71,11 +73,41 @@ local function OpenInExplorer() --Open in Explorer
71
73
end
72
74
end
73
75
76
+ local function open_in_nautilus () -- Open in Nautilus
77
+ local images = dt .gui .selection ()
78
+ local curr_image = " "
79
+ if # images == 0 then
80
+ dt .print (' please select an image' )
81
+ elseif # images <= 15 then
82
+ for _ ,image in pairs (images ) do
83
+ curr_image = image .path .. PS .. image .filename
84
+ local run_cmd = " nautilus --select " .. df .sanitize_filename (curr_image )
85
+ dt .print_log (" OpenInExplorer run_cmd = " .. run_cmd )
86
+ resp = dsys .external_command (run_cmd )
87
+ end
88
+ else
89
+ dt .print (' please select fewer images (max 15)' )
90
+ end
91
+ end
92
+
93
+ local function open_in_filemanager () -- Open
94
+ -- Inits--
95
+ if not proper_install then
96
+ return
97
+ end
98
+
99
+ if (dt .configuration .running_os == " windows" ) then
100
+ open_in_explorer ()
101
+ elseif (dt .configuration .running_os == " linux" ) then
102
+ open_in_nautilus ()
103
+ end
104
+ end
105
+
74
106
-- GUI --
75
107
if proper_install then
76
108
dt .gui .libs .image .register_action (
77
109
" show in file explorer" ,
78
- function () OpenInExplorer () end ,
110
+ function () open_in_filemanager () end ,
79
111
" Opens File Explorer at the selected image's location"
80
112
)
81
113
end
0 commit comments