Add rates widget

This commit is contained in:
streetturtle 2016-01-04 23:04:16 +01:00
parent d3f0f72cd2
commit 88d661d953
3 changed files with 30 additions and 0 deletions

21
RatesWidget/rates.lua Normal file
View File

@ -0,0 +1,21 @@
local wibox = require("wibox")
local awful = require("awful")
rateWidget = wibox.widget.textbox()
-- DBus (Command are sent to Dbus, which prevents Awesome from freezу)
sleepTimerDbus = timer ({timeout = 5})
sleepTimerDbus:connect_signal ("timeout",
function ()
awful.util.spawn_with_shell("dbus-send --session --dest=org.naquadah.awesome.awful /com/console/rate com.console.rate.rateWidget string:$(python ~/.config/awesome/rates/rates.py)" )
end)
sleepTimerDbus:start()
dbus.request_name("session", "com.console.rate")
dbus.add_match("session", "interface='com.console.rate', member='rateWidget' " )
dbus.connect_signal("com.console.rate",
function (...)
local data = {...}
local dbustext = data[2]
rateWidget:set_text(dbustext)
end)

9
RatesWidget/rates.py Normal file
View File

@ -0,0 +1,9 @@
#!/usr/bin/python
import requests
import json
r = requests.get("http://api.fixer.io/latest?symbols=CHF,EUR")
resp = json.loads(r.content)
print resp["rates"]["CHF"]

0
RatesWidget/readme.md Normal file
View File