From 7d21067bd4113cb1e8879bb5d321ebf5981a0234 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Fri, 28 Feb 2020 12:15:09 +0000 Subject: [PATCH] awesome: Add calendar widget --- home/.config/awesome/rc.lua | 4 ++++ home/.config/awesome/widgets.lua | 28 +++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/home/.config/awesome/rc.lua b/home/.config/awesome/rc.lua index 72c4e55..1651c96 100644 --- a/home/.config/awesome/rc.lua +++ b/home/.config/awesome/rc.lua @@ -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), diff --git a/home/.config/awesome/widgets.lua b/home/.config/awesome/widgets.lua index 6d43d27..eb87f3a 100644 --- a/home/.config/awesome/widgets.lua +++ b/home/.config/awesome/widgets.lua @@ -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