Giter VIP home page Giter VIP logo

google-calendar-layer's Introduction

Google calendar layer

./img/gcal.png

Table of Contents

Description

This layer provides two-way Google calendar synchronization using the org-gcal package and a dedicated calendar view using calfw package.

Calendar events are synchronized to your computer by org-gcal. They are stored in org format in one or several files user definable files. This allow the user both to include these calendar events in org-agenda and to create new events from any emacs buffer with org-capture. To learn how to setup and use the many features of org-mode see orgmode.org.

Your calendar events and TODOs (if you are an org user) can be viewed in either org-agenda or the dedicated calendar view provided by calfw. Calfw has daily, weekly and monthly calendar views and lets the user to easily create new events from the view itself.

Install

To use google-calendar layer.

  1. git clone https://github.com/mhkc/google-calendar-layer ~/.emacs.d/private/google-calendar
  2. add it to your ~/.spacemacs. You will need to add google-calendar to the existing dotspacemacs-configuration-layers list in this file.

Configuration

Configure org-gcal

To use sync your Google calendar with org-gcal you need Auth credentials from Google Developers Console.

Create credentials

  1. Go to Google Developers Console
  2. Create a project (with any name)
  3. Go to Google Calendar API and enable the API
  4. Click on Credentials and create a new “OAuth client ID”.
  5. You will need to create a “Consent screen” that will be shown when you allow org-gcal to access your data.
  6. After the screen is created select the Application type “Other”.
  7. Click on Create Client ID
  8. Save the Client ID and Client secret for later.
  9. Go to the calendar setting of your Google Caldendar by clicking on the cogwheel icon in the top right corner.
  10. Click on the “Calendar” that, which will display a list of your calendars.
  11. Select the calendar you want to synchronize with. Save the Calendar-ID which is located in the section called Calendar address, following the ICAL and HTML buttons.

Setup org-gcal

Set the following variables with your Client ID and Secret.

(setq org-gcal-client-id "YourClientId"
      org-gcal-client-secret "YourSecret")

You need to specify which calendar is going to be synchronized to which file. The variable org-gcal-file-alist expect a list where each element is an associated list containing a Calendar-ID and which file to synchronize to, see example. If you want to synchronize multiple calendars its recommended to synchronize them with different files. This also enables the user to create events for a specific calendar. Currently org-gcal do not support synchronization of multiple Google accounts.

(setq org-gcal-file-alist '(("[email protected]" . "/path/to/first_schedule_file.org")
                            ("[email protected]" . "/path/to/second_schedule_file.org")))

You need to include the calendar event files in org-agenda, do so by adding the paths to the files to the org-agenda-files variable.

(setq org-agenda-files
      (quote ("/path/to/first_schedule_file.org" "/path/to/second_schedule_file.org")))

You can create new calendar events from any Emacs buffer with org-capture. This layer provides convenient accessory functions that automatically synchronize the new event to Google calendar, see below.

Configure calfw

You can configure how the calfw calendar buffer should be displayed by altering the variable calfw-calendar-window-setup. When you close the calendar view this layer tries to restore the previous window configuration, if you would like to disable this behavior set calfw-restore-windows-after-quit to nil.

Calfw lets you customize the name of the months and days by altering the following arrays.

;; Month
(setq calendar-month-name-array
  ["January" "February" "March"     "April"   "May"      "June"
   "July"    "August"   "September" "October" "November" "December"])

;; Week days
(setq calendar-day-name-array
      ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"])

You can also change which day the week begins with the following variable.

;; First day of the week
(setq calendar-week-start-day 1) ; 0:Sunday, 1:Monday

In Calfw calendar view you can capture TODOs or events. To do so you need to bind a org-capture template to the variable cfw:org-capture-template. The following are an example template for creating a calendar event that works with the google-calendar/sync-cal-after-capture function.

(setq cfw:org-capture-template '("s" "Scedule an event" entry
                                 (file "/path/to/a/schedule/file.org")
                                 "* %^{Description}\n%^{LOCATION}p\n%(cfw:org-capture-day)\n%?"))

Configure alert

Depending on your taste and OS you might want to set different notification styles. For macOS users osx-notifier or growl on older system might work the best.

NameSummary
fringeChanges the current frame’s fringe background color
mode-lineChanges the current frame’s mode-line background color
gntpUses gntp, it requires [gntp.el](https://github.com/tekai/gntp.el)
growlUses Growl on OS X, if growlnotify is on the PATH
ignoreIgnores the alert entirely
libnotifyUses libnotify if notify-send is on the PATH
logLogs the alert text to Alerts, with a timestamp
messageUses the Emacs `message` facility
notificationsUses notifications library via D-Bus
notifierUses terminal-notifier on OS X, if it is on the PATH
osx-notifierNative OSX notification using AppleScript
toasterUse the toast notification system
(setq alert-default-style 'libnotify)

Schedule events with org-capture

There are many ways to use this layer in conjunction with org-agenda, for instance you can capture tasks directly to the schedule org file for instance by using the template described above. To automatically convert the newly to a calendar event you need to also add the following function to the org-capture-after-finalize-hook. The function checks if the capture entry is put in one of the calendar org files, and if so creates an calendar event of the file.

(add-hook 'org-capture-after-finalize-hook 'google-calendar/sync-cal-after-capture)

For a calendar event to be considered valid by org-gcal it needs.

  • A header
  • A non-interactive timestamp or time range.

Key bindings

Spacemacs leader key shortcuts.

Key BindingDescription
SPC a g fFetch new events
SPC a g sSync calendar
SPC a g rRefresh OAuth token
SPC a g cOpen calendar view

Changing the calendar view.

Key BindingDescription
DDay view
WWeek view
TTwo weeks view
MMonth view

Navigation in calendar view.

Key BindingDescription
lGo right
hGo left
kGo up
jGo down
nNext week
pPrevious week
NNext month
PPrevious month
tToday
gAbsolute date (YYYY/MM/DD)
TABNext item in a day

Actions you can perform in calendar view.

Key BindingDescription
cCapture new event
vPop-up detail agenda buffer
rRefresh buffer
RETJump
qQuit calendar view

google-calendar-layer's People

Contributors

mhkc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

google-calendar-layer's Issues

Where do the settings go?

"
Set the following variables with your Client ID and Secret.

(setq org-gcal-client-id "YourClientId"
org-gcal-client-secret "YourSecret")
"
Where do you put the settings? In the .spacemacs? or a separate file?

This is not clear

`SPC a g` is already taken

SPC a g can't be used as a prefix for keybindings in this layer, since it's already taken by the gnus layer. If you enable both layers, SPC a g will start gnus, so you won't be able to run commands like SPC a g r.

Issue open-org-calendar can't open load file no such file or directory ... calfw.org error

I've followed your instructions and have this syncing with google calendar. org-agenda displays my google calendar appointments and syncs correctly. However when I try SPC a g c (open-org-calendar) I get the following error message:

Cannot open load file: No such file or directory, calfw-org

If I run M-x cfw:open-calendar-buffer works correctly. The package calfw-org doesn't seem to be installed?

Provide a Package that Spacemacs Can use in additional-packages

If I attempt to install google-calendar-layer the "proper" way in spacemacs, i.e.

      (google-calendar :location (recipe
           :fetcher github
           :repo "mhkc/google-calendar-layer"))

under additional-packages and then under user-config put (require 'google-calendar) I get an error saying that the package couldn't be loaded due to a missing google-calendar.el file. This method requires that a google-calendar.el file exists and in that file (provide 'google-calendar) exists. There may be some more details, but that is as far as I have gotten so far.

Feature request - synchronize selected events by tag

Hello,
a friend of mine has a following problem. He would like to synchronize some particular events to google calendar.
To be more specific, within one org file, there are some events that he would like to synchronize with google calendar, and there are some events that he would like to keep locally.

As far as I know, we can only specify a complete org file which will be synchronized with google calendar all the time.
My question is if there is any support for tag-based synchronization, so only events with a specific tag (for example named gcal ) will be uploaded to the google calendar server.

org-gcal-refresh-token renamed to org-gcal--refresh-token

just an fyi.

@@ -13,7 +13,7 @@
   (defun google-calendar/org-gcal-update ()
     "Refresh OAuth token, fetch and sync calendar"
     (interactive)
-    (org-gcal-refresh-token)
+    (org-gcal--refresh-token)
     (org-gcal-fetch))

Also, thanks for the layer, just needs a couple tweaks and it works.

Creating calendar events

I've been able to get my calendar synced but when I try to add new events, through the keybinding "c", I get an error saying cfw:org-capture-template is not set yet. I placed the template function into the google-calendar/sync-cal-after-capture function, but I'm still getting the error. Is there anything else I need to do?

Also, whenever I open the calendar, I get a warning which says Error (use-package): org-projectile/:config: Symbol’s function definition is void: org-projectile:per-repo How do I fix this?

Could not contact remote service. Please check your network connectivity.

Good day,

I had a working version of gcal integration on one of my pcs around 4 months ago. But now it seems to not work on my other laptop. I get
D:/Google Drive/Documents/gcal.org and d:/Google Drive/Documents/gcal.org are the same file Got error: (error . "exited abnormally with code 2 ") Could not contact remote service. Please check your network connectivity.
What can be the reason for it and how can I get rid of this error? Did some google api change meanwhile?
My spacemacs configuration looks like this
(setq org-gcal-client-id "***.apps.googleusercontent.com" org-gcal-client-secret "***")
(setq org-gcal-file-alist '(("**@group.calendar.google.com" . "D:/Google Drive/Documents/gcal.org")))
Thank you for your advice.

Spacemacs not receiving proper id, Missing required parameter: client_id

Good day,

My spacemacs runs on windows, I followed your instructions. I put
(setq org-gcal-client-id "YourClientId" org-gcal-client-secret "YourSecret")
inside the user-config with the corresponding client id and yoursecret
But every time I open spacemacs and have a google-calendar layer I get redirected to the google page, which states
error
What am I doing wrong?

http 404 error?

When I done configuration, it report error http 404 when I sync the gcal

CalFW question

On a fresh install of this spacemacs layer, I attempt the command SPC a g f and emacs tells me that it cannot open a file named calfw-org.

  • Where is this searching?
  • Where do I find the specifications for forming this file (from my fetched gcal.org)

Thank you.

org-gcal calendar id is nil, so API request fails

I'm trying to set up the google calendar layer for spacemacs. Even though my calendar id is set like this in my .spacemacs file:

(setq org-gcal-file-alist '(("[MY-CALENDAR-ID]@group.calendar.google.com" . "~/Dropbox/emacs/calendar.org")))
I get an error like this when I try to test out adding a calendar event by capturing from calfw:

condition-case: Before first headline at position 3045 in buffer *cfw-calendar* REQUEST [error] Error (error) while connecting to https://www.googleapis.com/calendar/v3/calendars/nil/events.

REQUEST [error] Error (error) while connecting to https://www.googleapis.com/oauth2/v3/token. (error http 404)

deferred error : (error "Got error 404: (error http 404)") deferred error : (error "Got error 401: (error http 401)")

I don't know why it's failing, but it looks like the word nil is being put into the url where the ID should go. Am I doing something wrong? Or is this an issue for anyone right now?

Add instructions for storing auth info elsewhere?

I keep my ~/.spacemacs file, along with my other dotfiles, on GitHub. I'd prefer not to sign up as a Google developer and then share that secret with the world. As an emacs novice, I don't know how to have emacs source this info from an external file. Could you add instructions for how to do that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.