#54 fix attempt

This commit is contained in:
luke bonham 2014-07-21 13:34:40 +02:00
parent cf1bb42a83
commit 57e595c656

View file

@ -24,13 +24,11 @@ local setmetatable = setmetatable
-- ALSA volume bar -- ALSA volume bar
-- lain.widgets.alsabar -- lain.widgets.alsabar
local alsabar = local alsabar = {
{
channel = "Master", channel = "Master",
step = "5%", step = "5%",
colors = colors = {
{
background = beautiful.bg_normal, background = beautiful.bg_normal,
mute = "#EB8F8F", mute = "#EB8F8F",
unmute = "#A4CE8A" unmute = "#A4CE8A"
@ -39,8 +37,7 @@ local alsabar =
terminal = terminal or "xterm", terminal = terminal or "xterm",
mixer = terminal .. " -e alsamixer", mixer = terminal .. " -e alsamixer",
notifications = notifications = {
{
font = beautiful.font:sub(beautiful.font:find(""), beautiful.font:find(" ")), font = beautiful.font:sub(beautiful.font:find(""), beautiful.font:find(" ")),
font_size = "11", font_size = "11",
color = beautiful.fg_normal, color = beautiful.fg_normal,
@ -54,8 +51,7 @@ local alsabar =
function alsabar.notify() function alsabar.notify()
alsabar.update() alsabar.update()
local preset = local preset = {
{
title = "", title = "",
text = "", text = "",
timeout = 4, timeout = 4,
@ -68,10 +64,10 @@ function alsabar.notify()
then then
preset.title = alsabar.channel .. " - Muted" preset.title = alsabar.channel .. " - Muted"
else else
preset.title = alsabar.channel .. " - " .. alsabar._current_level * 100 .. "%" preset.title = alsabar.channel .. " - " .. alsabar._current_level .. "%"
end end
int = math.modf(alsabar._current_level * alsabar.notifications.bar_size) int = math.modf((alsabar._current_level / 100) * alsabar.notifications.bar_size)
preset.text = "[" preset.text = "["
.. string.rep("|", int) .. string.rep("|", int)
.. string.rep(" ", alsabar.notifications.bar_size - int) .. string.rep(" ", alsabar.notifications.bar_size - int)
@ -131,8 +127,8 @@ local function worker(args)
mute = "off" mute = "off"
end end
alsabar._current_level = tonumber(volu) / 100 alsabar._current_level = tonumber(volu)
alsabar.bar:set_value(alsabar._current_level) alsabar.bar:set_value(alsabar._current_level / 100)
if not mute and tonumber(volu) == 0 or mute == "off" if not mute and tonumber(volu) == 0 or mute == "off"
then then