summaryrefslogtreecommitdiff
path: root/RatesWidget
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@gmail.com>2016-01-12 22:59:53 +0100
committerstreetturtle <streetturtle@gmail.com>2016-01-12 22:59:53 +0100
commitaa4c4b621a98d5e538cd02bb551517e5c8bad72d (patch)
tree3e477cdcddb5d59bc597226a8c97f0e411d4ff2f /RatesWidget
parent7d2752e3f3d7d7e86863fa2987b028885f25c66a (diff)
Popup notification added
Diffstat (limited to 'RatesWidget')
-rw-r--r--RatesWidget/rates.lua17
-rw-r--r--RatesWidget/ratesPopup.py11
-rw-r--r--RatesWidget/readme.md5
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/