From e1ca89ed7f9e7c575eb5d486e6a4d6ccd5413b5d Mon Sep 17 00:00:00 2001 From: Diogo Duarte Date: Tue, 12 Mar 2024 14:07:53 +0000 Subject: [PATCH] added notification support for new bookmarks --- init.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/init.lua b/init.lua index 1df33ac..5be7e67 100644 --- a/init.lua +++ b/init.lua @@ -23,6 +23,17 @@ local save_bookmark = ya.sync(function(state, idx) desc = tostring(folder.cwd), cursor = folder.cursor, } + + if state.notify.enable then + local description = state.notify.format + description, _ = description:gsub("", SUPPORTED_KEYS[idx].on) + description, _ = description:gsub("", tostring(folder.cwd)) + ya.notify { + title = "Bookmarks", + content = description, + timeout = state.notify.timeout, + } + end end) local all_bookmarks = ya.sync(function(state) return state.bookmarks or {} end) @@ -64,4 +75,22 @@ return { delete_bookmark(selected) end end, + setup = function(state, args) + if not args then + return + end + + state.notify = { enable = false, timeout = 2, format = "New bookmark in '' -> ''" } + if args.notify ~= nil then + if type(args.notify.enable) == "boolean" then + state.notify.enable = args.notify.enable + end + if type(args.notify.timeout) == "number" then + state.notify.timeout = args.notify.timeout + end + if type(args.notify.format) == "string" then + state.notify.format = args.notify.format + end + end + end, }