Fandom

HabitRPG Wiki

Google Calendar Integration Linux Script

744pages on
this wiki
Add New Page
Talk3 Share

This software stopped working after 30 July 2016 when Habitica's deprecated API v2 was removed.

Information about the API change can be found at Application Programming Interface.


Calendar events

Description

Imports your Google Calendar events for tomorrow into your Habitica To-Dos.

Installation

Install and configure Google Calendar Command Line Interface and Habitica Command Line Tool (direct link). Copy the script to an executable file on your Linux computer.

Usage

Run the script each time you want to import events (e.g., every evening). Each event for tomorrow will be added as a To-Do with the name ":calendar: %H:%M Event name", with easy difficulty. For example, you create Google Calendar event "Learn more about Inferno and Plan9" for 15:00. After running this script, you will have a new To-Do in Habitica titled ":calendar: 15:00 Learn more about Interno and Plan9." Events which had been imported on a previous run will not be imported again.


Below is the version of the script as of February 21, 2016, however it is recommended that you obtain the latest version of the script from the maintainer's website.

#!/bin/sh

PATH=${PATH}:/usr/local/bin/
TODO_PREFIX=":calendar:"

calendar_get_events() {
    local day="${1:-tomorrow}" # see man date(1) DATE STRING

    # validate day syntax
    for i in $day "$day + 1 day"; do
        date -d"${i}" "+%Y-%m-%d" >/dev/null 2>&1 || {
            echo "calendar_get_events invalid argument, see man date(1) DATE STRING" > /dev/stderr
            return
        }
    done
    gcalcli --military --nocolor agenda `date -d"$day" +%Y-%m-%d` `date -d"$day + 1 day" +%Y-%m-%d`
}

parse_events() {
     sed -E 's/^..\. [^\.]+\. [0-9]+? //' | awk -vPREFIX="${TODO_PREFIX}" -r '/^ +[0-9]+?:[0-9]+? / {printf PREFIX" "$1;$1=""; print $0}' | sort -r

}

habatica_update_todo() {
    xargs -tI% sh -c "habitica todos | fgrep '%' || habitica todos add --difficulty=easy '%'"
}


calendar_get_events "tomorrow" | parse_events | habatica_update_todo

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.