Created
November 11, 2024 18:27
-
-
Save Strajk/b7f2002bf9d88a5c4654a7257e250c59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Name: Log Past X Minutes to Calendar | |
| // Description: Asks for duration in minutes, event title, and (on first use) calendar name | |
| // Author: Pavel 'Strajk' Dolecek <www.strajk.me> | |
| // Twitter: @straaajk | |
| // me.strajk:status SHARED | |
| const minutes = await arg("Enter the duration (in minutes) to log retroactively") | |
| const title = await arg("Describe the activity you want to log") | |
| let calendar = await env("SCRIPTKIT_LOG_CALENDAR_NAME", { | |
| hint: `Enter the exact name of an existing calendar in your Calendar app`, | |
| }) | |
| await applescript(` | |
| tell application "Calendar" | |
| switch view to week view | |
| tell calendar "${calendar}" | |
| set theCurrentDate to current date | |
| make new event at end with properties {summary:"${title}", start date:theCurrentDate - ${minutes} * minutes, end date:theCurrentDate} | |
| end tell | |
| end tell | |
| `) | |
| await notify(`Logged ${minutes} minutes of ${title} to ${calendar}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment