awesome: Add basic calendar highlighting support

This commit is contained in:
Simon Bruder 2020-06-04 18:15:06 +02:00
parent a81388d206
commit e4c0786e79
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
2 changed files with 9 additions and 2 deletions

View file

@ -1,4 +1,5 @@
local helpers = require("lain.helpers")
local markup = require("lain.util.markup")
local utils = {}
@ -10,5 +11,11 @@ function utils.handle_pid(command, callback)
helpers.async_with_shell(string.format("ps x -o pid=,command=|grep -E '^\\s*[0-9]* %s$'|sed 's/\\s*\\([0-9]*\\) .*/\\1/'", command), callback)
end
function utils.ansi2markup(ansi, colors)
return ansi
:gsub("\x1b%[1m([^\x1b]*)", markup.bold("%1"))
:gsub("\x1b%[7m([^\x1b]*)", markup.color(colors.base1, colors.base02, "%1"))
:gsub("\x1b%[0m([^\x1b]*)", "%1")
end
return utils

View file

@ -211,10 +211,10 @@ widgets.cal.toggle = function()
naughty.destroy(widgets.cal.notification)
widgets.cal.notification = nil
else
helpers.async({ "khal", "calendar" }, function(output)
helpers.async({ "khal", "--color", "calendar" }, function(output)
widgets.cal.notification = naughty.notify{
screen = awful.screen.focused(),
text = output:gsub("\n$", ""),
text = utils.ansi2markup(output:gsub("\n$", ""), theme.colors),
timeout = 0,
}
end)