All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
3 Licensed under GNU General Public License v2
5 * (c) 2010, Adrian C. <anrxc@sysphere.org>
9 local helpers = require("lain.helpers")
10 local shell = require("awful.util").shell
11 local wibox = require("wibox")
12 local string = { match = string.match,
13 format = string.format }
18 local function factory(args)
19 local alsa = { widget = wibox.widget.textbox() }
20 local args = args or {}
21 local timeout = args.timeout or 5
22 local settings = args.settings or function() end
24 alsa.cmd = args.cmd or "amixer"
25 alsa.channel = args.channel or "Master"
26 alsa.togglechannel = args.togglechannel
28 local format_cmd = string.format("%s get %s", alsa.cmd, alsa.channel)
30 if alsa.togglechannel then
31 format_cmd = { shell, "-c", string.format("%s get %s; %s get %s",
32 alsa.cmd, alsa.channel, alsa.cmd, alsa.togglechannel) }
37 function alsa.update()
38 helpers.async(format_cmd, function(mixer)
39 local l,s = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
40 if alsa.last.level ~= l or alsa.last.status ~= s then
41 volume_now = { level = l, status = s }
44 alsa.last = volume_now
49 helpers.newtimer(string.format("alsa-%s-%s", alsa.cmd, alsa.channel), timeout, alsa.update)