Example 1.0.0
Reminds you to take a break every so often.
Shows a reminder to take a break every so often.
Once started, it shows an alert with message every interval minutes. The remind hotkey
shows one straight away, and toggle starts or stops the reminders. When your config is
reloaded, it remembers when the next reminder was due, so reloading doesn't restart the wait.
This is the template's example Spoon. Copy it, rename it and make it your own: it has the
parts most Spoons have (settings, hotkey actions, start(), stop() and shutdown()), laid
out the way this repository's README, docs and lint tooling expect.
Usage
hs.spoons.use("Example", {
source: "Hammerspoon/Spoons2Template",
hotkeys: "default",
start: true,
})
// or, configured:
hs.spoons.use("Example", {
source: "Hammerspoon/Spoons2Template",
config: { message: "Stand up and stretch!", interval: 45 },
hotkeys: { remind: [["cmd", "alt", "ctrl"], "b"] },
start: true,
})
Settings
Set these with hs.spoons.use()'s config option, or directly, as hs.spoons.Example.setting = value.
| Setting | Type | Default | Description |
|---|---|---|---|
message |
string |
"Time for a break!" |
The text of each reminder. |
interval |
number |
60 |
Minutes between reminders. |
duration |
number |
5 |
Seconds each reminder stays on screen. |
Hotkey actions
Bind hotkeys to these with hs.spoons.use()'s hotkeys option, or with bindHotkeys(): for example, hotkeys: { remind: [["cmd", "alt"], "x"] }. hotkeys: "default" binds the default hotkeys.
| Action | Default hotkey | Description |
|---|---|---|
remind |
⌃⌥⌘R | Shows a reminder now. |
toggle |
⌃⌥⌘T | Starts the reminders if they're stopped, or stops them if they're running. |
Lifecycle
init() is called when the Spoon is loaded, and shutdown() when your config is reloaded or Hammerspoon 2 quits. start: true in hs.spoons.use() calls start(). See the guide's Lifecycle section.
start()
Starts the reminders. The first is due interval minutes from now, or, just after a config
reload, when it was due before the reload. Does nothing if they're already running.
Returns object The Spoon, so calls can be chained
stop()
Stops the reminders. Does nothing if they aren't running.
Returns object The Spoon, so calls can be chained
shutdown(reason)
Called by Hammerspoon 2 when your config is reloaded or it quits. It doesn't need to stop the
timer, since Hammerspoon 2 stops every timer itself. It saves when the next reminder was due,
for start() to pick up after a reload.
reasonstring"reload"or"quit"
Methods
remind()
Shows a reminder now, without changing when the next one is due.
Returns object The Spoon, so calls can be chained
toggle()
Starts the reminders if they're stopped, or stops them if they're running.
Returns object The Spoon, so calls can be chained
isRunning()
Whether the reminders are running.
Returns boolean true if start() has been called, and stop() hasn't since