Remove gmail count from polybar
Signed-off-by: Severin Kaderli <severin@kaderli.dev>
This commit is contained in:
parent
d8fe52b9d7
commit
3e241ede14
4 changed files with 1 additions and 79 deletions
|
@ -43,7 +43,7 @@ module-margin = 2
|
||||||
|
|
||||||
modules-left = i3
|
modules-left = i3
|
||||||
modules-center =
|
modules-center =
|
||||||
modules-right = update gmail battery battery2 volume backlight vpn wlan ethernet date power
|
modules-right = update battery battery2 volume backlight vpn wlan ethernet date power
|
||||||
tray-position = none
|
tray-position = none
|
||||||
separator = |
|
separator = |
|
||||||
|
|
||||||
|
@ -122,20 +122,6 @@ interval = 60
|
||||||
|
|
||||||
click-left = xdg-open "https://www.archlinux.org/"
|
click-left = xdg-open "https://www.archlinux.org/"
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# G-Mail #
|
|
||||||
###############################################################################
|
|
||||||
[module/gmail]
|
|
||||||
type = custom/script
|
|
||||||
exec = ${XDG_CONFIG_HOME}/polybar/scripts/gmail/count.py
|
|
||||||
|
|
||||||
format = <label>
|
|
||||||
label = %output%
|
|
||||||
|
|
||||||
interval = 60
|
|
||||||
|
|
||||||
click-left = xdg-open https://mail.google.com
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Battery indicator #
|
# Battery indicator #
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import os
|
|
||||||
import pathlib
|
|
||||||
import httplib2
|
|
||||||
import webbrowser
|
|
||||||
from oauth2client import client, file
|
|
||||||
|
|
||||||
SCOPE = 'https://www.googleapis.com/auth/gmail.readonly'
|
|
||||||
REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob'
|
|
||||||
DIR = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
CLIENT_SECRETS_PATH = os.path.join(DIR, 'client_secrets.json')
|
|
||||||
CREDENTIALS_PATH = os.path.join(DIR, 'credentials.json')
|
|
||||||
storage = file.Storage(CREDENTIALS_PATH)
|
|
||||||
|
|
||||||
if pathlib.Path(CREDENTIALS_PATH).is_file():
|
|
||||||
credentials = storage.get()
|
|
||||||
credentials.refresh(httplib2.Http())
|
|
||||||
print('Credentials successfully refreshed')
|
|
||||||
else:
|
|
||||||
flow = client.flow_from_clientsecrets(CLIENT_SECRETS_PATH, scope=SCOPE,
|
|
||||||
redirect_uri=REDIRECT_URI)
|
|
||||||
auth_uri = flow.step1_get_authorize_url()
|
|
||||||
webbrowser.open(auth_uri)
|
|
||||||
auth_code = input('Enter the auth code: ')
|
|
||||||
credentials = flow.step2_exchange(auth_code)
|
|
||||||
storage.put(credentials)
|
|
||||||
print('Credentials successfully created')
|
|
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
"installed": {
|
|
||||||
"client_id": "1041679298587-8solnkr9tr8iktrut958if6tsgqt42m2.apps.googleusercontent.com",
|
|
||||||
"project_id": "polybar-gmail",
|
|
||||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
|
||||||
"token_uri": "https://accounts.google.com/o/oauth2/token",
|
|
||||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
|
||||||
"client_secret": "-aZZAslLp6ydldCAFvH9AEwi",
|
|
||||||
"redirect_uris": ["urn:ietf:wg:oauth:2.0:oob"]
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
import pathlib
|
|
||||||
import subprocess
|
|
||||||
import time
|
|
||||||
import argparse
|
|
||||||
from apiclient import discovery, errors
|
|
||||||
from oauth2client import client, file
|
|
||||||
from httplib2 import ServerNotFoundError
|
|
||||||
|
|
||||||
DIR = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
CREDENTIALS_PATH = os.path.join(DIR, 'credentials.json')
|
|
||||||
|
|
||||||
if not os.path.isfile(CREDENTIALS_PATH):
|
|
||||||
print(0)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
gmail = discovery.build(
|
|
||||||
'gmail', 'v1', credentials=file.Storage(CREDENTIALS_PATH).get())
|
|
||||||
labels = gmail.users().labels().get(userId='me', id='INBOX').execute()
|
|
||||||
print(labels['messagesUnread'])
|
|
||||||
except Exception as e:
|
|
||||||
print(0)
|
|
Loading…
Add table
Add a link
Reference in a new issue