Skip to content

Instantly share code, notes, and snippets.

@moehrenzahn
Created October 11, 2015 16:36

Revisions

  1. moehrenzahn created this gist Oct 11, 2015.
    19 changes: 19 additions & 0 deletions menucalendaraction.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    # 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