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.
4 Licensed under GNU General Public License v2
5 * (c) 2013, Luke Bonham
6 * (c) 2010-2012, Peter Hofmann
7 * (c) 2010, Adrian C. <anrxc@sysphere.org>
11 local markup = require("lain.util.markup")
12 local run_in_terminal = require("lain.helpers").run_in_terminal
14 local awful = require("awful")
15 local beautiful = require("beautiful")
16 local wibox = require("wibox")
19 local string = { format = string.format,
20 match = string.match }
22 local setmetatable = setmetatable
32 local args = args or {}
33 local channel = args.channel or "Master"
34 local step = args.step or "1%"
35 local header = args.header or " Vol "
36 local header_color = args.header_color or beautiful.fg_normal or "#FFFFFF"
37 local color = args.color or beautiful.fg_focus or "#FFFFFF"
39 local myvolume = wibox.widget.textbox()
40 local myvolumeupdate = function()
41 local f = io.popen('amixer get ' .. channel)
42 local mixer = f:read("*all")
45 local volume, mute = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
54 if mute == nil or mute == 'on'
63 local ret = markup(color, string.format("%d%s", volume, mute))
64 myvolume:set_markup(markup(header_color, header) .. ret .. " ")
67 local myvolumetimer = timer({ timeout = 5 })
68 myvolumetimer:connect_signal("timeout", myvolumeupdate)
70 myvolumetimer:emit_signal("timeout")
72 myvolume:buttons(awful.util.table.join(
75 run_in_terminal('alsamixer')
79 awful.util.spawn('amixer sset ' .. channel ' toggle')
84 awful.util.spawn('amixer sset ' .. channel .. ' ' .. step '+')
90 awful.util.spawn('amixer sset ' .. channel .. ' ' .. step '-')
95 alsa.widget = myvolume
96 alsa.channel = channel
98 alsa.notify = myvolumeupdate
100 return setmetatable(alsa, { __index = alsa.widget })
103 return setmetatable(alsa, { __call = function(_, ...) return worker(...) end })