Skip to content

Instantly share code, notes, and snippets.

@moehrenzahn
Created October 11, 2015 16:36
Show Gist options
  • Save moehrenzahn/d503dd0c714e8eae3676 to your computer and use it in GitHub Desktop.
Save moehrenzahn/d503dd0c714e8eae3676 to your computer and use it in GitHub Desktop.
# This is an action script for TextBar corresponding to this gist: https://gist.github.com/moehrenzahn/6e29d3080edb6466db7b
# By Max Melzer
open /Applications/Calendar.app; # If any line of the list is clicked, open the default Calendar app.
# The following code begins a multi-line applescript. The repeat loop makes sure that the script waits until Calendar has finished opening.
osascript -e '
set calendarDidFinishLaunching to false
repeat while calendarDidFinishLaunching is false
tell application "System Events" to set frontApp to name of first application process whose frontmost is true
if frontApp is "Calendar" then set calendarDidFinishLaunching to true
end repeat
tell application "System Events" to keystroke "t" using command down' # This simulates a press of CMD-T, which tells Calendar to jump to the current day. You could parse the title of an event and jump right to that event, but I havent implemented this functionality yet.
if [[ $TEXTBAR_TEXT == *"Neuer Eintrag"* ]] ; then # This parses the clicked line and checks if it is our link to create a new entry.
osascript -e 'tell application "System Events" to keystroke "n" using command down' # If it is we simulate a press of CMD-N, opening the quick entry pane of calendar, ready for your input.
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment