From 88d661d9538da1d9ce44d04954f5eee199d55bd6 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Mon, 4 Jan 2016 23:04:16 +0100 Subject: Add rates widget --- RatesWidget/rates.lua | 21 +++++++++++++++++++++ RatesWidget/rates.py | 9 +++++++++ RatesWidget/readme.md | 0 3 files changed, 30 insertions(+) create mode 100644 RatesWidget/rates.lua create mode 100644 RatesWidget/rates.py create mode 100644 RatesWidget/readme.md 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 -- cgit v1.2.3