Add conkys and wallpapers

This commit is contained in:
kuben
2019-11-03 15:04:22 +01:00
parent a58cdb6355
commit 86764734fd
57 changed files with 1669 additions and 0 deletions

42
.conky/scripts/.passwords.json Executable file
View File

@@ -0,0 +1,42 @@
{
"gmail":
{
"username":"jakub.fojt96@gmail.com",
"password":"donotforget"
},
"github":
{
"username": "kuben",
"password": "githubpassword",
"fav_repos" : ["madhur.github.com", "portablejekyll", "GAnalytics", "wunder-java", "msysgit-2.0.0"]
},
"feedly":
{
"access_token": "feedly_access_token",
"access_code" : "feedly_access_code",
"refresh_token" : "feedly_refresh_token"
},
"twitter":
{
"key": "xxxxxxxx",
"secret":"xxxxxxxx",
"access_token": "xxxxxxxx",
"user": "your twitter screen name"
},
"pocket":
{
"key": "xxxxx",
"request_token":"xxxxxx",
"access_token" : "xxxxxxx"
},
"so" :
{
"userid":"stackoverflow_user_id"
},
"weather":
{
"location_code":"SWXX0043"
}
}

10
.conky/scripts/disk.sh Executable file
View File

@@ -0,0 +1,10 @@
cat /proc/mounts | awk '{ if ( $1 ~ /\/dev/ )
{
num_elem = split($2,str_array,"/")
if (str_array[num_elem] == "")
{
str_array[num_elem] = "/";
}
printf "%5.5s: ${fs_free %s} / ${fs_size %s}\n${fs_bar 6 %s}\n", str_array[num_elem], $2, $2, $2
}
}'

17
.conky/scripts/facebook.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
msgcount=$(fbcmd NOTIFY | grep MESSAGES_UNREAD | grep -oE "[[:digit:]]{1,}")
notifycount=$(fbcmd NOTICES unread | grep -c :title)
friendcount=$(fbcmd NOTIFY | grep FRIEND_REQUESTS | grep -oE "[[:digit:]]{1,}")
currenttime=$(date +%I:%M)
if [[ "$msgcount" -eq "0" ]] && [[ "$notifycount" -eq "0" ]] && [[ "$friendcount" -eq "0" ]]
then
echo '${color}No new updates ${alignr}Updated: ${color white}'$currenttime
else
echo '${color white}'$msgcount'${color aaaaaa} NEW MESSAGE(S) ${alignr}Updated: ${color white}'$currenttime
echo '${color white}'$notifycount'${color aaaaaa} NEW NOTIFICATION(S)'
echo '${color white}'$friendcount'${color aaaaaa} NEW Friend Request(s)'
fi

71
.conky/scripts/feed_read.py Executable file
View File

@@ -0,0 +1,71 @@
#!/usr/bin/env python
from feedly import FeedlyClient
import json
from subprocess import call
from os.path import expanduser
import time
#Categories to ignore, you can add yours
ignored=["global.all", "global.must", "global.uncategorized", "Security", "Ignore", "GMAT", "sharepoint", "madhur"]
FEEDLY_REDIRECT_URI = "http://localhost"
def get_feedly_client(token=None):
if token:
return FeedlyClient(token=token, sandbox=False)
else:
return FeedlyClient(
client_id=FEEDLY_CLIENT_ID,
client_secret=FEEDLY_CLIENT_SECRET,
sandbox=False
)
def auth(request):
feedly = get_feedly_client()
# Redirect the user to the feedly authorization URL to get user code
code_url = feedly.get_code_url(FEEDLY_REDIRECT_URI)
return redirect(code_url)
def callback(request):
code=request.GET.get('code','')
if not code:
return HttpResponse('The authentication is failed.')
feedly = get_feedly_client()
#response of access token
res_access_token = feedly.get_access_token(FEEDLY_REDIRECT_URI, code)
# user id
if 'errorCode' in res_access_token.keys():
return HttpResponse('The authentication is failed.')
id = res_access_token['id']
access_token=res_access_token['access_token']
def feed(access_token):
'''get user's subscription'''
feedly = get_feedly_client()
user_subscriptions = feedly.get_user_subscriptions(access_token)
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
data = json.load(json_data)
access_token=data['feedly']['access_token']
client = get_feedly_client(access_token)
categories = client.get_user_categories(access_token)
counts = client.get_unread_count(access_token)
text=""
count=0
for item in counts['unreadcounts']:
itemcount = item['count']
itemname = item['id'][51:]
if(itemcount > 0 and itemname not in ignored and "user/23bbb2c4-62b9-4bb9-a756-556cef1512f9/category/" in item['id']):
count = count + itemcount
text=text + "${color1}%s${alignr}${color white} %d" %(itemname, itemcount) +"\n"
print "${color1}Total unread: ${color white}%s ${alignr}${color1}Updated: ${color white}%s" %(count, time.strftime("%I:%M"))
print text
#call(['notify-send','Feedly Updated'])

123
.conky/scripts/feedly.py Executable file
View File

@@ -0,0 +1,123 @@
#!/usr/bin/env python
import requests
import json
class FeedlyClient(object):
def __init__(self, **options):
self.client_id = options.get('client_id')
self.client_secret = options.get('client_secret')
self.sandbox = options.get('sandbox', True)
if self.sandbox:
default_service_host = 'sandbox.feedly.com'
else:
default_service_host = 'cloud.feedly.com'
self.service_host = options.get('service_host', default_service_host)
self.additional_headers = options.get('additional_headers', {})
self.token = options.get('token')
self.secret = options.get('secret')
def get_code_url(self, callback_url):
scope = 'https://cloud.feedly.com/subscriptions'
response_type = 'code'
request_url = '%s?client_id=%s&redirect_uri=%s&scope=%s&response_type=%s' % (
self._get_endpoint('v3/auth/auth'),
self.client_id,
callback_url,
scope,
response_type
)
return request_url
def get_access_token(self,redirect_uri,code):
params = dict(
client_id=self.client_id,
client_secret=self.client_secret,
grant_type='authorization_code',
redirect_uri=redirect_uri,
code=code
)
quest_url=self._get_endpoint('v3/auth/token')
res = requests.post(url=quest_url, params=params)
return res.json()
def refresh_access_token(self,refresh_token):
'''obtain a new access token by sending a refresh token to the feedly Authorization server'''
params = dict(
refresh_token=refresh_token,
client_id=self.client_id,
client_secret=self.client_secret,
grant_type='refresh_token',
)
quest_url=self._get_endpoint('v3/auth/token')
res = requests.post(url=quest_url, params=params)
return res.json()
def get_user_subscriptions(self,access_token):
'''return list of user subscriptions'''
headers = {'Authorization': 'OAuth '+access_token}
quest_url=self._get_endpoint('v3/subscriptions')
res = requests.get(url=quest_url, headers=headers)
return res.json()
def get_user_categories(self,access_token):
'''return list of user subscriptions'''
headers = {'Authorization': 'OAuth '+access_token}
quest_url=self._get_endpoint('v3/categories')
res = requests.get(url=quest_url, headers=headers)
return res.json()
def get_unread_count(self,access_token):
'''return list of user subscriptions'''
headers = {'Authorization': 'OAuth '+access_token}
quest_url=self._get_endpoint('v3/markers/counts')
res = requests.get(url=quest_url, headers=headers)
return res.json()
def get_feed_content(self,access_token,streamId,unreadOnly,newerThan):
'''return contents of a feed'''
headers = {'Authorization': 'OAuth '+access_token}
quest_url=self._get_endpoint('v3/streams/contents')
params = dict(
streamId=streamId,
unreadOnly=unreadOnly,
newerThan=newerThan
)
res = requests.get(url=quest_url, params=params,headers=headers)
return res.json()
def mark_article_read(self, access_token, entryIds):
'''Mark one or multiple articles as read'''
headers = {'content-type': 'application/json',
'Authorization': 'OAuth ' + access_token
}
quest_url = self._get_endpoint('v3/markers')
params = dict(
action="markAsRead",
type="entries",
entryIds=entryIds,
)
res = requests.post(url=quest_url, data=json.dumps(params), headers=headers)
return res
def save_for_later(self, access_token, user_id, entryIds):
'''saved for later.entryIds is a list for entry id.'''
headers = {'content-type': 'application/json',
'Authorization': 'OAuth ' + access_token
}
request_url = self._get_endpoint('v3/tags') + '/user%2F' + user_id + '%2Ftag%2Fglobal.saved'
params = dict(
entryIds=entryIds
)
res = requests.put(url=request_url, data=json.dumps(params), headers=headers)
return res
def _get_endpoint(self, path=None):
url = "https://%s" % (self.service_host)
if path is not None:
url += "/%s" % path
return url

42
.conky/scripts/github.py Executable file
View File

@@ -0,0 +1,42 @@
#! /usr/bin/env python
import urllib2
import json
import zlib
import base64
from subprocess import call
from os.path import expanduser
import time
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
data = json.load(json_data)
username=data['github']['username']
password=data['github']['password']
#Put repos to publish
repos = data['github']['fav_repos']
request = urllib2.Request("https://api.github.com/users/" + username)
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
j = urllib2.urlopen(request)
json_data = j.read()
j_obj = json.loads(json_data)
print "${color1}Followers: ${color white}%d ${alignr}${color1}Updated: ${color white}%s" %(j_obj['followers'], time.strftime("%I:%M"))
for repo in repos:
repourl = "https://api.github.com/repos/"+ username +"/" + repo
request = urllib2.Request(repourl)
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
j = urllib2.urlopen(request)
json_data = j.read()
j_obj = json.loads(json_data)
print "${color white}%s ${goto 200}${color1}Starred: ${color white}%d ${color1}${alignr}Forks: ${color white}%d" %(j_obj['name'], j_obj['stargazers_count'], j_obj['forks_count'])

70
.conky/scripts/gmail.py Executable file
View File

@@ -0,0 +1,70 @@
#! /usr/bin/env python3
import urllib.request
import urllib # For BasicHTTPAuthentication
import feedparser # For parsing the feed
from textwrap import wrap # For pretty printing assistance
import json
from os.path import expanduser
import sys
import time
_URL = "https://mail.google.com/gmail/feed/atom/unread"
WRAP_LIMIT = 50
def auth():
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
data = json.load(json_data)
username=data['gmail']['username']
password=data['gmail']['password']
auth_handler = urllib.request.HTTPBasicAuthHandler()
auth_handler.add_password(realm='New mail feed',
uri='https://mail.google.com/',
user= username,
passwd= password)
opener = urllib.request.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
urllib.request.install_opener(opener)
'''The method to do HTTPBasicAuthentication'''
f = opener.open(_URL)
feed = f.read()
return feed
def fill(text, width):
'''A custom method to assist in pretty printing'''
if len(text) < width:
return text + ' '*(width-len(text))
else:
return text
def readmail(feed):
'''Parse the Atom feed and print a summary'''
atom = feedparser.parse(feed)
print ("${color white}You have %s new mails${color} ${alignr}Updated: ${color white}%s" % ((len(atom.entries)), time.strftime("%I:%M")))
for i in range(len(atom.entries)):
if(i>10):
break
if(len(atom.entries[i].title) > WRAP_LIMIT):
#print ("%s" % (fill(wrap(atom.entries[i].title, 50)[0]+" ...", 55)))
print ("${color1}%s" % (wrap(atom.entries[i].title, WRAP_LIMIT)[0]+" ..."))
else:
print ("${color1}%s" % (wrap(atom.entries[i].title, WRAP_LIMIT)[0]))
def countmail(feed):
'''Parse the Atom feed and print a summary'''
atom = feedparser.parse(feed)
print ("Emails: %s new" %len(atom.entries))
if __name__ == "__main__":
f = auth() # Do auth and then get the feed
if(len(sys.argv) > 1):
countmail(f)
else:
readmail(f) # Let the feed be chewed by feedparse

26
.conky/scripts/pocket.py Executable file
View File

@@ -0,0 +1,26 @@
#! /usr/bin/env python
import urllib2
import urllib
import json
from subprocess import call
from os.path import expanduser
import time
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
data = json.load(json_data)
key=data['pocket']['key']
access_token=data['pocket']['access_token']
data = {'consumer_key': key, 'access_token': access_token}
data = urllib.urlencode(data)
request = urllib2.Request("https://getpocket.com/v3/stats")
j = urllib2.urlopen(request, data)
json_data = j.read()
j_obj = json.loads(json_data)
print "${color1}Pocket Unread: ${alignr}${color white}%d" %(j_obj['count_unread'])

31
.conky/scripts/so.py Executable file
View File

@@ -0,0 +1,31 @@
#! /usr/bin/env python
import urllib2
import json
import zlib
from subprocess import call
import sys
import time
from os.path import expanduser
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
data = json.load(json_data)
userid=data['so']['userid']
so = 'https://api.stackexchange.com/2.2/users/'+userid+'?order=desc&sort=reputation&site=stackoverflow'
j = urllib2.urlopen(so)
json_data = j.read()
if j.info()['Content-Encoding'] == 'gzip':
json_data = zlib.decompress(json_data, zlib.MAX_WBITS + 16)
j_obj = json.loads(json_data)
if(len(sys.argv) > 1):
print "%s: %s" %("Reputation", j_obj['items'][0]['reputation'])
else:
print "${color}%s: ${alignr}${color white} %s" %("Stackoverflow Reputation", j_obj['items'][0]['reputation'])
print " ${color}%s: ${alignr}${color white} %s" %("Month", j_obj['items'][0]['reputation_change_month'])
print " ${color}%s: ${alignr}${color white} %s" %("Week", j_obj['items'][0]['reputation_change_week'])
print " ${color}%s: ${alignr}${color white} %s" %("Day", j_obj['items'][0]['reputation_change_day'])
#call(['notify-send','Conky Updated'])

24
.conky/scripts/twitter.py Executable file
View File

@@ -0,0 +1,24 @@
#! /usr/bin/env python
import urllib2
import json
import zlib
import base64
from subprocess import call
from os.path import expanduser
json_data=open(expanduser('~')+'/.conky/scripts/.passwords.json')
data = json.load(json_data)
access_token=data['twitter']['access_token']
user = data['twitter']['user']
request = urllib2.Request("https://api.twitter.com/1.1/users/show.json?screen_name=" + user)
bearer_value = 'Bearer %s' % access_token
request.add_header("Authorization", bearer_value)
j = urllib2.urlopen(request)
json_data = j.read()
j_obj = json.loads(json_data)
print "${color1}Twitter Followers: ${alignr}${color white}%d" %(j_obj['followers_count'])