Skip to content

feat: add CLI and scripting support#141

Merged
karbassi merged 1 commit intomichaelvillar:masterfrom
karbassi:master
Feb 7, 2026
Merged

feat: add CLI and scripting support#141
karbassi merged 1 commit intomichaelvillar:masterfrom
karbassi:master

Conversation

@karbassi
Copy link
Copy Markdown
Collaborator

@karbassi karbassi commented Feb 7, 2026

Closes #51, closes #105.

Summary

  • Add URL scheme (timer://) to control the timer programmatically — e.g. open "timer://5", open "timer://2:30?window=2"
  • Add launch argument support — e.g. open -a Timer --args 5 --window 2
  • Add AppleScript support via scripting definition (.sdef) — e.g. tell app "Timer" to start timer "5" window 2
  • Add CLI wrapper (timer-cli) as a thin shell script over the URL scheme — e.g. ./timer-cli 5 -w 2

Commands

Command Description
<duration> Start timer (e.g. 5 = 5 min, 2.5 = 2m30s, 2:30 = 2m30s)
stop Stop the timer (keeps time displayed)
reset Stop and clear timer to zero
pause Toggle pause/resume
new Open a new timer window

All commands accept an optional window parameter (1-based) to target a specific timer when multiple windows are open.

Files changed

  • Timer/AppDelegate.swift — URL handler, launch args parser, command router, time input parser
  • Timer/MVClockView+Behavior.swiftstartTimer(seconds:) method
  • Timer/MVTimerController.swift — expose clockView for programmatic access
  • Timer/Info.plist — URL scheme registration, AppleScript enabled
  • Timer/Timer.sdef — scripting definition (start/stop/pause/reset/new)
  • Timer/TimerScriptCommand.swiftNSScriptCommand subclass
  • Timer.xcodeproj/project.pbxproj — add new files to target
  • timer-cli — shell script CLI wrapper
  • Makefileinstall-cli target

Test plan

  • make build — clean build, no errors
  • make lint — 0 violations
  • make test — all tests pass
  • open "timer://5" — starts 5-minute timer
  • open "timer://2.5" — starts 2m30s timer
  • open "timer://2:30" — starts 2m30s timer
  • open "timer://stop", open "timer://reset", open "timer://pause"
  • open "timer://new" — opens new timer window
  • open "timer://5?window=2" — targets second window
  • open -a Timer --args 5 — starts via launch args
  • AppleScript: tell application "Timer" to start timer "2"
  • ./timer-cli 5 — starts via CLI wrapper

…ript, CLI)

Add four ways to control the timer programmatically:

- URL scheme: open "timer://5", open "timer://2.5", open "timer://2:30?window=2"
- Launch args: open -a Timer --args 5 --window 2
- AppleScript: tell app "Timer" to start timer "5" window 2
- CLI wrapper: ./timer-cli 5 -w 2 (thin shell script over URL scheme)

Commands: start (duration), stop, reset, pause, new.
Time formats: "5" (5 min), "2.5" (2m30s fractional), "2:30" (2m30s colon).
Multi-window: optional window parameter (1-based) targets specific timers.
@karbassi karbassi merged commit c114594 into michaelvillar:master Feb 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apple Script API Add ability to send timer via command line

1 participant