Skip to content

Commit d6e8444

Browse files
committed
search: Add a readme for search helpers, move third-party helpers
into the search-helpers directory, clean up search logging a bit.
1 parent 61a3f4e commit d6e8444

10 files changed

+62
-4
lines changed

libnemo-private/nemo-search-engine-advanced.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ get_cat_helper_directories (void)
122122
}
123123

124124
helper_dirs = g_list_prepend (helper_dirs, path);
125+
helper_dirs = g_list_reverse (helper_dirs);
125126

126127
return helper_dirs;
127128
}
@@ -160,7 +161,7 @@ process_search_helper_file (const gchar *path)
160161
try_exec = g_key_file_get_string (key_file, SEARCH_HELPER_GROUP, "TryExec", NULL);
161162
abs_try_path = g_find_program_in_path (try_exec);
162163
if (!abs_try_path) {
163-
g_message ("Skipping search helper '%s' - program is not available (%s)", path, try_exec);
164+
DEBUG ("Skipping search helper '%s' - program is not available (%s)", path, try_exec);
164165
goto done;
165166
}
166167

@@ -198,10 +199,10 @@ process_search_helper_file (const gchar *path)
198199

199200
existing = g_hash_table_lookup (search_helpers, mime_type);
200201
if (existing && existing->priority > priority) {
201-
g_message ("Existing nemo search_helper for '%s' has higher priority than a new one (%s), ignoring the new one.", mime_type, path);
202+
DEBUG ("Existing nemo search_helper for '%s' has higher priority than a new one (%s), ignoring the new one.", mime_type, path);
202203
continue;
203204
} else if (existing) {
204-
g_message ("Replacing existing nemo search_helper for '%s' with %s based on priority.", mime_type, path);
205+
DEBUG ("Replacing existing nemo search_helper for '%s' with %s based on priority.", mime_type, path);
205206
}
206207

207208
helper = g_slice_new0 (SearchHelper);
@@ -239,6 +240,8 @@ initialize_search_helpers (NemoSearchEngineAdvanced *engine)
239240
const gchar *path;
240241

241242
path = (const gchar *) d_iter->data;
243+
DEBUG ("Checking location '%s' for search helpers", path);
244+
242245
error = NULL;
243246

244247
dir = g_dir_open (path, 0, &error);
@@ -256,6 +259,7 @@ initialize_search_helpers (NemoSearchEngineAdvanced *engine)
256259
}
257260

258261
file_path = g_build_filename (path, filename, NULL);
262+
DEBUG ("Processing '%s'", path);
259263
process_search_helper_file (file_path);
260264
g_free (file_path);
261265
}

search-helpers/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
### Search Helpers
2+
3+
Nemo's file and content search utilizes a plugin-type system to allow content search for additional file types.
4+
5+
The only requirements for a helper is the ability to extract text from a given file type and print it to stdout. A definition file provides details necessary to use the helper.
6+
7+
##### Example definition file:
8+
9+
```
10+
[Nemo Search Cat Helper]
11+
TryExec=pdftotext
12+
Exec=pdftotext %s -
13+
MimeType=application/pdf;
14+
Priority=200
15+
16+
```
17+
The `Nemo Search Cat Helper` group name is mandatory.
18+
19+
- The filename must end in `.nemo_search_helper`.
20+
- `TryExec` should be set to the name of the executable (without any arguments). When the helpers are loaded, Nemo will
21+
check that the program a) exists and b) is executable. If these checks fail, the helper will be skipped. If only a
22+
program name is provided, it must exist in the user's path. This can also be an absolute path.
23+
- `Exec` should provide the full command line necessary to extract the text from the file. The `%s` argument will be replaced by
24+
the file name being processed during content search. Note, uris are not supported, only paths (local files).
25+
- `MimeType`is a semicolon (`;`)-separated list of mimetypes that this search helper should be used with. It must be
26+
semicolon-terminated (even if there's only a single item).
27+
- `Priority` is a value used to break a tie when multiple helpers support the same mimetype. The higher value wins. In the
28+
event of a tie, the last helper processed is used (the order is currently undefined). If the `Priority` entry is missing,
29+
the value is assumed to be 100.
30+
- The `TryExec`, `Exec` and `MimeType` keys are mandatory.
31+
32+
These definition files can be placed in `<datadir>/nemo/search-helpers` where `<datadir>` can be some directory in XDG_DATA_DIRS or under the user's data directory (`~/.local/share/namo/search-helpers`). The user directory is processed last, and takes precedence over the system dirs.
33+
34+
##### Debugging:
35+
If something doesn't seem to be working, you can run nemo with debugging enabled:
36+
```
37+
NEMO_DEBUG=Search nemo --debug
38+
```
39+
This will print out a bit of extra information related to searches.

search-helpers/meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
libgsf = dependency('libgsf-1', required: true)
32

43
mso_to_txt_sources = [
@@ -15,3 +14,5 @@ install_data(
1514
'mso.nemo_search_helper',
1615
install_dir: join_paths(nemoDataPath, 'search-helpers')
1716
)
17+
18+
subdir('third-party')
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
helpers = [
2+
'exif.nemo_search_helper',
3+
'id3.nemo_search_helper',
4+
'libreoffice.nemo_search_helper',
5+
'pdf2txt.nemo_search_helper',
6+
'pdftotext.nemo_search_helper',
7+
'ps2ascii.nemo_search_helper'
8+
]
9+
10+
install_data(
11+
helpers,
12+
install_dir: join_paths(nemoDataPath, 'search-helpers')
13+
)
14+

0 commit comments

Comments
 (0)