Skip to content
Browse files

updated README.org and commented other files

  • Loading branch information...
1 parent 80455a4 commit 04b89bc623dbcc79780bd445d8bb82b5acb2c9c0 @Neil-Smithline committed May 7, 2012
Showing with 155 additions and 0 deletions.
  1. +38 −0 README.org
  2. +26 −0 gmail-account.lua
  3. +41 −0 gmail2gcal
  4. +50 −0 gmail2gcal-sample.lua
View
38 README.org
@@ -0,0 +1,38 @@
+* Gmail2Gcal
+Gmail2Gcal allows you to convert [[http://bit.ly/IQM5AK][Gmail]] mail messages into [[http://bit.ly/IQNmYx][Gcal]] events. The events can simply be used to keep a timeline of emails or you can set a reminder on the events to notify you of the email via you calendar notification mechanism. This is particularly useful if you have a smartphone that synchronizes with your Gcal calendars.
+
+* Installation Requirements
+- A Gmail and Gcal account.
+- This has been written and tested under [[http://bit.ly/KfxHFQ][Ubuntu 10.4]] Linux. It should work on other operating systems but [[http://bit.ly/Kfy0R4][YMMV]]. If you are on [[http://bit.ly/II1ozK][Windows]], my advice is that you to upgrade to [[http://bit.ly/II1rvz][Linux]]. If you can't or just plain won't to upgrade to Linux, installing [[http://bit.ly/II16ce][Cygwin]] should allow a successful installation of Gmail2Gcal. Once again, YMMV.
+- Either a working [[http://bit.ly/Kfyu9Z][crontab]] system or another mechanism to execute IMAPFilter at regular time intervals. It should be possible, and possibly more efficient, to use IMAPFilter's "become_daemon" command to schedule execution of Gmail2Gcal. I did not do this as I found using a cron job easier than using "become_daemon". See [[https://github.com/lefcha/imapfilter/blob/master/samples/extend.lua][extend.lua]] in IMAPFilter's repository for an example of "become_daemon". Contributions in this area would be most appreciated.
+- Installation of the [[http://bit.ly/IHZM9l][GoogleCL]] Google Command Line interface program. Installation is well [[http://bit.ly/IHZT4E][documented]] and relatively straightforward. GoogleCL is supported on most operating systems.
+- Either a [[http://bit.ly/II0Tpm][bash]] shell or perhaps an [[http://bit.ly/IHZT4E][sh]] shell. Note that this has not been tested with an sh shell.
+- If you will be setting reminders with Gmail2Gcal, it is preferable to install Gmail2Gcal on a computer that is permanently connected to the internet.
+- Familiarity with Gmail [[http://bit.ly/Lx0qYS][labels]] and [[http://bit.ly/Lx0qYS][filters]].
+
+* Installation
+While no step is complex, there are several steps required to install Gmail2Gcal. Skipping any step will leave you with a non-working installation.
+
+** Installing Bash (likely only for Windows users)
+1) If you don't bash installed, install [[http://bit.ly/II16ce][Cygwin]] if you are on Windows or directly install bash from its [[http://bit.ly/JbQmzE][homepage]].
+
+** Install GoogleCL
+1. Follow the [[http://bit.ly/IHZT4E][documentation]] for installing GoogleCL.
+
+** TODO Gmail Setup
+1. Make sure you have a Gmail account.
+1. Create a new label in Gmail that you will use for emails that you want to have processed by Gmail2Gcal. I recommend the label /_Gmail2Gcal/ though you can choose a different one. I use the leading underscore (_) to cause the label to appear near the top of Gmail's label list.
+1. Configure filters TODO
+
+** Gcal Setup
+1. Make sure that you have a Gcal account.
+1. If you wish to use a calendar other than your default Gcal calendar for Gmail2Gcal events, create that calendar in Gcal. I use a calendar name /Reminders/ though that is just my personal choice.
+1. If you are not using your default calendar, edit the /gmail2gcal/ shell script and follow the directions at the top of the file for specifying which calendar should be used.
+
+** TODO Installing IMAPFilter
+
+** TODO Configuring IMAPFilter
+
+#+BEGIN_HTML
+<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text" property="dct:title" rel="dct:type">Gmail Configuration Sample for IMAPFilter</span> by <a xmlns:cc="http://creativecommons.org/ns#" href="http://www.neilsmithline.com" property="cc:attributionName" rel="cc:attributionURL">Neil Smithline</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.
+#+END_HTML
View
26 gmail-account.lua
@@ -0,0 +1,26 @@
+------------------------------------------------------------------------
+-- Gmail account configuration example for imapfilter
+--
+-- 1) Insert your username and password into the appropriate fields
+-- below
+--
+-- 2) Remove the leading "--" and put the next line near the beginning of
+-- your config.lua file:
+-- dofile 'gmail-account.lua'
+------------------------------------------------------------------------
+
+gmail = IMAP {
+ server = 'imap.gmail.com',
+ port = 993,
+ username = 'your username',
+ password = 'your password',
+ ssl = 'ssl3',
+}
+
+------------------------------------------------------------------------
+-- Gmail2Gcal for IMAPFilter by Neil Smithline is licensed under a
+-- Creative Commons Attribution-ShareAlike 3.0 Unported License.
+--
+-- See https://github.com/Neil-Smithline/imapfilter-gmail2gcal for
+-- more details.
+------------------------------------------------------------------------
View
41 gmail2gcal
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# By default, Gmail2Gcal will add events to your default calendar. If
+# you wish to use another calendar, remove the pound sign (#) from the
+# beginning of the line line below and insert your calendar name in
+# the line.
+
+# CALENDAR="--cal=YOUR-CALENDAR-NAME-HERE" # <=== Set calendar name here
+
+#######################################################################
+# What follows is the actual code and internal documentation. It is
+# not required to read further to install Gmail2Gcal.
+#######################################################################
+
+# The Gmail API has a peculiar bug that prevents alarms from being set
+# via the natural language interface that is used by the GoogleCL
+# command. After much exerimentation, I discovered a workaround.
+#
+# It seems that the CLI event creation puts an inactive reminder in
+# the event. Visiting the event on the web will activate the reminder
+# but that is not an automated process.
+#
+# To automate the process, we create the event, extracting the event's
+# URL from the CLI's output, and then we access the URL via a wget.
+#
+# Don't ask me to explain this. Complain to Google. All I know is that it works.
+
+(
+ url=$(google calendar --reminder=0m "$CALENDAR" add "$*" 2>&1 > /dev/null | sed 's/Event created: //')
+
+ wget -O /dev/null "$url"
+
+) 2>&1 > /dev/null
+
+########################################################################
+## Gmail2Gcal for IMAPFilter by Neil Smithline is licensed under a
+## Creative Commons Attribution#ShareAlike 3.0 Unported License.
+##
+## See https://github.com/Neil#Smithline/imapfilter#gmail2gcal for
+## more details.
+########################################################################
View
50 gmail2gcal-sample.lua
@@ -0,0 +1,50 @@
+------------------------------------------------------------------------
+-- Gmail2Gcal configuration example for IMAPFilter
+--
+-- 1) Insert the coontents of this file at the end of your
+-- 'config.lua' file.
+--
+-- 2) Change the line, near the end of the code, so that the call to
+-- 'dofile' contains the correct path to your copy of the gmail2gcal
+-- shell script.
+------------------------------------------------------------------------
+
+-- It is probably best to put this line near the top of your
+-- 'config.lua' file.
+dofile 'gmail-account.lua'
+
+function do_subject(msgs, cmd)
+ count = 0
+ result = Set()
+ for _, mesg in ipairs(msgs) do
+ count = count + 1
+ -- mbox, uid = table.unpack(mesg)
+ mbox = mesg[1]
+ uid = mesg[2]
+ print("uid=" .. uid .. ".")
+ subject = mbox[uid]:fetch_field("Subject")
+ if cmd == nil then
+ print(" NO COMMAND")
+ else
+ pipe_to(cmd, subject)
+ end
+ end
+ return count
+end
+
+
+gmail2gcal=gmail._Gmail2Gcal:select_all()
+------------------------------------------------------------------------
+-- Modify this line to have the correct path.
+do_subject(gmail2gcal, "REPLACE-WITH-APPROPRIATE-PATH/gmail2gcal `cat`")
+------------------------------------------------------------------------
+gmail._Gmail2Gcal:delete_messages(gmail2gcal)
+
+
+------------------------------------------------------------------------
+-- Gmail2Gcal for IMAPFilter by Neil Smithline is licensed under a
+-- Creative Commons Attribution-ShareAlike 3.0 Unported License.
+--
+-- See https://github.com/Neil-Smithline/imapfilter-gmail2gcal for
+-- more details.
+------------------------------------------------------------------------

0 comments on commit 04b89bc

Please sign in to comment.
Something went wrong with that request. Please try again.