brightness-widget: add tooltip showing current level
This commit is contained in:
parent
ce1af8e607
commit
e85d353933
|
@ -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 |
|
| `path_to_icon` | `/usr/share/icons/Arc/status/symbolic/display-brightness-symbolic.svg` | Path to the icon |
|
||||||
| `font` | `Play 9` | Font |
|
| `font` | `Play 9` | Font |
|
||||||
| `timeout` | 1 | How often in seconds the widget refreshes. Check the note below |
|
| `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).
|
_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).
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ local function worker(user_args)
|
||||||
local step = args.step or 5
|
local step = args.step or 5
|
||||||
local base = args.base or 20
|
local base = args.base or 20
|
||||||
local level = 0 -- current brightness value
|
local level = 0 -- current brightness value
|
||||||
|
local tooltip = args.tooltip or false
|
||||||
if program == 'light' then
|
if program == 'light' then
|
||||||
get_brightness_cmd = 'light -G'
|
get_brightness_cmd = 'light -G'
|
||||||
set_brightness_cmd = 'light -S ' -- <level>
|
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)
|
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
|
return brightness_widget.widget
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue