Skip to content

Instantly share code, notes, and snippets.

@dannydb
Last active June 3, 2020 22:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannydb/e707f136ba939efcb359 to your computer and use it in GitHub Desktop.
Save dannydb/e707f136ba939efcb359 to your computer and use it in GitHub Desktop.

Automate a reminder to pack your laptop

I don't usually take my work laptop home each evening, but once in awhile I do, and a fraction of those times I've neglected to pack the deck the next morning because it's not part of my usual morning routine.

Here's a quick fix, using iCloud reminders, a neat (free!) app called ControlPlane and a couple of short scripts.

1. Install ControlPlane

Get ControlPlane by using Cask:

brew cask install controlplane

Or download the binary here.

2. Modify the scripts

Next, modify the laptop_reminder.sh and laptop_reminder.applescript scripts below to use the correct iCloud reminder list and set the text and alert time of the generated reminder.

Make sure the path you supply to laptop_reminder.sh is absolute.

2. Configure a context and action

ControlPlane allows you to trigger actions based on contexts. Contexts are defined by system characteristics the app refers to as "evidence sources." The plan is to create a context that goes active when ControlPlane detects you are at home, based on CoreLocation and WiFi information.

First, add a context called "Home":

create home context

Make sure "Current Location" and "Nearby WiFi Network" are enabled in evidence sources:

sources

Create rules to activate your Home context when CoreLocation matches your home address and Nearby WiFi Network matches your home network:

rules rules

Finally, create an action that will trigger laptop_reminder.sh, which then calls laptop_reminder.applescript when the home context activates.

action

That's it! ControlPlane will notify you that the action has run the next time the home context activates and a scheduled reminder will appear in Reminders.app on OS X and iOS that will alert you to pack your laptop the next day:

reminder

tell application "Reminders"
repeat with thisReminder in (get reminders in list "Reminders" whose completed is false)
set nameObj to name of thisReminder
if (nameObj is equal to "Don't forget your laptop!") then
return
end if
end repeat
set reminderDate to current date
set day of reminderDate to ((reminderDate's day) + 1)
set time of reminderDate to (8 * hours) + (45 * minutes)
tell list "Reminders"
make new reminder at end with properties {name:"Don't forget your laptop!", remind me date:reminderDate}
end tell
end tell
osascript ~/Projects/dotfiles/applescript/laptop_reminder.applescript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment