From e4c0786e7955e8a9d0c6d36a689e2a1fde0e950f Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Thu, 4 Jun 2020 18:15:06 +0200 Subject: [PATCH] awesome: Add basic calendar highlighting support --- home/.config/awesome/utils.lua | 7 +++++++ home/.config/awesome/widgets.lua | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/home/.config/awesome/utils.lua b/home/.config/awesome/utils.lua index dbd9989..069ac0e 100644 --- a/home/.config/awesome/utils.lua +++ b/home/.config/awesome/utils.lua @@ -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 diff --git a/home/.config/awesome/widgets.lua b/home/.config/awesome/widgets.lua index 5b0c8b5..b153d2b 100644 --- a/home/.config/awesome/widgets.lua +++ b/home/.config/awesome/widgets.lua @@ -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)