You definitely heard correctly that there is a Keyboard Maestro field guide coming. (I don’t remember when he said it was coming, though.)
As far as your calendar question goes, I think we can solve this by using http://hasseg.org/icalBuddy, which is a free little tool for getting calendar items.
It has a lot of ways to restrict its data pool (see man icalBuddy
for help there), but just as a starter, I would do something like this:
icalBuddy --excludeAllDayEvents --includeOnlyEventsFromNowOn eventsToday
which gives me this
• Phone Catherine (Tracey)
2:00 PM - 3:00 PM
• Ethan Guitar Lesson (Family)
location: 32 Plattsburgh Plz
Plattsburgh NY 12901
4:00 PM - 5:00 PM
• Interfaith Prayer Service (Tj)
location: 1 Bowman St
Plattsburgh NY 12901
url: http://www.bethisraelplattsburgh.org/
7:00 PM - 8:30 PM
As you can see, there’s only one event with an URL. I could also restrict it further by limiting which calendar it was using. For example, this will restrict the output to only events on the ‘(Tj)’ calendar:
icalBuddy --excludeAllDayEvents --includeOnlyEventsFromNowOn --includeCals Tj eventsToday
which gives me this:
• Interfaith Prayer Service (Tj)
location: 1 Bowman St
Plattsburgh NY 12901
url: http://www.bethisraelplattsburgh.org/
7:00 PM - 8:30 PM
The only real drawback to icalBuddy
is that it’s relatively slow, but I think if you used Keyboard Maestro to run the appropriate icalBuddy
command a minute or two before your meeting on Friday, you could do something like this to pull out the correct URL:
icalBuddy --excludeAllDayEvents --includeOnlyEventsFromNowOn --includeCals Tj eventsToday \
| awk -F' ' '/url:/{print $NF}' \
| head -1
(For those who aren’t familiar with these shell commands: the awk
line tells it to get the last ($NF
) piece of info from the line that matches url:
and the head -1
stays “just show me the first matching result”.)
For me, the above command shows this:
http://www.bethisraelplattsburgh.org/
So, if I wanted to put that into a variable, I would do this:
URL=$(icalBuddy --excludeAllDayEvents --includeOnlyEventsFromNowOn --includeCals Tj eventsToday \
| awk -F' ' '/url:/{print $NF}' \
| head -1)
which would assign the variable $URL
to the, well, URL. If I wanted to open that URL in Chrome, I could then add this line:
open -a 'Google Chrome' "$URL"
Putting it all together as a script that you should be able to use in Keyboard Maestro:
#!/bin/zsh -f
# replace 'Tj' with the name of the calendar you want to use to look for events
CALENDAR='Tj'
# set this to whatever is right for your Mac, or just use this, it should be right for most
PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
# assign the URL variable, using the "$CALENDAR" variable we assigned about
URL=$(icalBuddy --excludeAllDayEvents --includeOnlyEventsFromNowOn --includeCals "$CALENDAR" eventsToday \
| awk -F' ' '/url:/{print $NF}' \
| head -1)
# open the URL in Google Chrome
open -a 'Google Chrome' "$URL"
# End of script
Set that to run in Keyboard Maestro every Friday at 10:29 a.m. and I think it should solve the problem.
Let me know if you have any questions!