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.lua7
2 files changed, 7 insertions, 1 deletions
diff --git a/brightness-widget/README.md b/brightness-widget/README.md
index 936c881..0cdb774 100644
--- a/brightness-widget/README.md
+++ b/brightness-widget/README.md
@@ -16,6 +16,7 @@ It is possible to customize widget by providing a table with all or some of the
| `font` | `beautiful.font` | Font name and size, like `Play 12` |
| `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 |
+| `percentage` | false | Display a '%' character after 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).
diff --git a/brightness-widget/brightness.lua b/brightness-widget/brightness.lua
index b9f07c9..3a77a44 100644
--- a/brightness-widget/brightness.lua
+++ b/brightness-widget/brightness.lua
@@ -44,6 +44,7 @@ local function worker(user_args)
local base = args.base or 20
local current_level = 0 -- current brightness value
local tooltip = args.tooltip or false
+ local percentage = args.percentage or false
if program == 'light' then
get_brightness_cmd = 'light -G'
set_brightness_cmd = 'light -S %d' -- <level>
@@ -83,7 +84,11 @@ local function worker(user_args)
spacing = 4,
layout = wibox.layout.fixed.horizontal,
set_value = function(self, level)
- self:get_children_by_id('txt')[1]:set_text(level .. '%')
+ local display_level = level
+ if percentage then
+ display_level = display_level .. '%'
+ end
+ self:get_children_by_id('txt')[1]:set_text(display_level)
end
}
elseif type == 'arc' then