Todo stats to work

This commit is contained in:
Thomas Forgione 2018-09-14 14:47:07 +02:00
parent 7a8779dd52
commit 04a8ef5876
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 55 additions and 21 deletions

View File

@ -1,26 +1,43 @@
local os = require('os')
naughty = require('naughty')
local wibox = require('wibox')
local awful = require('awful')
local gears = require('gears')
local json = require('json')
function todo_list_widget(s)
local home = os.getenv('HOME')
local todo_path = home .. '/.config/todo/todo.json'
local text = wibox.widget{
markup = '\n <b>TODO</b>\n - Hello',
function read_all(file)
return content
end
function todo_list_widget(todo, s)
local text = '\n <b>' .. todo.title .. '</b>\n'
for key, item in pairs(todo.items) do
text = text .. ' - ' .. item .. '\n'
end
local text = wibox.widget {
markup = text,
align = 'left',
valign = 'top',
font = "Ubuntu 20",
font = "Ubuntu 18",
widget = wibox.widget.textbox
}
local widget = wibox.widget.background(text, "#000000aa", function(cr, width, height)
local widget = wibox.widget.background(text, todo.color, function(cr, width, height)
gears.shape.rounded_rect(cr, width, height, 20)
end)
widget.shape_border_width = 1
widget.shape_border_color = "#ffffff"
widget.forced_width = 500
widget.forced_height = 500
widget.point = { x = 20, y = 30 }
widget.forced_width = todo.width
widget.forced_height = todo.height
widget.point = { x = todo.x, y = todo.y }
return widget
@ -28,22 +45,39 @@ end
function add_background_widget(s)
background_widget = awful.wibar({
screen = s,
height = s.geometry.height,
bg = "#00000000",
})
local f = io.open(todo_path, "rb")
local text = wibox.widget.textbox("Hello to you")
text.point = { x = 75, y = 200 }
if f ~= nil then
local w = todo_list_widget(s)
local content = f:read("*all")
f:close()
background_widget:setup {
layout = wibox.layout.manual,
w
}
todo = json.parse(content)
background_widget:struts({left=0, right=0, top=0, bottom=0})
local l = wibox.layout {
layout = wibox.layout.manual
}
local widgets = {}
for key, val in pairs(todo) do
l:add(todo_list_widget(val, s))
end
background_widget = awful.wibar({
screen = s,
height = s.geometry.height,
bg = "#00000000",
})
background_widget:setup {
l,
layout = wibox.layout.manual
}
background_widget:struts({left=0, right=0, top=0, bottom=0})
end
end