(upbeat music)
(clap)
(upbeat music)
- During lockdown one of the issues I've had
with working from home,
which I'm sure a lot of people do,
is the fact that we have to have lots of meetings online
through lots of different video conferencing applications.
And what that means is I'm kind of reliant
on my mobile phone that tells me that I have a notification,
it's a meeting in 10 minutes.
The problem with this is,
what I tend to do with my mobile phone
is I don't like notification sitting around,
so I immediately kind of swipe them off
and I just think, oh yeah, I've got 10 minutes.
I'll just answer a couple of emails.
And it's usually kind of 20 minutes later that I realized,
I get a telephone call saying,
"Why aren't you on the meeting?"
Because that, I just thought it would be quite nice
to write a little sort of GUI application
I can have upon the screen constantly,
all the time that has a big visual change
and some audible output to say
a notification application, if you like.
So I've got my calendar in Google,
in my Google calendar.
Google have an API,
which they have like a Python bindings
for Python library to access their API.
So I just thought it would be quite nice
to write it through Python.
And I'm using the GTK Python bindings again for GTK library.
It was quite simple to create
and I'm just gonna go through,
show you how to install it and use it.
And then I'll have a little point through
the code to show you kind of how I've done it as well.
Okay.
So what I've got here is a raspberry PI
with the kind of audio, just normal analog audio
connected into a little electric speaker.
If you've got speakers in your TV or in monitor,
then you don't need that,
but this monitor doesn't have any speakers.
So I've got a standard Raspberry Pi OS,
running the 32-bit Raspberry Pi OS.
So what I can do is open a terminal on here.
And then the first thing I gotta do
is clone the code from GitHub.
So we do git clone HTTPS,
github.com, slash, ghollingworth, slash, NextEvent.
There we go.
So I've pulled out the data to download it
from my GitHub account.
And if you go into NextEvent and have a look in there
there's a bunch of files.
There are two Python files.
One's called NextEvent.
The other one's called Google Cow.
NextEvent is the bit that has most
of the kind of handling of the events
and the the window control, the GUI control.
The Google Cal part of it is just something
that does the Google API part of it and kind of simplifies
the connection between that and the NextEvent.
There's also installed dot sh,
and that is used to install
the dependencies required for this.
So if you have a look at it,
you'll see there's a bunch of Python libraries that I need.
So it's dateutil, there's a GI cairo,
which is the GTK bindings.
And then you've got the Google APIs,
the API libraries as well.
So if you just run that.
So dot slash install.
We'll install those libraries.
I've actually already installed them
so this will just run through
and say everything's already there.
Okay, so that's there.
I can now start NextEvent.
So if I go Python three,
it's important to run using Python three, NextEvent dot py.
Okay, so pops open a window and then it opens Chromium.
So what's happening here is my application
is requesting access to your data, to your calendar.
So if you run this code, it will do this,
and it will ask you for access to your code.
The way this works is,
there's a token that NextEvent has.
It passes that token to Google.
That identifies the application as being NextEvent.
That's how it knows it's called NextEvent.
So it passes that token to Google.
Google will then go through this process
of just checking that you're okay with that.
So you may have to log in here and put your password in
and approve that to say yes,
NextEvent is allowed access to my data.
Google then passes back to the application,
what is called an API token.
That API token then identifies your connection to Google
and to your data.
So using that API token for a short period of time,
'cause Google always only give you API tokens
for short periods of time,
you can then access the data.
And the idea, the kind of the complexity here
is all about making sure that when somebody comes
to access your data you don't just give them everything.
They don't request everything.
They only request the things they need.
So here it says I need to choose an account.
So here's the account that I'm going to log in.
So if it comes up here with a little warning,
this is because Google hasn't verified my app.
Fair enough.
And so you have to go advanced here
and then say yes that's fine.
Go to the NextEvent.
So what it does is it says,
okay, should I grant permissions to do this?
Let's say yes, I'm going to allow that.
And then it just says, right,
you are allowing NextEvent to view your calendar.
So that's the only thing that it's asking to be able to do.
So you say, yeah, okay, I'm going to allow that.
And there you go.
So now what we have is,
my NextEvent application has now been able
to load up all of my events
that I've got coming up in the next four events
that I've got coming up in the next day or so.
And as you can see right now,
I got in two minutes time a super secret meeting RE: sharks.
So what actually happens here, in the code,
each item goes through a number of different states.
Like with these ones,
they are more than five minutes away.
So they're in like a state, which just says,
we don't really care about them.
We're just gonna draw the line this.
Whereas this one is now less than five minutes away.
So it goes into a state where,
when it changes into that state, it dings.
When it started up, it did the ding.
And then as it switches down from two minutes down
to one minute, it'll do two dings.
And then when it's in progress,
so in other words at the actual time
that your meeting is starting,
then it will do four dings.
(flute sounds)
(dinging)
When one minute passes you get two dings.
(piano sounds)
(dinging)
And then when it gets into progress,
then you get the four dings
and you know you should join your conference call.
And that's it.
(upbeat music)