diff options
-rw-r--r-- | RatesWidget/rates.lua | 21 | ||||
-rw-r--r-- | RatesWidget/rates.py | 9 | ||||
-rw-r--r-- | RatesWidget/readme.md | 0 |
3 files changed, 30 insertions, 0 deletions
diff --git a/RatesWidget/rates.lua b/RatesWidget/rates.lua new file mode 100644 index 0000000..485eacb --- /dev/null +++ b/RatesWidget/rates.lua @@ -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) diff --git a/RatesWidget/rates.py b/RatesWidget/rates.py new file mode 100644 index 0000000..9a12462 --- /dev/null +++ b/RatesWidget/rates.py @@ -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"]
\ No newline at end of file diff --git a/RatesWidget/readme.md b/RatesWidget/readme.md new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/RatesWidget/readme.md |