Skip to content
/ dsfree Public

Daemon de productivité en Go. Aide à lutter contre le doomscrolling en bloquant l'accès aux sites de distraction via /etc/hosts.

License

Notifications You must be signed in to change notification settings

serisow/dsfree

Repository files navigation

DSFree

A simple system service for Linux to block distracting websites.

This tool helps you stay focused by making it intentionally difficult to access distracting sites.

Philosophy

The goal is to create friction. By making it hard to get distracted, this tool turns an impulsive click into a conscious choice, giving you a chance to stay on task. There is no easy "off" switch.

How It Works

  • Blocks Sites: The service edits your /etc/hosts file to block a list of common distracting websites.
  • Always On: It starts when your computer boots and runs constantly.
  • Self-Healing: If you manually edit the /etc/hosts file to unblock a site, the service will automatically block it again.
  • Clean Shutdown: When you shut down or reboot your computer, the service automatically cleans up its changes, leaving your system untouched.

Installation

You can install dsfree either from a pre-compiled binary for convenience or by building it from the source code.

Prerequisites for all methods:

  • A Linux system with systemd.
  • sudo access.

Option 1: Install from Binary (Recommended)

This is the easiest way to get started.

  1. Download the latest binary from the Releases Page.

  2. Make the binary executable and move it to a system path. In your terminal, navigate to where you downloaded the file and run:

    chmod +x dsfree
    sudo mv dsfree /usr/local/bin/
  3. Continue to "Set Up the Service" below.

Option 2: Build from Source

Prerequisite: Go compiler (version 1.18+).

  1. Clone this repository and build the binary:

    git clone https://github.com/serisow/dsfree.git
    cd dsfree
    go build -o dsfree
  2. Move the compiled binary to a system path:

    sudo mv dsfree /usr/local/bin/
  3. Continue to "Set Up the Service" below.

Set Up the Service

This final step is required for both installation methods.

  1. Create the systemd service file:

    sudo nano /etc/systemd/system/dsfree.service
  2. Paste this content into the file:

    [Unit]
    Description=Blocks distracting websites by editing /etc/hosts
    After=network.target
    
    [Service]
    User=root
    ExecStart=/usr/local/bin/dsfree
    KillMode=none
    Restart=on-failure
    
    [Install]
    WantedBy=multi-user.target
  3. Enable and start the service:

    sudo systemctl daemon-reload
    sudo systemctl enable dsfree
    sudo systemctl start dsfree

The service is now active and will start on every boot.

Management

  • To check the service status:
    systemctl status dsfree
  • To stop the service: The service is designed to ignore standard stop commands. The only way to bypass the block is through the "Emergency Recovery" steps below.

Emergency Recovery

If you absolutely must access a blocked site, you must kill the service manually. This will leave your system in a blocked state and prevent the service from starting on the next boot until you clean it up.

  1. Stop systemd from managing the service:
    sudo systemctl stop dsfree
  2. Find the Process ID (PID):
    ps aux | grep dsfree
  3. Kill the process:
    # Replace <PID> with the number you found
    sudo kill -9 <PID>
  4. Restore your hosts file: A backup of your original hosts file is at /etc/hosts.dsfree.bak.
    sudo mv /etc/hosts.dsfree.bak /etc/hosts

To re-enable the service after a manual recovery, simply run sudo systemctl start dsfree.

Customization

To change the list of blocked sites, edit the domainsToBlock list in the main.go file, then rebuild and reinstall the binary.

About

Daemon de productivité en Go. Aide à lutter contre le doomscrolling en bloquant l'accès aux sites de distraction via /etc/hosts.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages