SailfishOS:Chum icon

SailfishOS:Chum

A Sailfish OS software repository by the community

App icon of Hosts-block

Hosts-block

Hosts-based adblock script

v0.1.1

Ad-blocking via /etc/hosts

Primer

After installation the script runs immediately, and then updates every week (configurable).

By default medium protection is used, provided by one of firebog's meta lists, checked against false positives.

You can add as many sources as you want - they'll be combined and de-duplicated to create the ultimate ad-blocking hosts file.

3 formats are supported, all are URLs to

Each variable can contain several URLs, separated by newlines.

If you want stricter or less strict blocking, copy /usr/share/doc/hosts-block/cfg.sh to /home/defaultuser/.config/hosts-block/ and edit it to your liking. The file is sourced by the ash shell script, i.e. it follows shell syntax.

When the edited config file is saved a forced run is triggered automatically.

You can force-regenerate the hosts file manually with devel-su systemctl start hosts-block-forced.service or devel-su hosts-block forced.

The script sends various graphical notifications when something important happens (good or bad).

"Modifications to this file normally take effect immediately, except in cases where the file is cached by applications" (source). Since this is the case for the SFOS browser you will be prompted to restart it if required.

White-/Blacklisting

You can whitelist sites by creating /home/defaultuser/.config/hosts-block/whitelist.txt - the format is much like hosts itself but without the numerical IP address, so just the [sub.]domain.tld, one per line.

Same for blacklist.txt/blacklisting.

Both can also be achieved via two "Open with..." .desktop files that will show up in a context menu for links, but unfortunately not in the browser itself as that would require a Share plugin (TODO).

Both can also be achieved via two "Open with..." .desktop files that will show up in a context menu for links, but unfortunately not in the browser itself as that would require a Share plugin (TODO).

This will not blacklist the specific URL that was tapped, but its full domain. E.g. https://forum.sailfishos.org/t/hosts-block-ad-blocking-via-etc-hosts-now-in-chum/22282 is stripped down to forum.sailfish.org and https://framagit.org/ohnonot/sfos/hosts-block is stripped own to framagit.org

Please keep in mind that some sites redirect to the www. subdomain, which has to be specified explicitely, if so desired. In other words, for such domains you'll probably want 2 lines (TODO: make the script act accordingly when the domain starts with www):

domain.tld
www.domain.tld

There is no way to add wildcards for all subdomains to hosts.

If one of the black/whitelist files is edited (manually or via .desktop entry), an offline (not forced) run is triggered automatically.

Android App Support

Has been added. AFAICS updates to the hosts file don't transfer to Android apps in real time. I'm still investigating, but until then a restart of AAS is desired when hosts is updated.

Before installing the package

There is nothing to do if you haven't customized /etc/hosts. But if you want to use its content as the head of the new hosts file, move/copy it to /etc/hosts.head before installing.

In any case, rpm will archive the existing /etc/hosts as /home/hosts*, on initial installation only.

If /etc/hosts.head does not exist, the script uses a default hosts.head (see repo) that covers both standard SFOS and AAS entries.

Either file becomes the "head" (i.e. the first few lines) of your new hostsfile.

It is, however, not a good idea to put to-be-blocked domains in /etc/hosts.head. Please use the blacklist feature for that (if you think these domains haven't been covered by one of the available blocklists already).

If you uninstall hosts-block /etc/hosts.head (or the repo default) will become your regular hosts file again.

Other apps writing to /etc/hosts?

You should not have other software installed that modifies hosts. System software won't do this anyhow - the file is static by definition (which does not mean that one isn't allowed to modify it).

Nevertheless, upon first installation rpm will archive /etc/hosts to /home/hosts*tar.gz but will not restore it upon uninstallation.


Source
Framagit.org
Notabug.org

Download

The easiest way to download and install this software is by the SailfishOS:Chum GUI app. If you wish to download the RPM file by yourself, please expand the section below.

Download links

Changelog

0.1.1-4 (2026-01-18)

- added check_inst.sh for troubleshooting
- made medium strict blocking the new default

Older changelogs

0.1.1 (2026-01-12)

- rewrote some scripts and functions (de-duplication)
- still trying to fix the logic in watch-config.sh

0.1.0-3 (2026-01-09)

- updated README.md
- added archiving of existing /etc/hosts to .spec file (only on installation)

0.1.0-2 (2026-01-07)

- improved .spec file service starts/restarts

0.1.0-1 (2026-01-07)

- Now using /var/cache for downloads
- added hosts.head as a file with default values
- hosts.head now correctly prepends hosts
- improved .spec file, esp. service starts/restarts

0.0.9-3 (2025-06-30)

- Removed "But there was no change" notification
  (the message is still logged)

0.0.9-1 (2025-06-07)

- watch-config.sh now reacts correctly when *list.txt is removed
  It also now starts the systemd service instead of launching
  the script directly

0.0.8-5 (2025-06-05)

- fixing rpm specs for smooth upgrades

0.0.8-3 (2025-06-04)

- small fixes, version/release bump

0.0.7-0 (2025-03-10)

- another major overhaul to fix enable reload on filechange

0.0.6-0 (2025-03-04)

- major overhaul to enable reload on filechange

0.0.5-0 (2025-02-22)

- added icons and blacklist options
- now in chum:testing

0.0.4-1 (2025-02-15)

- added configuration and whitelist options

0.0.3-1 (2025-02-13)

- Script improvements
- Service & timer improvements
- Rework systemd commands in spec file to make sure the hosts file is updated immediately after installation

0.0.2-1 (2025-01-12)

- Send notification to restart browser after update

0.0.1-2 (2025-01-08)

- Initial rpm packaging

0.0.1 (2023-10-29)

- Development and announcement on forum.sailfishos.org

App information

Package name
hosts-block
Version
0.1.1+master.20260118193835.8e96588-1.3.1.bso
Licence
GPLv3
Developer
Ohnonot
Packager
Ohnonot, Vlad G.
Last updated
2026-01-19 18:30:45

Download size
37.8 KiB
Installed size
40.2 KiB
Checksum (sha256)
a76c49eaf276b2aaf1294a4c6fc6850e7f8ada8a18fc8ecd5788611848a816f4
Download size
62.4 KiB
Installed size
58.0 KiB
Checksum (sha256)
7362f09b19fa1f7e5fc200116d32fcc4155f2e2c7841c7325bef4ace3920f2c4

Links