The basic thought was to create a simple tool to view, add and remove tasks (all day events in google calendar). First you will need to install the googlecl package. You can find it in standard repositories or HERE.
When you will run your first command, you will be asked to allow permissions to access the calendar. Login to your Google account and allow access for googlecl tools.
Afterward you can use my wrapper. The usage is following:
list all List all events in calendar.
list today List events for today.
list List events for upcoming week.
add today <string> Add event for today.
add <NR> <string> Add event for <NR> days.
del <string> Delete event from calendar.
Examples:
gcal list -this will list events for upcoming week
gcal add 4 this is my memo -add event for 4 days
To delete an event use first letters from event to find it:
gcal del this
For calendar MyCalendar
Are you SURE you want to delete event "this is my memo"? (y/N): y
-if there are several matches the question will repeat
Beware of using memos like: my memo for 4 days, my memo for tomorrow, as this can be wrong interpreted and added to the calendar. Also if you need to use . (dot) or some other signs it might not work. You need to try, it seems like sometimes it works and sometimes don't.
NOTE: set in the script (del section) your calendar name.
Here's the script:
#!/bin/bash TODAY=`date +%Y-%m-%d` NEXTWEEK=`date -d 'next week' +%Y-%m-%d` MONTH=`date +%b` usage(){ echo -e "Wrapper for googlecl tools\nKRISKO 2011\n" echo -e "USAGE:\n" echo -e "list all\t\tList all events in calendar." echo -e "list today\t\tList events for today." echo -e "list\t\t\tList events for upcoming week." echo -e "add today <string>\tAdd event for today." echo -e "add <NR> <string>\tAdd event for <NR> days." echo -e "del <string>\t\tDelete event from calendar." } case "$1" in "list" ) if [ "$2" == "all" ]; then #list all events in calendar google calendar list | sed -e '1,2d' | sed -e 's/00:00//g' | sed -e 's/'$MONTH'//2' | sed -e 's/ - /-/' | sed -e 's/ / /g' elif [ "$2" == "today" ]; then #lists only todays events google calendar list --date $TODAY | sed -e '1,2d' | sed -e 's/00:00//g' | sed -e 's/'$MONTH'//2' | sed -e 's/ - /-/' | sed -e 's/ / /g' #default, list events from one week in the future else google calendar list --date $TODAY,$NEXTWEEK | sed -e '1,2d' | sed -e 's/00:00//g' | sed -e 's/'$MONTH'//2' | sed -e 's/ - /-/' | sed -e 's/ / /g' fi ;; "add" ) if [ "$2" == "today" ]; then #add all day event for today ADD=`echo $@ | sed -e 's/add today //'` echo Event for today: "$ADD" google calendar add "$ADD today" elif [[ "$2" == [0-9]* ]]; then #add event for several days ADD=`echo $@ \`date +%d" "%b\`-\`date -d ''$2' day' +%d" "%b\` | cut -d ' ' -f 3-` echo Event for $2 days: $ADD google calendar add "$ADD" fi ;; "del" ) #delete events, note that MyCalendar is my calendar name DEL=`echo $@ | cut -d ' ' -f 2-` google calendar delete --cal "MyCalendar" --title "$DEL" ;; * ) usage;; esac exit 0
No comments:
Post a Comment