Possible fix for the memory leak (issue #11)

This commit is contained in:
pmakhov 2017-12-09 14:39:46 -05:00
parent bce9fbdd5f
commit e6c3059727
5 changed files with 69 additions and 17 deletions

View File

@ -1,3 +1,13 @@
-------------------------------------------------
-- Battery Widget for Awesome Window Manager
-- Shows the battery status using the ACPI tool
-- More details could be found here:
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/battery-widget
-- @author Pavel Makhov
-- @copyright 2017 Pavel Makhov
-------------------------------------------------
local awful = require("awful") local awful = require("awful")
local naughty = require("naughty") local naughty = require("naughty")
local watch = require("awful.widget.watch") local watch = require("awful.widget.watch")

View File

@ -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 wibox = require("wibox")
local watch = require("awful.widget.watch") local watch = require("awful.widget.watch")
--local get_brightness_cmd = "xbacklight -get" --local GET_BRIGHTNESS_CMD = "xbacklight -get"
local get_brightness_cmd = "light -G" local GET_BRIGHTNESS_CMD = "light -G"
local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" local path_to_icons = "/usr/share/icons/Arc/status/symbolic/"
local brightness_text = wibox.widget.textbox() local brightness_text = wibox.widget.textbox()
@ -14,20 +24,23 @@ local brightness_icon = wibox.widget {
resize = false, resize = false,
widget = wibox.widget.imagebox, 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_icon,
brightness_text, brightness_text,
layout = wibox.layout.fixed.horizontal, layout = wibox.layout.fixed.horizontal,
} }
watch( watch(
get_brightness_cmd, 1, GET_BRIGHTNESS_CMD, 1,
function(widget, stdout, stderr, exitreason, exitcode) function(widget, stdout, stderr, exitreason, exitcode)
local brightness_level = tonumber(string.format("%.0f", stdout)) local brightness_level = tonumber(string.format("%.0f", stdout))
widget:set_text(" " .. brightness_level .. "%") widget:set_text(" " .. brightness_level .. "%")
end, end,
brightness_text brightness_text
) )
return brightness_widget

View File

@ -1,3 +1,13 @@
-------------------------------------------------
-- Volume Widget for Awesome Window Manager
-- Shows the current volume level
-- More details could be found here:
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/volume-widget
-- @author Pavel Makhov
-- @copyright 2017 Pavel Makhov
-------------------------------------------------
local awful = require("awful") local awful = require("awful")
local wibox = require("wibox") local wibox = require("wibox")
local watch = require("awful.widget.watch") local watch = require("awful.widget.watch")
@ -6,7 +16,7 @@ local spawn = require("awful.spawn")
local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" local path_to_icons = "/usr/share/icons/Arc/status/symbolic/"
local request_command = 'amixer -D pulse sget Master' local request_command = 'amixer -D pulse sget Master'
volume_widget = wibox.widget { local volume_widget = wibox.widget {
{ {
id = "icon", id = "icon",
image = path_to_icons .. "audio-volume-muted-symbolic.svg", image = path_to_icons .. "audio-volume-muted-symbolic.svg",
@ -48,4 +58,6 @@ volume_widget:connect_signal("button::press", function(_,_,_,button)
end) end)
end) end)
watch(request_command, 1, update_graphic, volume_widget) watch(request_command, 1, update_graphic, volume_widget)
return volume_widget

View File

@ -1,3 +1,13 @@
-------------------------------------------------
-- Volume Arc Widget for Awesome Window Manager
-- Shows the current volume level
-- More details could be found here:
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/volumearc-widget
-- @author Pavel Makhov
-- @copyright 2017 Pavel Makhov
-------------------------------------------------
local awful = require("awful") local awful = require("awful")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local spawn = require("awful.spawn") local spawn = require("awful.spawn")
@ -17,13 +27,10 @@ local volumearc = wibox.widget {
forced_width = 17, forced_width = 17,
bg = "#ffffff11", bg = "#ffffff11",
paddings = 2, paddings = 2,
widget = wibox.container.arcchart, widget = wibox.container.arcchart
set_value = function(self, value)
self.value = value
end,
} }
volumearc_widget = wibox.container.mirror(volumearc, { horizontal = true }) local volumearc_widget = wibox.container.mirror(volumearc, { horizontal = true })
local update_graphic = function(widget, stdout, _, _, _) local update_graphic = function(widget, stdout, _, _, _)
local mute = string.match(stdout, "%[(o%D%D?)%]") local mute = string.match(stdout, "%[(o%D%D?)%]")
@ -50,3 +57,5 @@ volumearc:connect_signal("button::press", function(_, _, _, button)
end) end)
watch(GET_VOLUME_CMD, 1, update_graphic, volumearc) watch(GET_VOLUME_CMD, 1, update_graphic, volumearc)
return volumearc_widget

View File

@ -1,3 +1,13 @@
-------------------------------------------------
-- Volume Bar Widget for Awesome Window Manager
-- Shows the current volume level
-- More details could be found here:
-- https://github.com/streetturtle/awesome-wm-widgets/tree/master/volumebar-widget
-- @author Pavel Makhov
-- @copyright 2017 Pavel Makhov
-------------------------------------------------
local awful = require("awful") local awful = require("awful")
local gears = require("gears") local gears = require("gears")
local spawn = require("awful.spawn") local spawn = require("awful.spawn")
@ -10,8 +20,7 @@ local bar_color = "#74aeab"
local mute_color = "#ff0000" local mute_color = "#ff0000"
local background_color = "#3a3a3a" local background_color = "#3a3a3a"
local volumebar_widget = wibox.widget {
volumebar_widget = wibox.widget {
max_value = 1, max_value = 1,
forced_width = 50, forced_width = 50,
paddings = 0, paddings = 0,
@ -24,9 +33,6 @@ volumebar_widget = wibox.widget {
top = 10, top = 10,
bottom = 10, bottom = 10,
}, },
set_value = function(self, value)
self.value = value
end,
widget = wibox.widget.progressbar widget = wibox.widget.progressbar
} }
@ -56,3 +62,5 @@ volumebar_widget:connect_signal("button::press", function(_,_,_,button)
end) end)
watch(request_command, 1, update_graphic, volumebar_widget) watch(request_command, 1, update_graphic, volumebar_widget)
return volumebar_widget