Strict Pomodoro is a powerful daemon for Linux that enforces a distraction-free work environment by blocking websites during Pomodoro sessions. It integrates directly with GNOME Pomodoro via D-Bus to automatically block sites when you start working and unblock them when you're on a break.
Strict Pomodoro uses a secure, modular approach to manage focus time:
- Daemon (
daemon.sh): A systemd user service runs in the background, monitoring GNOME Pomodoro's state via D-Bus. - State Change: When the daemon detects a state change (e.g., from
breaktopomodoro), it triggers the appropriate action. - Hosts Manager (
hosts-manager):- Block: During a
pomodorostate, the daemon invokes thehosts-managerscript withsudoto add entries for each site in your blocklist to/etc/hosts, redirecting them to127.0.0.1. - Unblock: During
short-break,long-break, or idle states, it removes only the lines it added, leaving the rest of/etc/hostsuntouched.
- Block: During a
- Tab Closing (Optional): If enabled, the daemon will also close any open browser tabs that match the sites in your blocklist.
This design ensures that /etc/hosts is modified in a safe and controlled manner, without giving the main daemon script broad root permissions.
- 🔒 Secure Host File Management: Uses a dedicated, restricted script (
hosts-manager) to safely block and unblock sites. - 🛡️ Restricted Permissions: The installer configures a
sudoersrule to grant passwordless execution only for the specifichosts-managerscript, preventing escalation. - 📡 Real-time Monitoring: Instantly reacts to GNOME Pomodoro state changes using D-Bus signals.
- 탭 Closes Distracting Tabs: Prevents you from getting sidetracked by already-open sites (requires browser setup).
- 📝 Simple Blocklist: Customize your list of blocked sites in a plain text file.
- ⚙️ Systemd Integration: Runs as a reliable systemd user service.
- 🚀 Automated Installer: Quick setup and configuration with a single command.
The installer will attempt to install these for you, but you can install them manually:
gnome-shell-pomodorodbus(usually pre-installed)jq(for the optional tab-closing feature)
git clone https://github.com/akunbeben/strict-pomodoro.git
cd strict-pomodorochmod +x install.sh
./install.shThe installer automates the following steps:
- Installs Dependencies: Ensures
gnome-shell-pomodoroanddbusare installed. - Copies Scripts:
daemon.shis copied to~/.local/bin/strict-pomodoro.sh.hosts-manageris securely copied to/usr/local/bin/strict-pomodoro-hosts-managerwithrootownership.
- Sets Up Blocklist: A default
blocklist.txtis placed in~/.local/share/strict-pomodoro/. - Configures Sudoers: A file is created at
/etc/sudoers.d/strict-pomodoroto allow the daemon to run thehosts-managerscript without a password. - Deploys Service: The systemd user service file is copied to
~/.config/systemd/user/. - Starts Service: The systemd user daemon is reloaded, and the
strict-pomodoroservice is enabled and started.
Modifying /etc/hosts requires root privileges. To avoid running the entire daemon as root, Strict Pomodoro uses a more secure model:
- A minimal script,
hosts-manager, is placed in/usr/local/binand owned byroot. Its sole purpose is to add or remove specific lines from/etc/hosts. - The installer adds a rule to
/etc/sudoers.d/. This rule allows your user to execute only thehosts-managerscript withsudowithout being prompted for a password. - The main
daemon.shscript, which runs with user privileges, can then callsudo strict-pomodoro-hosts-managerto safely perform the block/unblock actions.
This isolates the root-level operations, ensuring the daemon cannot perform any unauthorized actions.
The list of blocked websites is stored at:
~/.local/share/strict-pomodoro/blocklist.txt
You can add or remove any domain.
Example:
www.facebook.com
youtube.com
twitter.com
instagram.com
After editing the file, restart the service to apply changes:
systemctl --user restart strict-pomodoro.serviceThe automatic tab-closing feature uses the Chrome DevTools Protocol and requires a Chromium-based browser (Google Chrome, Chromium, Brave, etc.).
Requirements:
jqcommand-line JSON processor must be installed (sudo apt install jq).- Your browser must be launched with remote debugging enabled.
How to Enable Remote Debugging:
Launch your browser from the terminal with the remote debugging flag.
# For Google Chrome
google-chrome --remote-debugging-port=9222 &
# For Chromium
chromium-browser --remote-debugging-port=9222 &To make this permanent, edit your browser's .desktop file (e.g., in /usr/share/applications/) and add the --remote-debugging-port=9222 flag to the Exec line.
-
Check Status:
systemctl --user status strict-pomodoro.service
-
View Live Logs:
journalctl --user -u strict-pomodoro.service -f
-
Start GNOME Pomodoro (Headless):
gnome-pomodoro --no-default-window
To completely remove Strict Pomodoro and all its components:
./install.sh --uninstallThis will stop the service, remove all installed files (including the scripts, blocklist, service file, and sudoers rule), and restore your system to its previous state.