From 80f6bb2c05f7b3fc81c0b8c881e7f52bdc88c00a Mon Sep 17 00:00:00 2001 From: Michael Cochez Date: Sat, 20 Nov 2021 02:21:32 +0100 Subject: Added the option to customize te mousebuttons for going to the previous and next month --- calendar-widget/README.md | 21 ++++++++++++++++++++- calendar-widget/calendar.lua | 7 ++++--- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'calendar-widget') diff --git a/calendar-widget/README.md b/calendar-widget/README.md index 3d878bf..c7b46e2 100644 --- a/calendar-widget/README.md +++ b/calendar-widget/README.md @@ -4,7 +4,6 @@ Calendar widget for Awesome WM - slightly improved version of the `wibox.widget. ## Features - - mouse support: scroll up - shows next month, scroll down - previous - themes: | Name | Screenshot | @@ -30,6 +29,23 @@ Calendar widget for Awesome WM - slightly improved version of the `wibox.widget. ![calendar_bottom_right](./calendar_bottom_right.png) + - mouse support: + move to the next and previous month. Using mouse buttons or scroll wheel. + + You can configure this by specifying the button to move to next/previous. + Usually these are configured as follows. If you want to use other mouse buttons, you can find their number using `xev`. + + | number | button | + |--------|--------| + | 4 | scroll up | + | 5 | scroll down | + | 1 | left click | + | 2 | right click | + | 3 | middles click | + + By default `previous_month_button` is 5, `next_month_button` is 4. + + ## How to use This widget needs an 'anchor' - another widget which triggers visibility of the calendar. Default `mytextclock` is the perfect candidate! @@ -47,6 +63,9 @@ local cw = calendar_widget({ theme = 'outrun', placement = 'bottom_right', radius = 8, +-- with customized next/previous (see table above) + previous_month_button = 1, + next_month_button = 3, }) mytextclock:connect_signal("button::press", function(_, _, _, button) diff --git a/calendar-widget/calendar.lua b/calendar-widget/calendar.lua index 81c28a9..d62f52b 100644 --- a/calendar-widget/calendar.lua +++ b/calendar-widget/calendar.lua @@ -95,7 +95,8 @@ local function worker(user_args) local theme = args.theme or 'naughty' local placement = args.placement or 'top' local radius = args.radius or 8 - + local next_month_button = args.next_month_button or 4 + local previous_month_button = args.previous_month_button or 5 local styles = {} local function rounded_shape(size) @@ -198,14 +199,14 @@ local function worker(user_args) popup:buttons( awful.util.table.join( - awful.button({}, 4, function() + awful.button({}, next_month_button, function() local a = cal:get_date() a.month = a.month + 1 cal:set_date(nil) cal:set_date(a) popup:set_widget(cal) end), - awful.button({}, 5, function() + awful.button({}, previous_month_button, function() local a = cal:get_date() a.month = a.month - 1 cal:set_date(nil) -- cgit v1.2.3