A content blocker for your entire computer.
Important
This extension depends on hBlock and will NOT WORK if you don't have it installed on your computer. Follow the instructions here to install it.
After installing hBlock, you can install Blocker itself through the GNOME Extensions website.
Caution
Blocker replaces your system's /etc/hosts
file. Consider making a backup of it!
Click the Quick Settings toggle and input your user's password to activate Blocker (it will take a while to download all its denylists). Once Blocker is active, it will display a system indicator of a shield. To turn it off, simply click the toggle and input your password again.
This GNOME Shell extension is just a convenient frontend for hBlock, which does all the heavy lifting. Here's what happens when you toggle Blocker:
First, Blocker uses pkexec (the program that prompts you for your password) to gain super user privilege, which is required to run hBlock. Then, if you enabled Blocker, it enables hBlock by running hblock
. If you disabled Blocker, it disables hBlock by running hblock -S none -D none
. I couldn't resist a flowchart...
flowchart TD
A["Blocker toggled"] --> B["Gain privilege with pkexec"]
B -- Blocker disabled --> C["Execute `hblock -S none -D none`"]
B -- Blocker enabled --> D["Execute `hblock`"]
Blocker is powered by hBlock, so its limitations are Blocker's limitations.
The content blocking strategy used by hBlock is DNS blocking. That means that any connections that do not depend on name resolution cannot be blocked using this approach, such as accessing an IP address directly. Additionally, certain applications may set their own DNS settings (e.g. Firefox, when it uses DNS over HTTPS) instead of adhering to the system's configuration. Finally, your DNS settings may be affected if you are using a VPN, which tipically route your DNS queries to its own resolvers.
Visit https://hblock.molinero.dev, it tells you whether hBlock is active or not. This is does that by checking if connections to https://hblock-check.molinero.dev are blocked, which is the case for hBlock's default configuration.
Blocker does not provide, not plans to provide, that kind of customization. However, you can do that if you hBlock directly in the terminal, using -A
, -D
, and -S
flags. Run hblock --help
for more details.
For false positives, report in hBlock's issue tracker. For everything else, report in Blocker's issue tracker.
To build and install the extension run:
gnome-extensions pack --force --extra-source=icons [email protected] && gnome-extensions install [email protected] --force
You can run a nested session of GNOME Shell to test the extension out with:
dbus-run-session -- gnome-shell --nested --wayland
If you want to change the size of the window of the nested session, set the MUTTER_DEBUG_DUMMY_MODE_SPECS
environment variable (as advised here), like so:
env MUTTER_DEBUG_DUMMY_MODE_SPECS=1024x768 dbus-run-session -- gnome-shell --nested --wayland
- Assign a custom icon to a Quick Settings toggle: based on the codebase from Caffeine.
- Run shell commands asynchronously: heavily inspired by the GJS docs and GSConnect.
- Send customized notifications: reused from Gravatar and Picture of the day extensions.
- Blocker's logo: derived from the
shield-safe-symbolic
icon, by the GNOME Project. - EGO banner: modified from Just Perfection's work.
This project would not exist if it weren't for hBlock, so I thank its maintainer and all its contributors. I'm also grateful to everyone in the GNOME Extensions matrix room, who kindly answered the many questions that came up while I was writing this program.
This project is licensed under the terms of the GPLv3.