summaryrefslogtreecommitdiff
path: root/brightness-widget
diff options
context:
space:
mode:
Diffstat (limited to 'brightness-widget')
-rw-r--r--brightness-widget/README.md1
-rw-r--r--brightness-widget/brightness.lua12
2 files changed, 13 insertions, 0 deletions
diff --git a/brightness-widget/README.md b/brightness-widget/README.md
index 5428029..5b1a23a 100644
--- a/brightness-widget/README.md
+++ b/brightness-widget/README.md
@@ -11,6 +11,7 @@ It is possible to customize widget by providing a table with all or some of the
| `type`| `arc` | The widget type. Could be `arc` or `icon_and_text` |
| `program` | `light` | The program used to control the brightness, either 'light' or 'xbacklight'. |
| `step` | 5 | Step |
+| `base` | 20 | Base level to set brightness to on left click. |
| `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 |
diff --git a/brightness-widget/brightness.lua b/brightness-widget/brightness.lua
index fed6a91..052c56b 100644
--- a/brightness-widget/brightness.lua
+++ b/brightness-widget/brightness.lua
@@ -16,6 +16,7 @@ local naughty = require("naughty")
local ICON_DIR = os.getenv("HOME") .. '/.config/awesome/awesome-wm-widgets/brightness-widget/'
local get_brightness_cmd
+local set_brightness_cmd
local inc_brightness_cmd
local dec_brightness_cmd
@@ -39,12 +40,15 @@ local function worker(user_args)
local program = args.program or 'light'
local step = args.step or 5
+ local base = args.base or 20
if program == 'light' then
get_brightness_cmd = 'light -G'
+ set_brightness_cmd = 'light -S ' -- <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>
inc_brightness_cmd = 'xbacklight -inc ' .. step
dec_brightness_cmd = 'xbacklight -dec ' .. step
else
@@ -107,6 +111,13 @@ local function worker(user_args)
widget:set_value(brightness_level)
end
+ function brightness_widget:set(value)
+ spawn.easy_async(set_brightness_cmd .. value, function()
+ spawn.easy_async(get_brightness_cmd, function(out)
+ update_widget(brightness_widget.widget, out)
+ end)
+ end)
+ end
function brightness_widget:inc()
spawn.easy_async(inc_brightness_cmd, function()
spawn.easy_async(get_brightness_cmd, function(out)
@@ -124,6 +135,7 @@ local function worker(user_args)
brightness_widget.widget:buttons(
awful.util.table.join(
+ awful.button({}, 1, function() brightness_widget:set(base) end),
awful.button({}, 4, function() brightness_widget:inc() end),
awful.button({}, 5, function() brightness_widget:dec() end)
)