Skip to content

Commit c8388f4

Browse files
authored
Merge pull request #377 from WiltonLoch/master
New parameter to brightness widget
2 parents ca300ad + 5436535 commit c8388f4

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

brightness-widget/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ It is possible to customize widget by providing a table with all or some of the
1717
| `timeout` | 1 | How often in seconds the widget refreshes. Check the note below |
1818
| `tooltip` | false | Display brightness level in a tooltip when the mouse cursor hovers the widget |
1919
| `percentage` | false | Display a '%' character after the brightness level |
20+
| `rmb_set_max` | false | Right mouse click sets the brightness level to maximum |
2021

2122
_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).
2223

brightness-widget/brightness.lua

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ local function worker(user_args)
4646
local current_level = 0 -- current brightness value
4747
local tooltip = args.tooltip or false
4848
local percentage = args.percentage or false
49+
local rmb_set_max = args.rmb_set_max or false
4950
if program == 'light' then
5051
get_brightness_cmd = 'light -G'
5152
set_brightness_cmd = 'light -S %d' -- <level>
@@ -136,19 +137,23 @@ local function worker(user_args)
136137
end
137138
local old_level = 0
138139
function brightness_widget:toggle()
139-
if old_level < 0.1 then
140-
-- avoid toggling between '0' and 'almost 0'
141-
old_level = 1
142-
end
143-
if current_level < 0.1 then
144-
-- restore previous level
145-
current_level = old_level
140+
if rmb_set_max then
141+
brightness_widget:set(100)
146142
else
147-
-- save current brightness for later
148-
old_level = current_level
149-
current_level = 0
143+
if old_level < 0.1 then
144+
-- avoid toggling between '0' and 'almost 0'
145+
old_level = 1
146+
end
147+
if current_level < 0.1 then
148+
-- restore previous level
149+
current_level = old_level
150+
else
151+
-- save current brightness for later
152+
old_level = current_level
153+
current_level = 0
154+
end
155+
brightness_widget:set(current_level)
150156
end
151-
brightness_widget:set(current_level)
152157
end
153158
function brightness_widget:inc()
154159
spawn.easy_async(inc_brightness_cmd, function()

0 commit comments

Comments
 (0)