I am trying to spawn khal, a terminal calendar, when mouse pressing the default textclock widget in awesome wm.
local cal_notification
mytextclock:connect_signal("button::release",
function()
if cal_notification == nil then
awful.spawn.easy_async(noisy,
function(stdout, stderr, reason, exit_code)
cal_notification = naughty.notify{
text = stdout,
width = auto,
destroy = function() cal_notification = nil end
}
end
)
else
naughty.destroy(cal_notification)
end
end)
Unfortunately on execution, all syntax highlighting of khal is gone. Does anyone have an idea how to spawn a notification without losing the 'look'?
Edit: This occurs probably with any other terminal calendar, for example with cal, I think.
With grep --color -EC6 "$(date +%e)" it still doesnt output color. With a forced --color statement of khal it outputs 001b 1m before every highlighted character.
CLI applications like khal
use so-called ASCII escape codes to encode the coloured highlighting. Parts of those is what you saw with "outputs 001b 1m
before every highlighted character".
There are more characters within those sequences than what you pasted here, but those are likely swallowed by Lua's string handling or awesome's rendering.
The problem here is the fact that this way of highlighting text using ASCII escape codes is something that's specific to terminals and terminal emulators. Other applications do not use or implement them.
For awesome specifically, text markup is done through Pango Markup. So for your notifications to retain the highlighting created by khal
, you will need to create a conversion layer that transforms the ASCII escape codes into Pango markup.
An additional challenge is the fact that colours in terminals use a theme-based system. The terminal is configured with a certain set of colours, and the escape codes merely index into that list. They don't hold any actual colour information themselves. However, for Pango, you need to specify the actual colour value in the markup.