From e6c30597276edfa2637cde277d7d30209612dd5c Mon Sep 17 00:00:00 2001 From: pmakhov Date: Sat, 9 Dec 2017 14:39:46 -0500 Subject: Possible fix for the memory leak (issue #11) --- brightness-widget/brightness.lua | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'brightness-widget') diff --git a/brightness-widget/brightness.lua b/brightness-widget/brightness.lua index d7713ce..0db4be8 100644 --- a/brightness-widget/brightness.lua +++ b/brightness-widget/brightness.lua @@ -1,8 +1,18 @@ +------------------------------------------------- +-- Brightness Widget for Awesome Window Manager +-- Shows the brightness level of the laptop display +-- More details could be found here: +-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/brightness-widget + +-- @author Pavel Makhov +-- @copyright 2017 Pavel Makhov +------------------------------------------------- + local wibox = require("wibox") local watch = require("awful.widget.watch") ---local get_brightness_cmd = "xbacklight -get" -local get_brightness_cmd = "light -G" +--local GET_BRIGHTNESS_CMD = "xbacklight -get" +local GET_BRIGHTNESS_CMD = "light -G" local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" local brightness_text = wibox.widget.textbox() @@ -14,20 +24,23 @@ local brightness_icon = wibox.widget { resize = false, widget = wibox.widget.imagebox, }, - layout = wibox.container.margin(brightness_icon, 0, 0, 3) + top = 3, + widget = wibox.container.margin } -brightness_widget = wibox.widget { +local brightness_widget = wibox.widget { brightness_icon, brightness_text, layout = wibox.layout.fixed.horizontal, } watch( - get_brightness_cmd, 1, + GET_BRIGHTNESS_CMD, 1, function(widget, stdout, stderr, exitreason, exitcode) local brightness_level = tonumber(string.format("%.0f", stdout)) widget:set_text(" " .. brightness_level .. "%") end, brightness_text ) + +return brightness_widget \ No newline at end of file -- cgit v1.2.3