Skip to content

Instantly share code, notes, and snippets.

View hepcat72's full-sized avatar

Robert Leach hepcat72

View GitHub Profile
@hepcat72
hepcat72 / sendText.osa
Last active December 8, 2023 22:36
Send SMS or iMessages via AppleScript
#!/usr/bin/env osascript
-- Version 2, now with attachments!
-- Note, the first couple times you run this script, the Messages app may prompt you to approve a couple things, one of which will be the ability to send SMS messages through your phone
-- Run via osascript on the command line like this:
-- osascript sendText.scpt --to ########## "this is" "a text message" --attachment "/path/to/image.png" "sent via applescript"
-- Where ########## is the phone number to send to
-- If you leave out `--to ##########`, it defaults to the value of an environment variable named MYPHONE in your .bashrc file (add the line "export MYPHONE=##########" to ~/.bashrc, entering your default phone number in place of ##########)
-- The 3 quoted strings will appear on separate lines and the image will be inserted between the lines "a text message" and "sent via applescript"
on run argv
@hepcat72
hepcat72 / logProjectActivity.osa
Created February 28, 2024 14:39
Log project time by mission control desktop
-- Mission Control Desktop Time Tracker
-- What is this: This is a script intended to be run via a cron job that logs your current desktop name, cursor position, monitor, app, window name, and other customizable data to a project log file.
-- Purpose: Track time spent on projects that are organized by desktop (or custom-set app). See this stack post: https://apple.stackexchange.com/a/470628/55021
-- Author: Robert Leach, Genomics Group, Princeton, rleach@princeton.edu
-- Version: 7.0 (released on 2/28/2024)
-- Installation:
-- Put a Stickies.app sticky note on each desktop containing a single-word desktop name (as the first word on the first line of the sticky). The first line must also contain the string "dtop" (without the quotes). Be sure that Stickies.app is not assigned to any desktop.
-- Create a cron job
-- Command: `osascript logCurrentDesktop.osa >> desktop_log.txt`
-- Example expression: "* * * * MON-FRI" Runs once a minute of every weekday