X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/3a056ccaebc84a3bb98d3fab54298eea58544a35..70bee86b8b4e796a7f399f5d795b080ae8f3a4f6:/widgets/alsabar.lua diff --git a/widgets/alsabar.lua b/widgets/alsabar.lua index c7498d2..39bf394 100644 --- a/widgets/alsabar.lua +++ b/widgets/alsabar.lua @@ -127,28 +127,26 @@ local function worker(args) -- Capture mixer control state: [5%] ... ... [on] local volu, mute = string.match(mixer, "([%d]+)%%.*%[([%l]*)") - if volu == nil then - volu = 0 - mute = "off" - end - - alsabar._current_level = tonumber(volu) - alsabar.bar:set_value(alsabar._current_level / 100) - if not mute and tonumber(volu) == 0 or mute == "off" + if (volu and tonumber(volu) ~= alsabar._current_level) or (mute and string.match(mute, "on") ~= alsabar._muted) then - alsabar._muted = true - alsabar.tooltip:set_text (" [Muted] ") - alsabar.bar:set_color(alsabar.colors.mute) - else - alsabar._muted = false - alsabar.tooltip:set_text(string.format(" %s:%s ", alsabar.channel, volu)) - alsabar.bar:set_color(alsabar.colors.unmute) + alsabar._current_level = tonumber(volu) + alsabar.bar:set_value(alsabar._current_level / 100) + if not mute and tonumber(volu) == 0 or mute == "off" + then + alsabar._muted = true + alsabar.tooltip:set_text (" [Muted] ") + alsabar.bar:set_color(alsabar.colors.mute) + else + alsabar._muted = false + alsabar.tooltip:set_text(string.format(" %s:%s ", alsabar.channel, volu)) + alsabar.bar:set_color(alsabar.colors.unmute) + end + + volume_now = {} + volume_now.level = tonumber(volu) + volume_now.status = mute + settings() end - - volume_now = {} - volume_now.level = tonumber(volu) - volume_now.status = mute - settings() end alsabar.bar:buttons (awful.util.table.join (