Ignore directories in tracker-miner-fs - Ubuntu

avatar

Borislav Hadzhiev

Mon Feb 08 20211 min read

banner

Photo by Daan Stevens

The problem #

I'm on Ubuntu 20.04 and I have a pretty good CPU - Intel Core i7-9750H with 6 cores, however most of the time I start installing node_modules or the equivalent in other programming languages my CPU usage goes very high and my laptop gets very loud.

The reason is Ubuntu comes preinstalled with tracker-miner-fs - a search engine and a database. It indexes content from your home directory automatically, so applications can provide instant search results.

Tracker miner by default looks at files in the Documents, Music, Pictures, Videos, your Home Directory ~ and Downloads directories.

You can control Tracker Mines FS's configuration using gsettings. The relevant schema is org.freedesktop.Tracker.Miner.Files.

To tell Tracker Miner FS to ignore a directory and all its contents, you can create an empty file named .nomedia inside the directory. However I don't want to have to remember to always include a .nomedia file in my projects, so the solution is to globally ignore node_modules and venv directories.

The solution #

To see the directories ignored by default type into your terminal:

gsettings get org.freedesktop.Tracker.Miner.Files ignored-directories

The output will be something like: ['po', 'CVS', 'core-dumps', 'lost+found']

Now add node_modules and venv and restart tracker:

gsettings set org.freedesktop.Tracker.Miner.Files ignored-directories "['po', 'CVS', 'core-dumps', 'lost+found', 'node_modules', 'venv']" tracker reset -r

This way tracker miner will not try to index the hundreds of thousands of files in your env directories and burden your CPU.

Add me on LinkedIn

I'm a Web Developer with TypeScript, React.js, Node.js and AWS experience.

Let's connect on LinkedIn

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee