diff options
author | streetturtle <streetturtle@gmail.com> | 2016-01-04 23:04:16 +0100 |
---|---|---|
committer | streetturtle <streetturtle@gmail.com> | 2016-01-04 23:04:16 +0100 |
commit | 88d661d9538da1d9ce44d04954f5eee199d55bd6 (patch) | |
tree | b8f4e3e91039f6f80ef0f1140a5310d68b1e343a | |
parent | d3f0f72cd207c3f5aaf77cc8b73e8ad07d952702 (diff) |
Add rates widget
-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 |