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

View File

@@ -0,0 +1,53 @@
conky.config = {
use_spacer='none',
use_xft=true,
font='Open Sans Light:size=11',
text_buffer_size=2048,
update_interval=3600.0,
total_run_times=0,
own_window=true,
own_window_transparent=true,
own_window_type='normal',
own_window_hints='undecorated,skip_taskbar,skip_pager',
own_window_class='Conky-weather',
own_window_argb_visual=true,
own_window_argb_value=0,
draw_shades=false,
draw_outline=false,
draw_borders=false,
stippled_borders=0,
double_buffer=true,
draw_blended=false,
default_color='white',
default_shade_color='black',
--Minimum size of text area
maximum_width=1200 ,
alignment=bottom_right,
gap_x=20,
gap_y=20,
border_inner_margin=15,
border_outer_margin=0,
no_buffers=true,
net_avg_samples=2,
override_utf8_locale=true,
use_spacer=none,
short_units=on,
default_color=white,
color1 = 'ffffff',
color7 = '333333'
-- default_outline_color='black',--'00ccee',
-- lua_load = '~/.conky/arch/lua.lua'
};
conky.text = [[
${execp ~/.conky/weather/weather.py 890869}
]];

View File

@@ -0,0 +1,53 @@
conky.config = {
use_spacer='none',
use_xft=true,
font='Open Sans Light:size=11',
text_buffer_size=2048,
update_interval=3600.0,
total_run_times=0,
own_window=true,
own_window_transparent=true,
own_window_type='normal',
own_window_hints='undecorated,skip_taskbar,skip_pager',
own_window_class='Conky-weather',
own_window_argb_visual=true,
own_window_argb_value=0,
draw_shades=false,
draw_outline=false,
draw_borders=false,
stippled_borders=0,
double_buffer=true,
draw_blended=false,
default_color='white',
default_shade_color='black',
--Minimum size of text area
maximum_width=1200 ,
alignment=bottom_right,
gap_x=20,
gap_y=20,
border_inner_margin=15,
border_outer_margin=0,
no_buffers=true,
net_avg_samples=2,
override_utf8_locale=true,
use_spacer=none,
short_units=on,
default_color=white,
color1 = 'ffffff',
color7 = '333333'
-- default_outline_color='black',--'00ccee',
-- lua_load = '~/.conky/arch/lua.lua'
};
conky.text = [[
${execp ~/.conky/weather/weather.py 909319}
]];

View File

@@ -0,0 +1 @@
{"timestamp": "1546242922", "location": {"city": "Gothenburg", "country": "Sweden", "region": " Vastra Gotaland"}, "wind": {"chill": "25", "direction": "165", "speed": "27.36"}, "atmosphere": {"humidity": "93", "pressure": "34473.45", "rising": "0", "visibility": "20.28"}, "astronomy": {"sunrise": "8:56 am", "sunset": "3:36 pm"}, "lat": "57.701328", "long": "11.96689", "condition": {"code": "26", "date": "Mon, 31 Dec 2018 08:00 AM CET", "temp": "0", "text": "Cloudy"}, "forecast": [{"code": "26", "date": "31 Dec 2018", "day": "Mon", "high": "7", "low": "-1", "text": "Cloudy"}, {"code": "24", "date": "01 Jan 2019", "day": "Tue", "high": "7", "low": "3", "text": "Windy"}, {"code": "32", "date": "02 Jan 2019", "day": "Wed", "high": "2", "low": "0", "text": "Sunny"}, {"code": "30", "date": "03 Jan 2019", "day": "Thu", "high": "1", "low": "-2", "text": "Partly Cloudy"}, {"code": "28", "date": "04 Jan 2019", "day": "Fri", "high": "6", "low": "0", "text": "Mostly Cloudy"}, {"code": "30", "date": "05 Jan 2019", "day": "Sat", "high": "4", "low": "0", "text": "Partly Cloudy"}, {"code": "28", "date": "06 Jan 2019", "day": "Sun", "high": "5", "low": "0", "text": "Mostly Cloudy"}, {"code": "30", "date": "07 Jan 2019", "day": "Mon", "high": "5", "low": "2", "text": "Partly Cloudy"}, {"code": "30", "date": "08 Jan 2019", "day": "Tue", "high": "3", "low": "0", "text": "Partly Cloudy"}, {"code": "30", "date": "09 Jan 2019", "day": "Wed", "high": "3", "low": "0", "text": "Partly Cloudy"}]}

View File

@@ -0,0 +1 @@
{"timestamp": "1546242922", "location": {"city": "Vasteras", "country": "Sweden", "region": " Vastmanland"}, "wind": {"chill": "19", "direction": "190", "speed": "16.09"}, "atmosphere": {"humidity": "100", "pressure": "34541.18", "rising": "0", "visibility": "7.24"}, "astronomy": {"sunrise": "8:53 am", "sunset": "3:2 pm"}, "lat": "59.61998", "long": "16.53591", "condition": {"code": "26", "date": "Mon, 31 Dec 2018 08:00 AM CET", "temp": "-3", "text": "Cloudy"}, "forecast": [{"code": "28", "date": "31 Dec 2018", "day": "Mon", "high": "4", "low": "-3", "text": "Mostly Cloudy"}, {"code": "28", "date": "01 Jan 2019", "day": "Tue", "high": "6", "low": "0", "text": "Mostly Cloudy"}, {"code": "23", "date": "02 Jan 2019", "day": "Wed", "high": "0", "low": "-3", "text": "Breezy"}, {"code": "30", "date": "03 Jan 2019", "day": "Thu", "high": "-2", "low": "-5", "text": "Partly Cloudy"}, {"code": "28", "date": "04 Jan 2019", "day": "Fri", "high": "2", "low": "-3", "text": "Mostly Cloudy"}, {"code": "30", "date": "05 Jan 2019", "day": "Sat", "high": "3", "low": "-1", "text": "Partly Cloudy"}, {"code": "28", "date": "06 Jan 2019", "day": "Sun", "high": "1", "low": "-1", "text": "Mostly Cloudy"}, {"code": "28", "date": "07 Jan 2019", "day": "Mon", "high": "1", "low": "0", "text": "Mostly Cloudy"}, {"code": "30", "date": "08 Jan 2019", "day": "Tue", "high": "0", "low": "-3", "text": "Partly Cloudy"}, {"code": "30", "date": "09 Jan 2019", "day": "Wed", "high": "-1", "low": "-3", "text": "Partly Cloudy"}]}

84
.conky/weather/weather.py Executable file
View File

@@ -0,0 +1,84 @@
#! /usr/bin/env python3
import urllib
import json
#from subprocess import call
import sys
import time
import os.path
import urllib.parse
import urllib.request
#import time
woeid=sys.argv[1]
path="/home/kuba/.conky/weather/last-"+woeid+".json"
#Try to download new data; overwrite existing file
def fetch_data():
base_url = "https://query.yahooapis.com/v1/public/yql"
sel_url = "?q=select%20location,wind,atmosphere,astronomy,item%20from%20weather.forecast"
where_url = "%20where%20u='c'%20and%20woeid%20=%20" + woeid
format_url = "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"
yql_url = base_url + sel_url + where_url + format_url
try:
result = urllib.request.urlopen(yql_url).read()
data = json.loads(result)
ch = data['query']['results']['channel']
timestamp = str(round(time.time()))
parsed_data = {}#Don't save everything
parsed_data['timestamp'] = timestamp
for s in ['location', 'wind', 'atmosphere', 'astronomy']:
parsed_data.update({s : ch[s]})
for s in ['lat','long','condition','forecast']:
parsed_data.update({s : ch['item'][s]})
with open(path, 'w') as outfile:
json.dump(parsed_data, outfile)
except urllib.error.URLError:
pass
return
def print_output(data):
timestamp = int(data['timestamp'])
city = data['location']['city']
country = data['location']['country']
current_condition = data['condition']['text']
current_code = data['condition']['code']
current_temp = data['condition']['temp']
#weather_date = data['condition']['date']
speed_unit = "km/h"
speed = data['wind']['speed']
humidity = data['atmosphere']['humidity']
forecast = []
for forec in data['forecast']:
forecast.append((forec['day'], forec['low'], forec['high'] , forec['code']))
print ("${font Open Sans:size=15:style=Light}%s, %s " % (city, country), end = '')
print ("${font :size=6}${alignr}${color7}Updated: ${color white}%s ${color7}Fetched: ${color white}%s" % (time.strftime("%I:%M"), time.strftime("%m/%d %H:%M", time.gmtime(timestamp))))
print ("${color7}${hr}${color}")
print ("${voffset -5}${font Open Sans:size=60:style=Light}%s°${font}" %(current_temp))
print ("${offset 250}${voffset -65}%s" %(current_condition))
print ("${image ~/.conky/.conky-google-now/%s.png -p 180,45 -s 60x60}" %(current_code))
print ("${image ~/.conky/.conky-google-now/wind.png -p 245,62 -s 15x15}${goto 35}${offset 250}${voffset -12}%s %s" %(speed, speed_unit), end = '')
print ("${goto 400}%s ${goto 530} %s" %(forecast[0][0].upper(), forecast[1][0].upper()))
print ("${image ~/.conky/.conky-google-now/humidity.png -p 245,81 -s 15x15}${goto 35}${offset 250}%s %s" %(humidity,"%"), end = '')
print ("${goto 400}%s°${color6}%s°${color}${goto 530}%s°${color6}%s°${color}${voffset 15}" %(forecast[0][2], forecast[0][1], forecast[1][2], forecast[1][1]))
print ("${image ~/.conky/.conky-google-now/%s.png -p 440,65 -s 30x30}${image ~/.conky/.conky-google-now/%s.png -p 570,65 -s 30x30}${voffset -10}" %(forecast[0][3], forecast[1][3]))
return
#Open existing file and check if it's not too old
if not (os.path.isfile(path)):
fetch_data()
with open(path) as infile:
data = json.load(infile)
ts = int(data['timestamp'])
now = round(time.time())
if (ts + 3600 < now):
fetch_data()
ts = now
print_output(data)