nautilus-blacklist

Imports the blacklist from `Zeitgeist`_ and uses it to list and remove items matching the list from the *recently used files* in **Nautilus**.


Keywords
cli, dbus-python, gnome, privacy, python, zeitgeist
License
GPL-3.0
Install
pip install nautilus-blacklist

Documentation

Nautilus Blacklist Recent

This package gives you functions to import the blacklist from Zeitgeist and uses it to list and remove items matching the rules listed there from the recently used files in Gnome Nautilus.

Right now it only support blacklisted URIs, not programs or MIME types.

Overview

After installation you got a new command named blacklistrecent. Use blacklistrecent --help for all available subcommands and options.

Commands

  • list list the URIs of all recently used files

  • show list the URIs of the blacklisted recently used files

  • remove remove all blacklisted files from the recently used files list

  • watch keep running and removing blacklisted files

Installation

You can use pip:

pip install --user nautilus-blacklist

Alternatively just download or clone the source and use setup.py to install it manually.

Requirements

The only requirements besides the standard library is dbus-python.

If you install with pip or setup.py, the Python requirements are installed automatically. You can install it manually like this pip install dbus-python, or just run pip install -r requirements.txt from the source directory.

Python 3

As of right now this package unfortunately does not support Python 3, because it only requirement, dbus-python, does not. I guess this will not change, because it seems that the focus moved to the newer and more pythonic pydbus.

So far I couldn't be bothered to switch with this project, because the pydbus documentation is… well there is none. If you want have Python 3 support, feel free to have a look yourself and I will happily accept a pull request for it.

Another problem is, that pydbus requires PyGI, which is still not packaged for pypi yet and you have to install it manually with your package manager:

  • Debian: The package is called python-gi and you need the dev version too, so you have to run: apt-get install python-gi python-gi-dev.

Run it automatically

There are a couple of ways to run this package automatically. The remove subcommand runs just once while the watch subcommand keeps running and polls for changes in the XML file.

Cron

Probably the easiest way is to run the remove sub-command as a cron job, e.g. all 5 minutes like this (use crontab to edit your table):

*/5 * * * * export DISPLAY=:0.0 && /usr/bin/python2 -m blacklistrecent remove > /dev/null 2 > &1

Gnome Autostart

You can start the watch subcommand together with your desktop session, e.g. with Gnome and gnome-session-properties or similar. Just call the script like this to clean the recent files all 5 minutes (300 seconds):

/usr/bin/python2 -m blacklistrecent watch -i 300 &

systemd

If you use systemd as your init system, you have a couple of nice options… but first you need a service definition — the important part is Type=simple (take a look at the man pages for more informations):

# /etc/systemd/system/blacklistrecent.service
[Unit]
Description=Remove blacklisted files from the list of recently used files.

[Service]
Type=simple
ExecStart=/usr/bin/python2 -m blacklistrecent remove

Timer

If you create a timer unit, you can run your service automatically:

# /etc/systemd/system/blacklistrecent.timer
[Unit]
Description=Runs blacklistrecent every 5 minutes.

[Timer]
# time to wait after booting before first run
OnBootSec=5m
# time between runs
OnUnitActiveSec=5m
Unit=blacklistrecent.service

[Install]
WantedBy=multi-user.target

To start the timer use systemctl start blacklistrecent.timer. If you want to start it automatically at each boot, use systemctl enable blacklistrecent.timer.

On change

If you create a path unit, you can run your service automatically every time the file changes — this is my favorite option (note that you have to supply a username):

# /etc/systemd/system/blacklistrecent.path
[Unit]
Description=Run blacklistrecent if the recent files change for user <username>.

[Path]
PathModified=/home/<username>/.local/share/recently-used.xbel
Unit=blacklistrecent.service

[Install]
WantedBy=multi-user.target

Starting or enabling works the same as for the timer example.

If both units (the service and the timer or path) have the same name - like in the examples above - you can skip the Unit=blacklistrecent.service definition.

Source, Bugs, Issues…

You can find this project on GitHub: https://github.com/brutus/nautilus-blacklist

Along wit an issue tracker for bugs, requests and other feedback.