Skip to content

Instantly share code, notes, and snippets.

@Strajk
Created November 11, 2024 18:27
Show Gist options
  • Select an option

  • Save Strajk/b7f2002bf9d88a5c4654a7257e250c59 to your computer and use it in GitHub Desktop.

Select an option

Save Strajk/b7f2002bf9d88a5c4654a7257e250c59 to your computer and use it in GitHub Desktop.
// 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