X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/e73a70c2ab26caf981d356756d4f83ad8bfbdb5a..1ed42223a2857770aa85da863213cdfb29f7d426:/widgets/alsa.lua diff --git a/widgets/alsa.lua b/widgets/alsa.lua index 887f398..114e2b2 100644 --- a/widgets/alsa.lua +++ b/widgets/alsa.lua @@ -1,10 +1,10 @@ --[[ - - Licensed under GNU General Public License v2 - * (c) 2013, Luke Bonham - * (c) 2010, Adrian C. - + + Licensed under GNU General Public License v2 + * (c) 2013, Luke Bonham + * (c) 2010, Adrian C. + --]] local newtimer = require("lain.helpers").newtimer @@ -23,36 +23,37 @@ local alsa = {} local function worker(args) local args = args or {} local timeout = args.timeout or 5 - local channel = args.channel or "Master" + local channel = args.channel or "Master -c 1" local settings = args.settings or function() end alsa.widget = wibox.widget.textbox('') function alsa.update() - local f = io.popen('amixer get ' .. channel) + local f = assert(io.popen('amixer get ' .. channel)) local mixer = f:read("*all") f:close() - volume = {} + volume_now = {} - volume.level, volume.status = string.match(mixer, "([%d]+)%%.*%[([%l]*)") + volume_now.level, volume_now.status = string.match(mixer, "([%d]+)%%.*%[([%l]*)") - if volume.level == nil + if volume_now.level == nil then - volume.level = 0 - volume.status = "off" + volume_now.level = "0" + volume_now.status = "off" end - if volume.status == "" + if volume_now.status == "" then - if volume.level == 0 + if volume_now.level == "0" then - volume.status = "off" + volume_now.status = "off" else - volume.status = "on" + volume_now.status = "on" end end + widget = alsa.widget settings() end