aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/todo.lua
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2020-01-04 22:53:25 +0100
committerPatrick Spek <p.spek@tyil.nl>2020-01-04 22:53:25 +0100
commit933d5f0f1c43b75c8d49619adbd5b109cb2afd92 (patch)
treeaa687bf96899722a297f839724e1b3b133674a4d /.config/awesome/todo.lua
parent8e0810966369796ce9e1b98cce85ed858357cfdd (diff)
Update calendar todo widget
Diffstat (limited to '.config/awesome/todo.lua')
-rw-r--r--.config/awesome/todo.lua47
1 files changed, 47 insertions, 0 deletions
diff --git a/.config/awesome/todo.lua b/.config/awesome/todo.lua
new file mode 100644
index 0000000..83cf2d8
--- /dev/null
+++ b/.config/awesome/todo.lua
@@ -0,0 +1,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,
+})