Merge branch 'master' of gitea.tforgione.fr:tforgione/dotfiles

This commit is contained in:
Thomas Forgione 2018-09-17 09:16:27 +02:00
commit 25cd28023f
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
3 changed files with 50 additions and 44 deletions

View File

@ -3,22 +3,19 @@ naughty = require('naughty')
local wibox = require('wibox') local wibox = require('wibox')
local awful = require('awful') local awful = require('awful')
local gears = require('gears') local gears = require('gears')
local json = require('json') local json = require('jsonutils')
local home = os.getenv('HOME') local home = os.getenv('HOME')
local todo_path = home .. '/.config/todo/todo.json' local todo_path = home .. '/.config/todo/todo.json'
function read_all(file) local widget = nil
return content function todo_list_widget(index, todo)
end
function todo_list_widget(todo, s) local text = '\n <b>' .. index .. '. ' .. todo.title .. '</b> \n'
local text = '\n <b>' .. todo.title .. '</b> \n'
for key, item in pairs(todo.items) do for key, item in pairs(todo.items) do
text = text .. ' - ' .. item .. ' \n' text = text .. ' ' .. key .. '. ' .. item .. ' \n'
end end
local text = wibox.widget { local text = wibox.widget {
@ -35,13 +32,20 @@ function todo_list_widget(todo, s)
widget.shape_border_width = 1 widget.shape_border_width = 1
widget.shape_border_color = "#ffffff" widget.shape_border_color = "#ffffff"
widget.point = { x = todo.x, y = todo.y }
return widget return widget
end end
function add_background_widget(s) function update_background_widget(s)
local margin = 25
awful.spawn.easy_async_with_shell(":", function()
if widget ~= nil then
widget:remove()
end
local f = io.open(todo_path, "rb") local f = io.open(todo_path, "rb")
@ -52,8 +56,6 @@ function add_background_widget(s)
todo = json.parse(content) todo = json.parse(content)
local margin = 25
local l = wibox.layout { local l = wibox.layout {
homogeneous = false, homogeneous = false,
spacing = margin, spacing = margin,
@ -66,7 +68,7 @@ function add_background_widget(s)
local widgets = {} local widgets = {}
for key, val in pairs(todo) do for key, val in pairs(todo) do
l:add(todo_list_widget(val, s)) l:add(todo_list_widget(key, val))
end end
background_widget = awful.wibar({ background_widget = awful.wibar({
@ -82,7 +84,11 @@ function add_background_widget(s)
background_widget:struts({left=0, right=0, top=0, bottom=0}) background_widget:struts({left=0, right=0, top=0, bottom=0})
end widget = background_widget
end
end)
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) end)
-- }}} -- }}}