Focus Enabler is a Python program that deals with focusing issues while using computer, by blocking unneeded websites.
Python (python3.6
and above) with pip
installed.
For most end-users, this package can be installed by running:
pip3 install FocusEnabler
Notes:
Make sure
pip3
is up-to-date by runningpython3 -m pip --install pip
.For Windows, use
python
instead ofpython3
, andpip
instead ofpip3
.
The latest source code for this program can be found on GitHub. The program can then be built from source by running:
git clone https://github.com/GreaterGoodCorp/FocusEnabler
cd FocusEnabler
make build # or 'make dev-install' to install developmental version
Once installed, the program can be invoked by running focus
. Sample usage is as follows:
In order to blacklist certain domain names, use focus add <DOMAINS>
, where <DOMAINS>
is a list of domain names to
blacklist, separated by blank space.
Available options:
-
-c
(--clear
): Remove all blacklisted domains before adding new one (same asfocus remove .
) -
-d
(--disable-verbose
): Disable echoing info-messages to console. This option does not block warning or error messages
For example, to blacklist youtube.com
and facebook.com
, run the following:
$ focus add youtube.com facebook.com
The output is as follows:
- Checking operating system → MacOS
- Checking if a config file is already exists → Found at ~/.focusenabler
- Checking if host file is accessible → No
- Blacklisting facebook.com → Done
- Blacklisting youtube.com → Already blacklisted
- Writing to config file → OK
Notes:
The domain will be ignored if its syntax is invalid.
Do not run this command as
root
(or Administrator, for Windows). An error will occur when attempting to do so.
FocusEnabler
will remember any blacklisted domain names, even after rebooting.On the first run,
FocusEnabler
will create a default config file.
Likewise, to remove (un-blacklist) any domain names, use focus remove <DOMAINS>
, where <DOMAINS>
is a list of domain
names to un-blacklist, separated by blank space.
Available options:
-
-c
(--confirm
): Ask before removing each domain. -
-d
(--disable-verbose
): Disable echoing info-messages to console. This option does not block warning or error messages.
For example, to un-blacklist youtube.com
and facebook.com
, run the following:
$ focus remove youtube.com facebook.com
The output should look like this:
- Checking operating system → MacOS
- Checking if a config file is already exists → Found at ~/.focusenabler
- Checking if host file is accessible → No
- Un-blacklisting youtube.com → Done
- Un-blacklisting facebook.com → Done
- Writing to config file → OK
Notes:
The domain will be ignored if it is not blacklisted already.
Do not run this command as
root
(or Administrator, for Windows). An error will occur when attempting to do so.
To check for all blacklisted domains, run focus list
.
Available options:
-d
(--disable-verbose
): Disable echoing info-messages to console. This option does not block warning or error messages.
The output should look like this:
- Checking operating system → MacOS
- Checking if a config file is already exists → Found at ~/.focusenabler
- Checking if host file is accessible → No
All blacklisted domains:
(1) instagram.com
Notes:
Do not run this command as
root
(or Administrator, for Windows). An error will occur when attempting to do so.If
--disable-verbose
is set, this function will still list all blacklisted domains, minus the extra system information.
To activate FocusEnabler, i.e. to start blocking blacklisted domains, run sudo focus activate
(on Windows, open
Command Prompt
as administrator and run focus activate
instead).
Available options:
-d
(--disable-verbose
): Disable echoing info-messages to console. This option does not block warning or error messages.
The output should look like this:
- Checking operating system → MacOS
- Checking if a config file is already exists → Found at /Users/m1k3/.focusenabler
- Checking if host file is accessible → Yes
- Adding entry instagram.com → Done
- Writing to host file → Done
FocusEnabler is enabled!
Notes:
sudo
(or Administrator on Windows) is required as this program needs to write to the system' hosts file.
Likewise, to deactivate FocusEnabler, run sudo focus deactivate
(on Windows, open Command Prompt
as administrator
and run focus deactivate
instead).
Available options:
-d
(--disable-verbose
): Disable echoing info-messages to console. This option does not block warning or error messages.
The output should look like this:
- Checking operating system → MacOS
- Checking if a config file is already exists → Found at /Users/m1k3/.focusenabler
- Checking if host file is accessible → Yes
- Reading host file → Done
- Deactivating FocusEnabler → Done
- Writing to host file → Done
FocusEnabler is disabled!
Notes:
- Like
focus activate
,sudo
(or Administrator on Windows) is required as this program needs to write to the system' hosts file.
Initial release. No changelog available
-
New features:
- Added an option to all commands to disable echoing info-messages to console.
-
Internal changes
-
Optimised code flow
-
Remove unnecessary code guard
-
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This program is licensed under the MIT License.