summaryrefslogtreecommitdiff
path: root/brightness-widget/brightness.lua
diff options
context:
space:
mode:
Diffstat (limited to 'brightness-widget/brightness.lua')
-rw-r--r--brightness-widget/brightness.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/brightness-widget/brightness.lua b/brightness-widget/brightness.lua
index b66b1f0..ffdeb7b 100644
--- a/brightness-widget/brightness.lua
+++ b/brightness-widget/brightness.lua
@@ -45,14 +45,19 @@ local function worker(user_args)
local tooltip = args.tooltip or false
if program == 'light' then
get_brightness_cmd = 'light -G'
- set_brightness_cmd = 'light -S ' -- <level>
+ set_brightness_cmd = 'light -S %d' -- <level>
inc_brightness_cmd = 'light -A ' .. step
dec_brightness_cmd = 'light -U ' .. step
elseif program == 'xbacklight' then
get_brightness_cmd = 'xbacklight -get'
- set_brightness_cmd = 'xbacklight -set ' -- <level>
+ set_brightness_cmd = 'xbacklight -set %d' -- <level>
inc_brightness_cmd = 'xbacklight -inc ' .. step
dec_brightness_cmd = 'xbacklight -dec ' .. step
+ elseif program == 'brightnessctl' then
+ get_brightness_cmd = 'bash -c "brightnessctl -m | cut -d, -f4 | tr -d %"'
+ set_brightness_cmd = 'brightnessctl set %d%%' -- <level>
+ inc_brightness_cmd = 'brightnessctl set +' .. step .. '%'
+ dec_brightness_cmd = 'brightnessctl set ' .. step .. '-%'
else
show_warning(program .. " command is not supported by the widget")
return
@@ -116,7 +121,7 @@ local function worker(user_args)
function brightness_widget:set(value)
current_level = value
- spawn.easy_async(set_brightness_cmd .. value, function()
+ spawn.easy_async(string.format(set_brightness_cmd, value), function()
spawn.easy_async(get_brightness_cmd, function(out)
update_widget(brightness_widget.widget, out)
end)