1
0
Fork 0
mirror of https://github.com/lcpz/awesome-copycats.git synced 2024-10-22 12:31:23 +00:00

perceptive forked

This commit is contained in:
luke bonham 2013-03-31 17:39:26 +02:00
parent 93d30bc718
commit 1b55f9efe8
54 changed files with 17 additions and 304 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
rc.lua rc.lua
perceptive/

View file

@ -74,7 +74,6 @@ confdir = home .. "/.config/awesome"
scriptdir = confdir .. "/script/" scriptdir = confdir .. "/script/"
themes = confdir .. "/themes" themes = confdir .. "/themes"
active_theme = themes .. "/blackburn" active_theme = themes .. "/blackburn"
weather_icons = active_theme .. "/icons/weather/"
beautiful.init(active_theme .. "/theme.lua") beautiful.init(active_theme .. "/theme.lua")
@ -147,6 +146,7 @@ mygames = {
} }
mygraphics = { mygraphics = {
{ "gimp" , "gimp" }, { "gimp" , "gimp" },
{ "nathive" , "nathive" },
{ "dia", "dia" }, { "dia", "dia" },
{ "image viewer" , "viewnior" } { "image viewer" , "viewnior" }
} }
@ -287,7 +287,7 @@ function show(inc_offset)
}) })
end end
function add_calendar(t_out) function show_calendar(t_out)
remove_calendar() remove_calendar()
local char_width = char_width or calculate_char_width() local char_width = char_width or calculate_char_width()
local header, cal_text = create_calendar() local header, cal_text = create_calendar()
@ -355,15 +355,10 @@ function(widget, args)
end end
end, 1) end, 1)
-- MEM widget -- Mem widget
memwidget = wibox.widget.textbox() memwidget = wibox.widget.textbox()
vicious.register(memwidget, vicious.widgets.mem, gray .. "Mem " .. coldef .. white .. "$2 " .. coldef, 13) -- in Megabytes vicious.register(memwidget, vicious.widgets.mem, gray .. "Mem " .. coldef .. white .. "$2 " .. coldef, 13) -- in Megabytes
-- CPU widget
cpuwidget = wibox.widget.textbox()
vicious.register(cpuwidget, vicious.widgets.cpu, gray .. "Cpu " .. coldef .. white .. "$1 " .. coldef, 3)
cpuwidget:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn(tasks, false) end)))
-- Temp widget -- Temp widget
tempwidget = wibox.widget.textbox() tempwidget = wibox.widget.textbox()
vicious.register(tempwidget, vicious.widgets.thermal, gray .. "Temp " .. coldef .. white .. "$1 " .. coldef, 9, {"coretemp.0", "core"} ) vicious.register(tempwidget, vicious.widgets.thermal, gray .. "Temp " .. coldef .. white .. "$1 " .. coldef, 9, {"coretemp.0", "core"} )
@ -398,7 +393,7 @@ function remove_info()
end end
end end
function add_info(t_out) function show_info(t_out)
remove_info() remove_info()
local capi = { local capi = {
mouse = mouse, mouse = mouse,
@ -417,7 +412,7 @@ function add_info(t_out)
}) })
end end
fshwidget:connect_signal('mouse::enter', function () add_info(0) end) fshwidget:connect_signal('mouse::enter', function () show_info(0) end)
fshwidget:connect_signal('mouse::leave', function () remove_info() end) fshwidget:connect_signal('mouse::leave', function () remove_info() end)
-- Battery widget -- Battery widget
@ -507,153 +502,8 @@ end, 10)
netwidget:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn_with_shell(wifi) end))) netwidget:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn_with_shell(wifi) end)))
-- Weather widget -- Weather widget
weathericon = wibox.widget.imagebox() require("perceptive")
weathericon:set_image(beautiful.widget_weather_0) perceptive.register(1234567) -- replace with your city WOEID code
weatherwidget = wibox.widget.textbox()
sky = ""
vicious.register(weatherwidget, vicious.widgets.weather,
function (widget, args)
if args["{tempf}"] == "N/A" or args["{sky}"] == "N/A"
then
weathericon:set_image(beautiful.widget_weather_na)
sky = "na"
return ' '
else
-- very long work in progress
if os.date("%H") >= "6" and os.date("%H") <= "18"
then
if args["{sky}"] == "Cloudy" then
weathericon:set_image(beautiful.widget_weather_28)
sky = "28"
elseif args["{sky}"] == "Partly Cloudy" then
weathericon:set_image(beautiful.widget_weather_30)
sky = "30"
elseif args["{sky}"] == "Mostly Cloudy" then
weathericon:set_image(beautiful.widget_weather_26)
sky = "26"
else
weathericon:set_image(beautiful_widget_weather_na)
sky = "na"
end
else
if args["{sky}"] == "Cloudy" then
weathericon:set_image(beautiful.widget_weather_27)
sky = "27"
elseif args["{sky}"] == "Partly Cloudy" then
weathericon:set_image(beautiful.widget_weather_29)
sky = "29"
elseif args["{sky}"] == "Mostly Cloudy" then
weathericon:set_image(beautiful.widget_weather_26)
sky = "26"
else
weathericon:set_image(beautiful_widget_weather_na)
sky = "na"
end
end
return " " .. white .. args["{tempc}"] .. " " .. coldef
end
end, 600, "ICAO-CODE-GOES-HERE" )
-- attached notification
local timer = timer
local io = require("io")
local debug = require("debug")
local string = string
local print = print
local script_path = scriptdir .. 'weather'
local script_cmd = script_path .. ' --id='
local tmpfile = '/tmp/.awesome.weather'
local weather_data = ""
local notification = nil
local pattern = '%a.+'
local city_id = nil
function execute(cmd, output, callback)
-- Executes command line, writes its output to temporary file,
-- and runs the callback with output as an argument.
local cmdline = cmd .. " &> " .. output .. " & "
io.popen(cmdline):close()
local execute_timer = timer({ timeout = 7 })
execute_timer:connect_signal("timeout", function()
execute_timer:stop()
local f = io.open(output)
callback(f:read("*all"))
f:close()
end)
execute_timer:start()
end
function fetch_weather()
execute(script_cmd .. city_id, tmpfile, function(text)
old_weather_data = weather_data
weather_data = string.gsub(text, "[\n]$", "")
-- Italian localization (work in progress)
-- can be used as a stub for other localizations
weather_data = string.gsub(weather_data, "Now", "Ora")
weather_data = string.gsub(weather_data, "Sun", "Dom")
weather_data = string.gsub(weather_data, "Mon", "Lun")
weather_data = string.gsub(weather_data, "Tue", "Mar")
weather_data = string.gsub(weather_data, "Wed", "Mer")
weather_data = string.gsub(weather_data, "Thu", "Gio")
weather_data = string.gsub(weather_data, "Fri", "Ven")
weather_data = string.gsub(weather_data, "Sat", "Sab")
weather_data = string.gsub(weather_data, "Sat", "Sab")
weather_data = string.gsub(weather_data, "Partly", "Parzialmente")
weather_data = string.gsub(weather_data, "Mostly", "Molto")
weather_data = string.gsub(weather_data, "Cloudy", "Nuvoloso")
weather_data = string.gsub(weather_data, "Showers", "Piogge")
weather_data = string.gsub(weather_data, "Rain", "Piogge")
weather_data = string.gsub(weather_data, "AM", "In Mattinata")
weather_data = string.gsub(weather_data, "PM", "Nel Pomeriggio")
weather_data = string.gsub(weather_data, "Wind", "Vento")
weather_data = string.gsub(weather_data, "Few", "Sporadiche")
weather_data = string.gsub(weather_data, "Light", "Leggere")
if notification ~= nil and old_weather_data ~= weather_data then
add_weather(0)
end
end)
end
function remove_weather()
if notification ~= nil then
naughty.destroy(notification)
notification = nil
end
end
function add_weather(t_out)
remove_weather()
notification = naughty.notify({
text = weather_data,
icon = weather_icons .. sky .. ".png" ,
timeout = t_out, hover_timeout = 0.5
})
end
function add_weather_notification(widget, id)
city_id = id
fetch_weather()
update_timer = timer({ timeout = 600 })
update_timer:connect_signal("timeout", function()
fetch_weather()
end)
update_timer:start()
fetch_weather()
widget:connect_signal("mouse::enter", function()
add_weather(0)
end)
widget:connect_signal("mouse::leave", function()
remove_weather()
end)
vicious.force({ weatherwidget } )
end
-- the second argument must be your Yahoo Weather city id
add_weather_notification(weathericon, 123456)
-- Separators -- Separators
spr = wibox.widget.textbox(' ') spr = wibox.widget.textbox(' ')
@ -750,10 +600,8 @@ for s = 1, screen.count() do
right_layout:add(spr) right_layout:add(spr)
right_layout:add(mygmail) right_layout:add(mygmail)
right_layout:add(spr) right_layout:add(spr)
--right_layout:add(cpuwidget) right_layout:add(perceptive.icon)
--right_layout:add(spr) right_layout:add(perceptive.widget)
right_layout:add(weathericon)
right_layout:add(weatherwidget)
right_layout:add(spr) right_layout:add(spr)
right_layout:add(memwidget) right_layout:add(memwidget)
right_layout:add(spr) right_layout:add(spr)
@ -850,9 +698,9 @@ globalkeys = awful.util.table.join(
awful.key({ modkey, }, "z", function () scratch.drop(terminal) end), awful.key({ modkey, }, "z", function () scratch.drop(terminal) end),
-- Widgets popups -- Widgets popups
awful.key({ altkey, }, "c", function () add_calendar(7) end), awful.key({ altkey, }, "c", function () show_calendar(7) end),
awful.key({ altkey, }, "h", function () add_info(7) end), awful.key({ altkey, }, "h", function () show_info(7) end),
awful.key({ altkey, }, "w", function () add_weather(5) end), awful.key({ altkey, }, "w", function () perceptive.show_weather(5) end),
-- Volume control -- Volume control
awful.key({ "Control" }, "Up", function () awful.key({ "Control" }, "Up", function ()
@ -1028,8 +876,10 @@ awful.rules.rules = {
floating = true } }, floating = true } },
{ rule = { class = "Gimp" }, { rule = { class = "Gimp" },
properties = { tag = tags[1][4], properties = { tag = tags[1][4] } },
floating=true } },
{ rule = { class = "Native" },
properties = { tag = tags[1][4] } },
{ rule = { class = "Transmission-gtk" }, { rule = { class = "Transmission-gtk" },
properties = { tag = tags[1][5] } }, properties = { tag = tags[1][5] } },

View file

@ -1,87 +0,0 @@
#!/usr/bin/env python2.7
# coding=utf-8
"""Fetch weather using Yandex XML API."""
__author__ = "Ilia Glazkov"
import argparse
from urllib2 import urlopen
from xml.etree.ElementTree import ElementTree
WEATHER_API_PREFIX = "http://weather.yahooapis.com/forecastrss?u=c&w="
URLOPEN_TIMEOUT = 5
CELSIUS = '°C'
DASH = "—"
CURRENT_DAY = 'Now'
def weather_url_by_id(id):
return WEATHER_API_PREFIX + str(id)
def fetch_weather_tree(id):
return ElementTree().parse(
urlopen(weather_url_by_id(id), timeout=URLOPEN_TIMEOUT))
def format_date_string(day, text, temp, max_temp=None):
day = day or 'Now'
if max_temp:
temp_string = DASH.join((str(temp), str(max_temp)))
else:
temp_string = str(temp)
return '%s: %s, %s%s.' % (day, text, temp_string, CELSIUS)
class WeatherElement(object):
def __init__(self, element):
self.element = element
@property
def day(self):
return self.element.get('day') or CURRENT_DAY
@property
def text(self):
return self.element.get('text')
@property
def temp(self):
temp = self.element.get('temp')
if temp is not None:
return str(temp)
low, high = self.element.get('low'), self.element.get('high')
if low is not None and high is not None:
return DASH.join((str(low), str(high)))
def get_format_string(self):
return '%s: %s, %s%s.' % (self.day, self.text, self.temp, CELSIUS)
def get_weather_string(tree):
condition = next(el for el in tree.iter()
if el.tag.endswith('condition'))
forecast = [el for el in tree.iter()
if el.tag.endswith('forecast')]
forecast.insert(0, condition)
return '\n'.join((
WeatherElement(element).get_format_string()
for element in forecast))
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--id', type=int, required=True,
help='Yahoo WEOID of the city')
args = parser.parse_args()
print get_weather_string(fetch_weather_tree(args.id))
if __name__ == "__main__":
main()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View file

@ -1 +0,0 @@
http://merlinthered.deviantart.com/art/plain-weather-icons-157162192

View file

@ -60,54 +60,4 @@ theme.tasklist_maximized_vertical = ""
theme.widget_mail_notify = themes_dir .. "/icons/mail_notify.png" theme.widget_mail_notify = themes_dir .. "/icons/mail_notify.png"
theme.widget_no_net_notify = themes_dir .. "/icons/no_net_notify.png" theme.widget_no_net_notify = themes_dir .. "/icons/no_net_notify.png"
theme.widget_weather_na = themes_dir .. "/icons/weather/na.png"
theme.widget_weather_00 = themes_dir .. "/icons/weather/00.png"
theme.widget_weather_01 = themes_dir .. "/icons/weather/01.png"
theme.widget_weather_02 = themes_dir .. "/icons/weather/02.png"
theme.widget_weather_03 = themes_dir .. "/icons/weather/03.png"
theme.widget_weather_04 = themes_dir .. "/icons/weather/04.png"
theme.widget_weather_05 = themes_dir .. "/icons/weather/05.png"
theme.widget_weather_06 = themes_dir .. "/icons/weather/06.png"
theme.widget_weather_07 = themes_dir .. "/icons/weather/07.png"
theme.widget_weather_08 = themes_dir .. "/icons/weather/08.png"
theme.widget_weather_09 = themes_dir .. "/icons/weather/09.png"
theme.widget_weather_10 = themes_dir .. "/icons/weather/10.png"
theme.widget_weather_11 = themes_dir .. "/icons/weather/11.png"
theme.widget_weather_12 = themes_dir .. "/icons/weather/12.png"
theme.widget_weather_13 = themes_dir .. "/icons/weather/13.png"
theme.widget_weather_14 = themes_dir .. "/icons/weather/14.png"
theme.widget_weather_15 = themes_dir .. "/icons/weather/15.png"
theme.widget_weather_16 = themes_dir .. "/icons/weather/16.png"
theme.widget_weather_17 = themes_dir .. "/icons/weather/17.png"
theme.widget_weather_18 = themes_dir .. "/icons/weather/18.png"
theme.widget_weather_19 = themes_dir .. "/icons/weather/19.png"
theme.widget_weather_20 = themes_dir .. "/icons/weather/20.png"
theme.widget_weather_21 = themes_dir .. "/icons/weather/21.png"
theme.widget_weather_22 = themes_dir .. "/icons/weather/22.png"
theme.widget_weather_23 = themes_dir .. "/icons/weather/23.png"
theme.widget_weather_24 = themes_dir .. "/icons/weather/24.png"
theme.widget_weather_25 = themes_dir .. "/icons/weather/25.png"
theme.widget_weather_26 = themes_dir .. "/icons/weather/26.png"
theme.widget_weather_27 = themes_dir .. "/icons/weather/27.png"
theme.widget_weather_28 = themes_dir .. "/icons/weather/28.png"
theme.widget_weather_29 = themes_dir .. "/icons/weather/29.png"
theme.widget_weather_30 = themes_dir .. "/icons/weather/30.png"
theme.widget_weather_31 = themes_dir .. "/icons/weather/31.png"
theme.widget_weather_32 = themes_dir .. "/icons/weather/32.png"
theme.widget_weather_33 = themes_dir .. "/icons/weather/33.png"
theme.widget_weather_34 = themes_dir .. "/icons/weather/34.png"
theme.widget_weather_35 = themes_dir .. "/icons/weather/35.png"
theme.widget_weather_36 = themes_dir .. "/icons/weather/36.png"
theme.widget_weather_37 = themes_dir .. "/icons/weather/37.png"
theme.widget_weather_38 = themes_dir .. "/icons/weather/38.png"
theme.widget_weather_39 = themes_dir .. "/icons/weather/39.png"
theme.widget_weather_40 = themes_dir .. "/icons/weather/40.png"
theme.widget_weather_41 = themes_dir .. "/icons/weather/41.png"
theme.widget_weather_42 = themes_dir .. "/icons/weather/42.png"
theme.widget_weather_43 = themes_dir .. "/icons/weather/43.png"
theme.widget_weather_44 = themes_dir .. "/icons/weather/44.png"
theme.widget_weather_45 = themes_dir .. "/icons/weather/45.png"
theme.widget_weather_46 = themes_dir .. "/icons/weather/46.png"
theme.widget_weather_47 = themes_dir .. "/icons/weather/47.png"
return theme return theme