4

On my phone, I'm am enjoying a new tweak called MailStop which sole purpose is to limit my reflex of checking my mail far too often. I have set it to not allow me to start the Mail app for five hours once I have already started it. This has had a great impact on my mail checking abuse. I get to stop and remember I'm checking it far too often every time I try to open it during these hours.

There are other ways to limit the Mail app abuse with this application, but my question os the same as the title: Is there a way to limit how frequently you can start an application on the mac?

1
  • Suggest shortening the explanation to make it more concise. For example, "I find mysely using Mail.app too often. Is there a way to limit it to launching no more than once every n hours, under Mac OS X?"
    – gosmond
    Feb 21, 2013 at 8:53

4 Answers 4

6
+50

You can do this using AppleScript :

1. Open AppleScript Editor

2. Paste following code:

property appName : "Mail"
property minSecsBetweenLaunches : 600 -- seconds
property checkEvery : 5 -- seconds

-- DO NOT MODIFY AFTER THIS LINE IF NOT SURE --

property lastSeenOpen : ""
property lastMailState : ""

on run
    idle
end run

on idle
    my check()
    return checkEvery -- check every n seconds
end idle

on check()
    tell application "Finder" to set processes_names to name of processes
    if (lastMailState is "") then
        -- First run
        set lastMailState to (processes_names contains appName)
        if lastMailState then
            set lastSeenOpen to current date
        end if
    else
        if (processes_names contains appName) then
            if (lastMailState is false) then
                -- App just started
                set lastMailState to true
                if (lastSeenOpen is not "") then
                    -- Already been launched, check if launch allowed
                    set timeLeft to minSecsBetweenLaunches - ((current date) - lastSeenOpen)
                    if (timeLeft > 0) then
                        tell application appName to quit
                        activate
                        display dialog "Wait " & timeLeft & " sec. before opening " & appName & " again."
                    end if
                end if
            end if
            set lastSeenOpen to current date
        else
            if (lastMailState is true) then
                -- App just quit
                set lastMailState to false
            end if
        end if
    end if
end check

3. Adjust settings

The 3 first lines of the script can be edited to fit your needs. By default, check every 5 seconds if Mail has not been seen open since 10 min (which is 600 seconds).

4. Create the app

File menu > Export

  • Choose app name & destination
  • select to export as Application
  • check "stay open..."

5. Hide from dock

In the Finder, find the app you just exported, then right-click on it, and select "Show package content". Then open "Info.plist" of the "Contents" folder in TextEdit, and, before the last </dict> of the file, paste:

<key>LSBackgroundOnly</key>
<string>1</string>

For info, after edit, end of my file looks like :

[...]
        <string>event log</string>
    </dict>
    <key>LSBackgroundOnly</key>
    <string>1</string>
</dict>
</plist>

And save it of course.

6. Set your app as startup item

System Preferences > Users > ...

3
  • Is this your original work? I thought I saw this script posted in the answer to another similiar question.
    – gosmond
    Feb 22, 2013 at 19:16
  • Yes, my work. Of course some parts can be found elsewhere like how to hide an applescript app from dock or how to detect if an application is running. But I've written this code to answer your question.
    – Bibou
    Feb 23, 2013 at 11:40
  • gosmond… does it rly matter?
    – Alexander
    Feb 24, 2013 at 23:26
4

It would be pretty easy for someone to write a utility control app use in OS X, and it looks like someone already has. Have a look at Mac App Blocker. It has per-app granularity and restriction-by-schedule. It doesn't currently have the ability to limit an app to X launches per-hour / per-day.

I emailed this feature request to the developer:

Feb. 20, 2013
Can you add the ability to limit an application to launching  x number of 
times per hour, per day, or per week?  And, related, to limit an app to 
launching *no more than* once every x hours, days, or weeks?

Got this reply:

Feb. 21, 2013
I have had a few other requests along the same lines. Perhaps it would be 
a good idea to add this kind of functionality. As Mac App Blocker has 
progressed over the past year, it has become more feature rich and, 
possibly a little more complicated. As it is, we're trying to fulfill 
more requests while keeping the app simple to use. I like your idea and I 
would like to add something to MAB for these types of options.
I will definitely add this to our growing list of feature requests.
Hopefully, we'll get this added in a (near) future release.

Ken
<censored>@<censored>.com
KnewSense, LLC

Check up on that app in 6 months or a year, maybe it'll get added.


Last-ditch options might include pouring epoxy into the keyboard, handcuffing the problem user, or removing mains power from the building.

2
  • 1
    But they could always get a different input device, go to another building, or, if handcuffed, operate an iPad with their face. Only real solution: delete the MX records from his mail host's DNS configuration.
    – Dan J
    Feb 22, 2013 at 17:35
  • I have stayed in contact with Ken and it seems to be in the latest version.
    – molle
    Aug 10, 2013 at 14:23
2

Yes, it's call Willpower 1.0. :-)

Seriously, the only thing I can think of is Parental Controls, which can limit certain actions by time of day, but I don't think that's what you want. There are probably other apps designed to limit kids' activity on Macs that might have finer-grained controls.

0

In the same line as @Kick-McElhearn, you could set up parental controls for having a few windows for checking email, and you could inform people sending you email that you are in fact enforcing those windows.

You must log in to answer this question.

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