Creating custom notifications for reminders
Humans weren’t meant for sitting, and it has caused me a great deal of issues personally. I wanted to schedule reminders on Mac for standing up and drinking water, since I lose track of time pretty easily.
Turns out this is very simple to do.
- Create a shell script (for example,
drink-water.sh):
1#!/bin/bash
2osascript -e 'display notification "You need water" with title "Drink water"'Make the script executable, then register it with
launchd.If it doesn’t already exist, create
~/Library/LaunchAgents.Create
~/Library/LaunchAgents/com.my.drink-water.plist:
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
3 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
4<plist version="1.0">
5<dict>
6 <key>Label</key>
7 <string>drink.water.reminder</string>
8
9 <key>ProgramArguments</key>
10 <array>
11 <string>/full/path/to/drink-water.sh</string>
12 </array>
13
14 <key>StartInterval</key>
15 <integer>1800</integer>
16
17 <key>StandardErrorPath</key>
18 <string>/tmp/water.err</string>
19 <key>StandardOutPath</key>
20 <string>/tmp/water.out</string>
21</dict>
22</plist>- Load it:
1launchctl load /full/path/to/com.my.drink-water.plist