Protect 1Focus from being Force Quit

1Focus works on Mac OS, and it is pretty good software which prevents us from procrastinating. It blocks designated websites which fascinate us, which results in saving a lot of time and keeping us more stay focused. However, an outstanding procrastinator, namely me, has found out a way to get away from the protection by this software.

Although 1Focus doesn’t permit us to shut it down by usual ways, you can close it by using Force Quit in Activity Monitor. Since I noticed it, I am returning to a procrastinator again. This article is about what I did to protect 1Focus from being Force Quit and to be a self-disciplined guy again.

1Focus can be shut down manually through Activity Monitor

You might already know, you can Force Quit 1Focus through the Acivitity Monitor 🙁

Protection 1: Use apple scripts

At first, I wrote three apple scripts which automatically restart 1Focus when it crashes by referring to the following website: https://discussions.apple.com/thread/7457783

These three scripts constantly monitor 1Focus and each of scripts and restart them when one of them crashes. Thus, if you want to Force Quit 1Focus, at first you need to shut down all the scripts in a short period and then Force Quit 1Focus. It works as the pretty nice mind barrier for me to fight against the allure of shutting down 1Focus.

1Focus_n.app

on run doit() end run on idle doit() return 1 -- in seconds end idle on doit() tell application "System Events" set focusApps to every application process whose bundle identifier is "com.onefocusapp.OneFocus" set focusAppsp to every application process whose bundle identifier is "com.apple.ScriptEditor.id.1Focus-p" set focusAppsw to every application process whose bundle identifier is "com.apple.ScriptEditor.id.1Focus-w" if ((count of focusApps) is 0) then tell application "Finder" launch application "1Focus" launch application "1Focus_p" launch application "1Focus_w" end tell end if if ((count of focusAppsp) is 0) then tell application "Finder" launch application "1Focus" launch application "1Focus_p" launch application "1Focus_w" end tell end if if ((count of focusAppsw) is 0) then tell application "Finder" launch application "1Focus" launch application "1Focus_p" launch application "1Focus_w" end tell end if end tell end doit
Code language: PHP (php)

1Focus_p.app

on run doit() end run on idle doit() return 0 -- in seconds end idle on doit() tell application "System Events" set focusApps to every application process whose bundle identifier is "com.onefocusapp.OneFocus" set focusAppsw to every application process whose bundle identifier is "com.apple.ScriptEditor.id.1Focus-w" set focusAppsn to every application process whose bundle identifier is "com.apple.ScriptEditor.id.1Focus-n" if ((count of focusApps) is 0) then tell application "Finder" launch application "1Focus" launch application "1Focus_w" launch application "1Focus_n" end tell end if if ((count of focusAppsw) is 0) then tell application "Finder" launch application "1Focus" launch application "1Focus_w" launch application "1Focus_n" end tell end if if ((count of focusAppsn) is 0) then tell application "Finder" launch application "1Focus" launch application "1Focus_w" launch application "1Focus_n" end tell end if end tell end doit
Code language: PHP (php)

1Focus_w.app

on run doit() end run on idle doit() return 1 -- in seconds end idle on doit() tell application "System Events" set focusApps to every application process whose bundle identifier is "com.onefocusapp.OneFocus" set focusAppsn to every application process whose bundle identifier is "com.apple.ScriptEditor.id.1Focus-n" set focusAppsp to every application process whose bundle identifier is "com.apple.ScriptEditor.id.1Focus-p" if ((count of focusApps) is 0) then tell application "Finder" launch application "1Focus" launch application "1Focus_n" launch application "1Focus_p" end tell end if if ((count of focusAppsn) is 0) then tell application "Finder" launch application "1Focus" launch application "1Focus_n" launch application "1Focus_p" end tell end if if ((count of focusAppsp) is 0) then tell application "Finder" launch application "1Focus" launch application "1Focus_n" launch application "1Focus_p" end tell end if end tell end doit
Code language: PHP (php)

Copy the above code into the Script Editor and save with the following options one by one.

Once you create three executable applications, you need to copy them into the application folder. After you open the applications, you need to make them open at login by clicking their icons in Dock.

This protection works pretty well for me as the mind barrier, but you still can close the 1Focus by shutting all scripts in a very short period. Thus, I created a second mind barrier.

Protection 2: Use Cron

Cron is a CUI based scheduler. It will periodically launch designated software at the assigned time window.

At first, you need to type the following in your terminal

crontab -e

Then, add the following line and save it. The following line means Cron will launch “/Applications/1Focus_n.app” every 5 minutes.

*/5 * * * * open -a /Applications/1Focus_n.app
Code language: JavaScript (javascript)

Even if your desire to shut down 1Focus is strong enough to overcome the first mind barrier, Cron automatically relaunch the 1Focus automatically every 5 minutes. These two steps mind barriers work well for me, and I have never quit 1Focus since I introduced them.

Disclaimer

This blog does not make any warranties about the completeness, reliability, and accuracy of this information. Any action you take upon the information you find on this website (itsuka-naritai.com), is strictly at your own risk. This Blog will not be liable for any losses and/or damages in connection with the use of our website.

コメント

Copied title and URL