From aa4c4b621a98d5e538cd02bb551517e5c8bad72d Mon Sep 17 00:00:00 2001 From: streetturtle Date: Tue, 12 Jan 2016 22:59:53 +0100 Subject: Popup notification added --- RatesWidget/rates.lua | 17 +++++++++++++++++ RatesWidget/ratesPopup.py | 11 +++++++++++ RatesWidget/readme.md | 5 +++++ 3 files changed, 33 insertions(+) create mode 100644 RatesWidget/ratesPopup.py (limited to 'RatesWidget') 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/ -- cgit v1.2.3