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,47 +36,78 @@ 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
46
- proper_install = true
49
+ if dt .configuration .running_os ~= " macos " then
50
+ proper_install = true
47
51
else
48
- dt .print_error (' OpenInExplorer plug-in only supports Windows OS at this time' )
49
- return
52
+ dt .print_error (' OpenInExplorer plug-in only supports Windows and Linux at this time' )
53
+ return
54
+ end
55
+
56
+
57
+ -- FUNCTIONS --
58
+
59
+ local function open_in_explorer () -- Open in Explorer
60
+ local images = dt .gui .selection ()
61
+ local curr_image = " "
62
+ if # images == 0 then
63
+ dt .print (' please select an image' )
64
+ elseif # images <= 15 then
65
+ for _ ,image in pairs (images ) do
66
+ curr_image = image .path .. PS .. image .filename
67
+ local run_cmd = " explorer.exe /select, " .. curr_image
68
+ dt .print_log (" OpenInExplorer run_cmd = " .. run_cmd )
69
+ resp = dsys .external_command (run_cmd )
70
+ end
71
+ else
72
+ dt .print (' please select fewer images (max 15)' )
73
+ end
74
+ end
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
50
91
end
51
92
52
- -- FUNCTION --
53
- local function OpenInExplorer () -- Open in Explorer
54
- -- Inits--
55
- if not proper_install then
56
- return
57
- end
58
- local images = dt .gui .selection ()
59
- local curr_image = " "
60
- if # images == 0 then
61
- dt .print (' please select an image' )
62
- elseif # images <= 15 then
63
- for _ ,image in pairs (images ) do
64
- curr_image = image .path .. ' \\ ' .. image .filename
65
- local run_cmd = " explorer.exe /select, " .. curr_image
66
- dt .print_log (" OpenInExplorer run_cmd = " .. run_cmd )
67
- resp = dsys .external_command (run_cmd )
68
- end
69
- else
70
- dt .print (' please select fewer images (max 15)' )
71
- end
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
72
104
end
73
105
74
106
-- GUI --
75
107
if proper_install then
76
- dt .gui .libs .image .register_action (
77
- " show in file explorer" ,
78
- function () OpenInExplorer () end ,
79
- " Opens File Explorer at the selected image's location"
80
- )
108
+ dt .gui .libs .image .register_action (
109
+ " show in file explorer" ,
110
+ function () open_in_filemanager () end ,
111
+ " Opens File Explorer at the selected image's location"
112
+ )
81
113
end
0 commit comments