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 awful = require('awful')
local gears = require('gears')
local json = require('json')
local json = require('jsonutils')
local home = os.getenv('HOME')
local todo_path = home .. '/.config/todo/todo.json'
function read_all(file)
local widget = nil
return content
end
function todo_list_widget(index, todo)
function todo_list_widget(todo, s)
local text = '\n <b>' .. todo.title .. '</b> \n'
local text = '\n <b>' .. index .. '. ' .. todo.title .. '</b> \n'
for key, item in pairs(todo.items) do
text = text .. ' - ' .. item .. ' \n'
text = text .. ' ' .. key .. '. ' .. item .. ' \n'
end
local text = wibox.widget {
@ -35,54 +32,63 @@ function todo_list_widget(todo, s)
widget.shape_border_width = 1
widget.shape_border_color = "#ffffff"
widget.point = { x = todo.x, y = todo.y }
return widget
end
function add_background_widget(s)
function update_background_widget(s)
local f = io.open(todo_path, "rb")
local margin = 25
if f ~= nil then
awful.spawn.easy_async_with_shell(":", function()
local content = f:read("*all")
f:close()
todo = json.parse(content)
local margin = 25
local l = wibox.layout {
homogeneous = false,
spacing = margin,
forced_num_cols = 3,
layout = wibox.layout.grid,
}
l:set_orientation('horizontal')
local widgets = {}
for key, val in pairs(todo) do
l:add(todo_list_widget(val, s))
if widget ~= nil then
widget:remove()
end
background_widget = awful.wibar({
screen = s,
height = s.geometry.height,
bg = "#00000000",
})
local f = io.open(todo_path, "rb")
background_widget:setup {
wibox.container.margin(l, margin, margin, margin, margin),
layout = wibox.layout.manual
}
if f ~= nil then
background_widget:struts({left=0, right=0, top=0, bottom=0})
local content = f:read("*all")
f:close()
end
todo = json.parse(content)
local l = wibox.layout {
homogeneous = false,
spacing = margin,
forced_num_cols = 3,
layout = wibox.layout.grid,
}
l:set_orientation('horizontal')
local widgets = {}
for key, val in pairs(todo) do
l:add(todo_list_widget(key, val))
end
background_widget = awful.wibar({
screen = s,
height = s.geometry.height,
bg = "#00000000",
})
background_widget:setup {
wibox.container.margin(l, margin, margin, margin, margin),
layout = wibox.layout.manual
}
background_widget:struts({left=0, right=0, top=0, bottom=0})
widget = background_widget
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)
-- }}}