0

I often find myself looking for PDF documents. Luckily, I found pdfgrep that really does a great job at finding PDF documents by content.

Following command lets me search for documents that have my search word on the first page

pdfgrep -irl --page-range=1 2>/dev/null 'mysearchword'

Is it possible to integrate this command into the Nemo file manager search?

1

1 Answer 1

0

Yes!

https://github.com/linuxmint/nemo/tree/master/search-helpers explains how:

  1. Write a script or program that takes a file name and outputs the plain text of that file
  2. make that script executable
  3. Write a search helper definition file and put it into ~/.local/share/nemo/search-helpers.

Luckily, the first part has already been done by the PDF library that pdfgrep uses internally: There's a pdftotext utility.

So what you'd need to do is install pdftotext (sudo apt install poppler-utils), and write a application-pdf.nemo_search_helper:

[Nemo Search Helper]
TryExec=pdftotext
Exec=pdftotext %s
MimeType=application/pdf;
Priority=100

and put it in application-pdf.nemo_search_helper.


Fun fact:

that's already implemented in nemo 5, there's a pdftotext search helper, so you don't have to do anything. Just install poppler-utils, and you should get that search when hitting ctrl+f in nemo.

Not so fun fact: Ubuntu 21.10 is surprisingly conservative

... in the version of Nemo it ships: you need nemo 5, but it ships nemo 4.

You can build the official nemo source into a Ubuntu package and install it, but no guarantees are made. This might break things on your system, I haven't tested the functionality!

Now, you can build nemo from source:

sudo apt install git-buildpackage
git clone https://github.com/linuxmint/nemo
cd nemo
dpkg-buildpackage -rfakeroot

which will complain about missing packages:

dpkg-checkbuilddeps: error: Unmet build dependencies: cinnamon-l10n debhelper-compat (= 12) dh-python gobject-introspection gtk-doc-tools (>= 1.4) intltool (>= 0.40.1) itstool libatk1.0-dev (>= 1.32.0) libcinnamon-desktop-dev (>= 4.8) libexempi-dev (>= 2.2.0) libexif-dev (>= 0.6.20) libgail-3-dev libgirepository1.0-dev (>= 0.9.12) libglib2.0-dev (>= 2.45.7) libglib2.0-doc libgsf-1-dev libgtk-3-dev (>= 3.10) libgtk-3-doc libnotify-dev (>= 0.7.0) libpango1.0-dev libx11-dev libxapp-dev (>= 2.0.0) libxext-dev libxml2-dev (>= 2.7.8) libxrender-dev meson python3-gi x11proto-core-dev

Simply install these (the list might look different to you!) using

sudo apt install cinnamon-l10n debhelper-compat  dh-python gobject-introspection gtk-doc-tools  intltool itstool libatk1.0-dev  libcinnamon-desktop-dev  libexempi-dev  libexif-dev libgail-3-dev libgirepository1.0-dev libglib2.0-dev libglib2.0-doc libgsf-1-dev libgtk-3-dev libgtk-3-doc libnotify-dev libpango1.0-dev libx11-dev libxapp-dev libxext-dev libxml2-dev  libxrender-dev meson python3-gi x11proto-core-dev

then try again:

dpkg-buildpackage -rfakeroot

Which should now work flawlessly. (it does for my fresh Ubuntu 21.10 container). You can now install:

cd ..
sudo dpkg -i gir*.deb libnemo*.deb nemo-data*.deb nemo_*.deb
# there will be config errors of the above; run apt-get install to fix these:
sudo apt-get install -f

There you go, you'll have a bleeding edge nemo installation now.

3
  • After some digging around I found out that I am using Nemo 4.8.6 which apparently doesn't support search helpers. Is it possible for me to upgrade to Nemo 5.1 with Ubuntu 21.10? Sorry for these questions im rather new to linux Commented Dec 8, 2021 at 14:27
  • @CharlesDavidMupende addressed that in my question. Don't know whether you really would want to do that – it replaces an important part of your desktop environment, and I haven't tested whether it works. Commented Dec 8, 2021 at 14:55
  • This worked! Coming from windows, it still amazes me how much more flexible one is in the Linux world. Thank you! Commented Dec 8, 2021 at 15:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.