Update for Gnome Shell 45+
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import os.path
|
||||
import json
|
||||
|
||||
from google.auth.transport.requests import Request
|
||||
from google.oauth2.credentials import Credentials
|
||||
@@ -37,7 +38,7 @@ creds = None
|
||||
def _initCreds():
|
||||
global creds
|
||||
if creds: return
|
||||
|
||||
|
||||
# The file token.json stores the user's access and refresh tokens, and is
|
||||
# created automatically when the authorization flow completes for the first
|
||||
# time.
|
||||
@@ -53,15 +54,21 @@ def _initCreds():
|
||||
creds = flow.run_local_server(port=0)
|
||||
# Save the credentials for the next run
|
||||
with open('token.json', 'w') as token:
|
||||
token.write(creds.to_json())
|
||||
|
||||
data = {}
|
||||
data['refresh_token'] = creds.refresh_token
|
||||
data['client_id'] = creds.client_id
|
||||
data['client_secret'] = creds.client_secret
|
||||
data['token_uri'] = creds.token_uri
|
||||
data['id_token'] = creds.id_token
|
||||
token.write(json.dumps(data))
|
||||
|
||||
def getUnreadMails():
|
||||
"""
|
||||
Get number of unread threads (that may contain multiple messages)
|
||||
"""
|
||||
|
||||
_initCreds()
|
||||
|
||||
|
||||
service = build('gmail', 'v1', credentials=creds)
|
||||
pageToken = ''
|
||||
threads = set()
|
||||
@@ -69,6 +76,7 @@ def getUnreadMails():
|
||||
results = service.users().messages().list(userId='me', labelIds=['UNREAD'],\
|
||||
includeSpamTrash=False, pageToken=pageToken)\
|
||||
.execute()
|
||||
if not 'messages' in results.keys(): continue
|
||||
threads = threads.union(set([k['threadId'] for k in results['messages']]))
|
||||
# Loop over all result pages (100 results per page by default)
|
||||
pageToken = results.get('nextPageToken', '')
|
||||
|
||||
@@ -43,15 +43,12 @@ class PicturePopup(GenericMonitor):
|
||||
self.runMainLoop()
|
||||
|
||||
def display_next_img(self):
|
||||
filedata = urllib.request.urlopen('https://source.unsplash.com/random')
|
||||
# Get redirected URL without parameters
|
||||
url = filedata.url.split('?')[0]
|
||||
filedata = urllib.request.urlopen(url + '?fit=max&width=500&height=500')
|
||||
filedata = urllib.request.urlopen('https://picsum.photos/500/500')
|
||||
datatowrite = filedata.read()
|
||||
with open('/tmp/cat2.jpg', 'wb') as f:
|
||||
f.write(datatowrite)
|
||||
widget = GenericMonitorTextWidget('#%d' % self.imgs_idx, 'color:purple')
|
||||
url_widget = GenericMonitorTextWidget(url, 'color:white;font-weight:bold', signals={'on-click':'signal'}) # No name here
|
||||
url_widget = GenericMonitorTextWidget('random_pic', 'color:white;font-weight:bold', signals={'on-click':'signal'}) # No name here
|
||||
picture_widget = GenericMonitorPictureWidget('/tmp/cat2.jpg', name='NestedWidget', signals={'on-click':'signal'})
|
||||
popup = GenericMonitorPopup([url_widget, picture_widget])
|
||||
signals = {
|
||||
|
||||
Reference in New Issue
Block a user