Skip to content

cdzombak/hosts-timer

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

hosts-timer

Block websites on your system with /etc/hosts, and re-enable them on demand for a specified amount of time.

Installation

Requires Go to be installed (tested with Go 1.15.x).

git clone https://github.com/cdzombak/hosts-timer.git
cd hosts-timer
make install

Usage

Setup for domain(s)

sudo hosts-timer -install facebook.com twitter.com

(-disable is an alias for -install, which disables the given sites.)

Use a site for a specified duration of time

sudo hosts-timer -time 5m twitter.com

Durations must be acceptable by time.ParseDuration.

Remove hosts-timer block for domain(s)

sudo hosts-timer -uninstall twitter.com facebook.com

(-enable is an alias for -uninstall, which enables the given sites.)

Setup Hints

.zshrc helpers

function use-facebook() {
    if [ $# -eq 0 ]; then
        echo "Usage: use-facebook DURATION"
        echo "   eg. use-facebook 5m"
        return 1
    fi
    sudo hosts-timer -time "$1" facebook.com
}

function use-twitter() {
    if [ $# -eq 0 ]; then
        echo "Usage: use-twitter DURATION"
        echo "   eg. use-twitter 5m"
        return 1
    fi
    sudo hosts-timer -time "$1" twitter.com
}

Alfred helpers

Install the included Alfred helpers, and then you can use Alfred to enable Twitter or Facebook for a given amount of time (default 5 minutes).

Screenshot of Alfred helper for Twitter

Create /etc/sudoers.d/hosts-timer

cdzombak ALL=NOPASSWD: /usr/local/bin/hosts-timer

And then:

sudo chown root:wheel /etc/sudoers.d/hosts-timer
sudo chmod 440 /etc/sudoers.d/hosts-timer

Author

Chris Dzombak

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published