Adding a parameter to allow the right mouse button to always set the
brightness level to maximum, instead of the default toggle behavior.
This commit is contained in:
parent
3bb3d56c26
commit
5436535d37
|
@ -17,6 +17,7 @@ It is possible to customize widget by providing a table with all or some of the
|
||||||
| `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 |
|
| `tooltip` | false | Display brightness level in a tooltip when the mouse cursor hovers the widget |
|
||||||
| `percentage` | false | Display a '%' character after the brightness level |
|
| `percentage` | false | Display a '%' character after the brightness level |
|
||||||
|
| `rmb_set_max` | false | Right mouse click sets the brightness level to maximum |
|
||||||
|
|
||||||
_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).
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ local function worker(user_args)
|
||||||
local current_level = 0 -- current brightness value
|
local current_level = 0 -- current brightness value
|
||||||
local tooltip = args.tooltip or false
|
local tooltip = args.tooltip or false
|
||||||
local percentage = args.percentage or false
|
local percentage = args.percentage or false
|
||||||
|
local rmb_set_max = args.rmb_set_max 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 %d' -- <level>
|
set_brightness_cmd = 'light -S %d' -- <level>
|
||||||
|
@ -136,19 +137,23 @@ local function worker(user_args)
|
||||||
end
|
end
|
||||||
local old_level = 0
|
local old_level = 0
|
||||||
function brightness_widget:toggle()
|
function brightness_widget:toggle()
|
||||||
if old_level < 0.1 then
|
if rmb_set_max then
|
||||||
-- avoid toggling between '0' and 'almost 0'
|
brightness_widget:set(100)
|
||||||
old_level = 1
|
|
||||||
end
|
|
||||||
if current_level < 0.1 then
|
|
||||||
-- restore previous level
|
|
||||||
current_level = old_level
|
|
||||||
else
|
else
|
||||||
-- save current brightness for later
|
if old_level < 0.1 then
|
||||||
old_level = current_level
|
-- avoid toggling between '0' and 'almost 0'
|
||||||
current_level = 0
|
old_level = 1
|
||||||
|
end
|
||||||
|
if current_level < 0.1 then
|
||||||
|
-- restore previous level
|
||||||
|
current_level = old_level
|
||||||
|
else
|
||||||
|
-- save current brightness for later
|
||||||
|
old_level = current_level
|
||||||
|
current_level = 0
|
||||||
|
end
|
||||||
|
brightness_widget:set(current_level)
|
||||||
end
|
end
|
||||||
brightness_widget:set(current_level)
|
|
||||||
end
|
end
|
||||||
function brightness_widget:inc()
|
function brightness_widget:inc()
|
||||||
spawn.easy_async(inc_brightness_cmd, function()
|
spawn.easy_async(inc_brightness_cmd, function()
|
||||||
|
|
Loading…
Reference in New Issue