Ignore directories in tracker-miner-fs - Ubuntu

avatar

Borislav Hadzhiev

Last updated: Feb 8, 2021

banner

Check out my new book

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.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.