Skip to content

Commit

Permalink
Update pulseaudio.lua
Browse files Browse the repository at this point in the history
English
  • Loading branch information
mokasin committed Feb 21, 2017
1 parent 761ced5 commit 57386b6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pulseaudio.lua
Expand Up @@ -31,7 +31,7 @@ function pulseaudio:Create()
o.Volume = 0 -- volume of default sink
o.Mute = false -- state of the mute flag of the default sink

-- retreive current state from Pulseaudio
-- retrieve current state from pulseaudio
pulseaudio.UpdateState(o)

return o
Expand All @@ -40,30 +40,30 @@ end
function pulseaudio:UpdateState()
local f = io.popen(cmd .. " dump")

-- if the cmd can't be found
-- if the cmd cannot be found
if f == nil then
return false
end

local out = f:read("*a")
f:close()

-- get the default sink
-- find default sink
default_sink = string.match(out, "set%-default%-sink ([^\n]+)")

if default_sink == nil then
default_sink = ""
return false
end

-- retreive volume of default sink
-- retrieve volume of default sink
for sink, value in string.gmatch(out, "set%-sink%-volume ([^%s]+) (0x%x+)") do
if sink == default_sink then
self.Volume = tonumber(value) / 0x10000
end
end

-- retreive mute state of default sink
-- retrieve mute state of default sink
local m
for sink, value in string.gmatch(out, "set%-sink%-mute ([^%s]+) (%a+)") do
if sink == default_sink then
Expand Down Expand Up @@ -108,7 +108,7 @@ function pulseaudio:ToggleMute()
run(cmd .. " set-sink-mute " .. default_sink .. " 1")
end

-- …and update values.
-- …and updates values.
self:UpdateState()
end

Expand Down

0 comments on commit 57386b6

Please sign in to comment.