ossvol: fixed up by darkdefender

This commit is contained in:
Adrian C. (anrxc) 2010-05-01 20:03:10 +02:00
parent 1f26379afd
commit ac0455825f
1 changed files with 11 additions and 11 deletions

View File

@ -1,16 +1,13 @@
--------------------------------------------------- ---------------------------------------------------
-- Licensed under the GNU General Public License v2 -- Licensed under the GNU General Public License v2
-- * (c) 2009, Adrian C. <anrxc@sysphere.org> -- * (c) 2010, Adrian C. <anrxc@sysphere.org>
--------------------------------------------------- ---------------------------------------------------
-- {{{ Grab environment -- {{{ Grab environment
local tonumber = tonumber local tonumber = tonumber
local io = { popen = io.popen } local io = { popen = io.popen }
local setmetatable = setmetatable local setmetatable = setmetatable
local string = { local string = { match = string.match }
find = string.find,
match = string.match
}
-- }}} -- }}}
@ -28,19 +25,22 @@ local function worker(format, warg)
} }
-- Get mixer control contents -- Get mixer control contents
local f = io.popen("ossmix " .. warg) local f = io.popen("ossmix -c")
local mixer = f:read("*all") local mixer = f:read("*all")
f:close() f:close()
-- Capture mixer control state -- Capture mixer control state
local volu = tonumber(string.match(mixer, "([%d]+)")) local volu = tonumber(string.match(mixer, warg .. "[%s]([%d%.]+)"))/0.25
local mute = string.match(mixer, "vol%.mute[%s]([%a]+)")
-- Handle mixers without data -- Handle mixers without data
if volu == nil then if volu == nil then
return {0, mixer_state["off"]} return {0, mixer_state["off"]}
end end
-- Handle mixers without mute
if mute == "OFF" and volu == "0"
-- Handle mixers that are muted -- Handle mixers that are muted
if string.find(mixer, "OFF") then or mute == "ON" then
mute = mixer_state["off"] mute = mixer_state["off"]
else else
mute = mixer_state["on"] mute = mixer_state["on"]