let goodMorningFileName = `jarvis-good-morning.mp3 `
await run("play-audio-file", goodMorningFileName)
await run("press-keyboard-shortcut", "Spotify", ";", "command,control")
await run("press-keyboard-shortcut", "Simplenote", "l", "command,control")
await run("press-keyboard-shortcut", "Simplenote", "l", "command,control")
await run("press-keyboard-shortcut", "Simplenote", "l", "command,control")
await run("press-keyboard-shortcut", "Toggl Track", "j", "command,control")
await run("start-toggl", "checking in with myself", "personal catchall")
await run("new-daily-note")
await run("press-keyboard-shortcut", "Simplenote", "f", "command,option")
const AUDIO_FILE_DIR = `~/Documents/audiofiles`
let audioFileName = await arg(`What is the name of the audio file?`)
exec(`afplay ${AUDIO_FILE_DIR}/${audioFileName} &>/dev/null &`)
async function pressKeyboardShortcut (application = "", key, commands = []) {
const formattedCommands = formatCommands(commands)
return await applescript(
String.raw`
activate application "${application}"
tell application "System Events"
keystroke "${key}" using {${formattedCommands}}
end tell
`
)
}
function formatCommands(commands = []) {
return commands.map(command => `${command} down,`).join(" ").slice(0, -1)
}
let application = await arg(`What application should this be run with?`)
let key = await arg(`What is the key?`)
let unformattedCommands = await arg(`What are the commands? Separate by comma.`)
let commands = unformattedCommands.split(",")
console.log('run with ', application, key, commands)
await pressKeyboardShortcut(application, key, commands)
let btoa = await npm("btoa")
let TOGGL_TOKEN = await env("TOGGL_TOKEN")
let wid = await env("WORKSPACE_ID")
let description = await arg(`What are you working on?`)
let project = await arg('Select project:', [
'Coder',
'personal catchall',
'vim for vscode',
])
const projectIds = {
'Coder': "165657166",
"personal catchall": "165660677",
"vim for vscode": "165340149"
}
const pid = projectIds[project] || "165340149"
const response = await post(
"https://api.track.toggl.com/api/v8/time_entries/start",
{
time_entry: {
pid,
wid,
description,
created_with: "Script Kit",
},
},
{
headers: {
"Content-Type": "application/json",
Authorization:
"Basic " + btoa(`${TOGGL_TOKEN}:api_token`),
},
}
)
let {format} = await npm('date-fns')
let date = format(new Date(), 'yyyy-MM-dd')
let dayOfWeek = format(new Date(), "eeee")
await run("press-keyboard-shortcut", "Simplenote", "n", "command")
await applescript(
String.raw`
activate application "Simplenote"
tell application "System Events"
keystroke "${date}" & return & "Happy ${dayOfWeek} :)" & return & return & "Today I'm feeling grateful for:" & return & "1." & return & "2." & return & "3."
end tell
`
)