awesome-wm-widgets/RatesWidget/rates.lua

39 lines
1.3 KiB
Lua
Raw Normal View History

2016-01-04 23:04:16 +01:00
local wibox = require("wibox")
local awful = require("awful")
rateWidget = wibox.widget.textbox()
-- DBus (Command are sent to Dbus, which prevents Awesome from freezу)
2016-01-05 18:00:50 +01:00
sleepTimerDbus = timer ({timeout = 1800})
2016-01-04 23:04:16 +01:00
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()
2016-01-05 18:00:50 +01:00
sleepTimerDbus:emit_signal("timeout")
2016-01-04 23:04:16 +01:00
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)
2016-01-12 22:59:53 +01:00
-- 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)