Update widget

This commit is contained in:
Thomas Forgione 2018-09-16 15:18:46 +02:00
parent b67b5c5f43
commit 7c70080bbe
No known key found for this signature in database
GPG Key ID: 3B8FC64F5BBFE109
2 changed files with 12 additions and 4 deletions

View File

@ -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 <b>' .. index .. '. ' .. todo.title .. '</b> \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)

View File

@ -295,7 +295,7 @@ awful.screen.connect_for_each_screen(function(s)
},
}
add_background_widget(s)
update_background_widget(s)
end)
-- }}}