From e85d353933dcfd9dfc9101a3b53616d07f0cba20 Mon Sep 17 00:00:00 2001 From: Nuno Silva Date: Thu, 15 Apr 2021 23:03:13 +0100 Subject: brightness-widget: add tooltip showing current level --- brightness-widget/README.md | 1 + brightness-widget/brightness.lua | 10 ++++++++++ 2 files changed, 11 insertions(+) (limited to 'brightness-widget') diff --git a/brightness-widget/README.md b/brightness-widget/README.md index 5b1a23a..47f7d9c 100644 --- a/brightness-widget/README.md +++ b/brightness-widget/README.md @@ -15,6 +15,7 @@ It is possible to customize widget by providing a table with all or some of the | `path_to_icon` | `/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg` | Path to the icon | | `font` | `Play 9` | Font | | `timeout` | 1 | How often in seconds the widget refreshes. Check the note below | +| `tooltip` | false | Display brightness level in a tooltip when the mouse cursor hovers the widget | _Note:_ If brightness is controlled only by the widget (either by a mouse, or by a shortcut, then the `timeout` could be quite big, as there is no reason to synchronize the brightness level). diff --git a/brightness-widget/brightness.lua b/brightness-widget/brightness.lua index f222adc..0994ba7 100644 --- a/brightness-widget/brightness.lua +++ b/brightness-widget/brightness.lua @@ -42,6 +42,7 @@ local function worker(user_args) local step = args.step or 5 local base = args.base or 20 local level = 0 -- current brightness value + local tooltip = args.tooltip or false if program == 'light' then get_brightness_cmd = 'light -G' set_brightness_cmd = 'light -S ' -- @@ -163,6 +164,15 @@ local function worker(user_args) watch(get_brightness_cmd, timeout, update_widget, brightness_widget.widget) + if tooltip then + awful.tooltip { + objects = { brightness_widget.widget }, + timer_function = function() + return level .. " %" + end, + } + end + return brightness_widget.widget end -- cgit v1.2.3