diff options
-rw-r--r-- | RatesWidget/rates.lua | 17 | ||||
-rw-r--r-- | RatesWidget/ratesPopup.py | 11 | ||||
-rw-r--r-- | RatesWidget/readme.md | 5 |
3 files changed, 33 insertions, 0 deletions
diff --git a/RatesWidget/rates.lua b/RatesWidget/rates.lua index b170210..6fa2e47 100644 --- a/RatesWidget/rates.lua +++ b/RatesWidget/rates.lua @@ -20,3 +20,20 @@ dbus.connect_signal("com.console.rate", local dbustext = data[2] rateWidget:set_text(dbustext) end) + +-- The notification popup which shows rates for other currencies +function showRatesPopup() + naughty.notify({ + title = "Rates", + text = awful.util.pread("python ~/.config/awesome/rates/ratesPopup.py"), + icon = "/home/username/.config/awesome/rates/currency.png", + icon_size = 100, + timeout = 10, + width = 300, + padding = 100, + fg = "#ffffff", + bg = "#333333aa", + }) +end + +rateWidget:connect_signal("mouse::enter", function() showRatesPopup() end)
\ No newline at end of file diff --git a/RatesWidget/ratesPopup.py b/RatesWidget/ratesPopup.py new file mode 100644 index 0000000..4ac6cce --- /dev/null +++ b/RatesWidget/ratesPopup.py @@ -0,0 +1,11 @@ +#!/usr/bin/python + +import requests +import json + +r = requests.get("http://api.fixer.io/latest?symbols=USD,EUR,JPY,GBP,CHF,CAD,RUB") +resp = json.loads(r.content) +rates = resp["rates"] + +for currency, rate in rates.items(): + print currency, rate diff --git a/RatesWidget/readme.md b/RatesWidget/readme.md index 5820aa0..d13bae1 100644 --- a/RatesWidget/readme.md +++ b/RatesWidget/readme.md @@ -1,3 +1,8 @@ # Rates Widget
Widget for Awesome WM which displays the currency rate between Swiss Frank and Euro. For the rate API it uses [fixer.io](http://fixer.io/) - JSON API for foreign exchange rates and currency conversion. And a python script which calls this API.
+
+You can read more about it in these posts:
+
+ - http://pavelmakhov.com/2016/01/how-to-create-widget/
+ - http://pavelmakhov.com/2016/01/how-to-create-widget-part-2/
|