awesome: Add calendar widget

This commit is contained in:
Simon Bruder 2020-02-28 12:15:09 +00:00
parent 646f0a3ae5
commit 7d21067bd4
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F
2 changed files with 31 additions and 1 deletions

View file

@ -107,6 +107,10 @@ menubar.utils.terminal = terminal -- Set the terminal for applications that requ
-- Create a textclock widget
mytextclock = wibox.widget.textclock()
-- Create calendar and attach it to textclock
mycal = widgets.cal
mycal.attach(mytextclock)
-- Create a wibox for each screen and add it
local taglist_buttons = gears.table.join(
awful.button({ }, 1, function(t) t:view_only() end),

View file

@ -1,6 +1,7 @@
local awful = require("awful")
local wibox = require("wibox")
local gtable = require("gears.table")
local naughty = require("naughty")
local wibox = require("wibox")
local lain = require("lain")
local helpers = require("lain.helpers")
@ -187,4 +188,29 @@ widgets.tearstop:buttons(
)
)
widgets.cal = {}
widgets.cal.show = function()
widgets.cal.hide()
helpers.async({ "khal", "calendar" }, function(output)
widgets.cal.notification = naughty.notify{
screen = awful.screen.focused(),
text = output:gsub("\n$", ""),
timeout = 0,
}
end)
end
widgets.cal.hide = function()
if not widgets.cal.notification then return end
naughty.destroy(widgets.cal.notification)
widgets.cal.notification = nil
end
widgets.cal.attach = function(parent)
parent:connect_signal("mouse::enter", widgets.cal.show)
parent:connect_signal("mouse::leave", widgets.cal.hide)
end
return widgets