A command-line tool (and background service) for managing distractions with builtin pomodoro mode.
SYNOPSIS
distractions [on|off|toggle|status|background|clock|pomodoro]
OPTIONS
-f --file
Path to the distractions file. Needed for 'off' command
--work-time
Work time for pomodoro mode. Example values: '20m' '1h'. Default: 25m.
--break-time
Break time for pomodoro mode. Example values: 20m, 3m. Default: 5m
--on-work
Execute given script on starting to work
--on-break
Execute given script on break
--json
Format output as JSON. (Only implemented for clock command)
--relative
Format output as relative time. (Only implemented for clock command)
-h --help
Show help
Clone and add it to $PATH
Create a .distractions
file in your home directory:
gmail.com
news.ycombinator.com
twitter.com
quora.com
Start a background service as root
, it needs write access to /etc/hosts
;
$ sudo distractions background -f ~/.distractions
If preferred, you can define a system service;
Unit]
Description=Distractions
[Service]
Type=simple
ExecStart=distractions background -f /home/azer/.distractions
User=root
[Install]
WantedBy=multi-user.target
Once distractions is running on the background, you can call it by sending signals via the same distraction script;
$ distractions off
It'll add these lines to /etc/hosts
:
# <distractions>
127.0.0.1 gmail.com
127.0.0.1 news.ycombinator.com
127.0.0.1 twitter.com
127.0.0.1 quora.com
# </distractions>
You can turn them on if needed, so they'll be removed from /etc/hosts
$ distractions on
Check if it's on/off:
$ distractions status
Run clock
command to see how many minutes has passed since you've turned off distractions;
$ distractions clock
00:08 Work
Run pomodoro
command if you prefer switching work/break mode automatically:
$ distractions pomodoro
Starting Pomodoro.
Starting work-mode.
By default, work is 25 minutes and break is 5 minutes. You can customize that;
$ distractions pomodoro --work-time 15m --break-time 3m
You can set custom scripts to be executed when work/break mode starts:
$ distractions pomodoro --on-work ~/start-work.sh --on-break ~/start-break.sh
If desired, you can define a system service for pomodoro mode so you can control it easily;
Description=Pomodoro
[Service]
Type=simple
ExecStart=distractions pomodoro --on-work /home/azer/.pomodoro/start-work.sh --on-break /home/azer/.pomodoro/start-break.sh
Environment=DISPLAY=:0
Environment=XAUTHORITY=%h/.Xauthority
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
User=azer
[Install]
WantedBy=multi-user.target
Note that this service runs as non-root user, in contrast to the background service.