1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
local capi = {
mouse = mouse,
screen = screen,
}
local naughty = require("naughty")
------------------------------------------
-- todo.txt popup widget
------------------------------------------
local todo = {}
function todo:new(args)
return setmetatable({}, {__index = self})
end
function todo:show()
local f = assert(io.open("/home/tyil/documents/todo.txt", "rb"))
local content = f:read("*all"):gsub("%s+$", "")
f:close()
self.notification = naughty.notify({
title = "Todo",
text = content,
timeout = 0,
hover_timeout = 0.5,
screen = capi.mouse.screen,
position = self.position,
})
end
function todo:hide()
if self.notification then
naughty.destroy(self.notification)
self.notification = nil
self.num_lines = 0
end
end
function todo:attach(widget)
widget:connect_signal('mouse::enter', function() self:show() end)
widget:connect_signal('mouse::leave', function() self:hide() end)
end
return setmetatable(todo, {
__call = todo.new,
})
|