diff --git a/awesome/background_widget.lua b/awesome/background_widget.lua index 4e3b1bc..593fe4d 100644 --- a/awesome/background_widget.lua +++ b/awesome/background_widget.lua @@ -8,7 +8,9 @@ local json = require('jsonutils') local home = os.getenv('HOME') local todo_path = home .. '/.config/todo/todo.json' -function todo_list_widget(index, todo, s) +local widget = nil + +function todo_list_widget(index, todo) local text = '\n ' .. index .. '. ' .. todo.title .. ' \n' @@ -35,10 +37,14 @@ function todo_list_widget(index, todo, s) end -function add_background_widget(s) +function update_background_widget(s) awful.spawn.easy_async_with_shell(":", function() + if widget ~= nil then + widget:remove() + end + local f = io.open(todo_path, "rb") if f ~= nil then @@ -62,7 +68,7 @@ function add_background_widget(s) local widgets = {} for key, val in pairs(todo) do - l:add(todo_list_widget(key, val, s)) + l:add(todo_list_widget(key, val)) end background_widget = awful.wibar({ @@ -78,6 +84,8 @@ function add_background_widget(s) background_widget:struts({left=0, right=0, top=0, bottom=0}) + widget = background_widget + end end) diff --git a/awesome/rc.lua b/awesome/rc.lua index e7d9e2d..f93c416 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -295,7 +295,7 @@ awful.screen.connect_for_each_screen(function(s) }, } - add_background_widget(s) + update_background_widget(s) end) -- }}}