So I have a problem with distractions on a macbook. I am hard at work (in emacs) and then I need to look something up. I go to my web browser (Chrome) find the information I need, and half an hour later I realize I'm reading up on the actions Mueller is taking to [subvert the will of the people / save American Democracy]. I quickly get back to work.

So it would be useful if when Chrome is in the foreground some alert pops up after 5 minutes. Maybe a sound, maybe a dialog box. But something that brings me back to the moment and realize I'm wasting time.

I've set up things that block my access to particular websites or such, but I can't block all of these webpages without blocking access to information I need to get. So that's not the solution.

Is there a way to get some sort of alert to pop up every 5 minutes when Chrome has been in the foreground?


This works for me using the latest version of Sierra.

Paste this following AppleScript code into script editor.app then save it as an application.You can play around with the delay and the repeat values But as it is set now, You will get a notification when Google Chrome has been the front most application for five minutes.

Just launch your new app anytime u want Google Chrome to be monitored.

So far, the only negative issue is... Because I have an infinite repeat loop inside of the script code,The only way to exit the application is by force quit.

property isGoogleFrontmost : missing value

    tell application "Google Chrome" to set isGoogleFrontmost to frontmost
    if isGoogleFrontmost is true then
        repeat 300 times -- 5 minutes with a delay 1 value
            delay 1
            tell application "Google Chrome" to set isGoogleFrontmost to frontmost
        end repeat
        if isGoogleFrontmost is true then
        end if
    end if
end repeat

on Google_Status()
    tell application "Google Chrome" to set isGoogleFrontmost to frontmost
    tell application "Google Chrome"
        repeat until isGoogleFrontmost is true
            set isGoogleFrontmost to frontmost
        end repeat
    end tell
end Google_Status

on displayNotification()
    display notification ¬
        "GET BACK TO WORK" with title ¬
        "DUDE...Time To Quit Google Chrome" sound name "Bottle"
    delay 5
end displayNotification
  • I'm curious why my post got a -1. I think my solution addresses exactly what the OP was looking to achieve. Wouldn't a comment with constructive criticism be more useful to everyone, Rather than just -1? – wch1zpink Jan 21 '18 at 4:00
  • Might it be that the code doesn't actually work properly? – user3439894 Jan 21 '18 at 4:07
  • It works flawlessly on my end. Do you see any issues? – wch1zpink Jan 21 '18 at 4:10
  • I have it set right now so that Google Chrome needs to be continuously Upfront For that specified time. If the user put another application frontmost then puts chrome Back to front most... The delay and the counting starts over – wch1zpink Jan 21 '18 at 4:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .