summaryrefslogtreecommitdiff
path: root/RatesWidget
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@gmail.com>2016-01-04 23:04:16 +0100
committerstreetturtle <streetturtle@gmail.com>2016-01-04 23:04:16 +0100
commit88d661d9538da1d9ce44d04954f5eee199d55bd6 (patch)
treeb8f4e3e91039f6f80ef0f1140a5310d68b1e343a /RatesWidget
parentd3f0f72cd207c3f5aaf77cc8b73e8ad07d952702 (diff)
Add rates widget
Diffstat (limited to 'RatesWidget')
-rw-r--r--RatesWidget/rates.lua21
-rw-r--r--RatesWidget/rates.py9
-rw-r--r--RatesWidget/readme.md0
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