diff options
author | Nuno Silva <nuno.m.ribeiro.silva@tecnico.ulisboa.pt> | 2021-04-15 23:03:13 +0100 |
---|---|---|
committer | Nuno Silva <nuno.m.ribeiro.silva@tecnico.ulisboa.pt> | 2021-04-15 23:03:13 +0100 |
commit | e85d353933dcfd9dfc9101a3b53616d07f0cba20 (patch) | |
tree | 8d29148397c420bf7cab2eff257fef34ef2aa829 | |
parent | ce1af8e6072464112e792829565d8b922122e265 (diff) |
brightness-widget: add tooltip showing current level
-rw-r--r-- | brightness-widget/README.md | 1 | ||||
-rw-r--r-- | brightness-widget/brightness.lua | 10 |
2 files changed, 11 insertions, 0 deletions
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 ' -- <level> @@ -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 |