mirror of https://github.com/lcpz/lain.git
Merge pull request #169 from MaksVal/master
Add callback function for to update sink
This commit is contained in:
commit
cded8aad10
|
@ -23,6 +23,7 @@ local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 5
|
local timeout = args.timeout or 5
|
||||||
local settings = args.settings or function() end
|
local settings = args.settings or function() end
|
||||||
|
local scallback = args.scallback or nil
|
||||||
|
|
||||||
pulseaudio.sink = args.sink or 0 -- user defined or first one
|
pulseaudio.sink = args.sink or 0 -- user defined or first one
|
||||||
pulseaudio.cmd = args.cmd or string.format("pacmd list-sinks | sed -n -e '/base volume/d' -e '/index: %d/p' -e '/volume:/p' -e '/muted:/p' | sed -n -e '/index: %d/,+2p'",
|
pulseaudio.cmd = args.cmd or string.format("pacmd list-sinks | sed -n -e '/base volume/d' -e '/index: %d/p' -e '/volume:/p' -e '/muted:/p' | sed -n -e '/index: %d/,+2p'",
|
||||||
|
@ -37,6 +38,10 @@ local function worker(args)
|
||||||
volume_now.right = tonumber(string.match(s, "right.-(%d+)%%")) or tonumber(string.match(s, "1:.-(%d+)%%"))
|
volume_now.right = tonumber(string.match(s, "right.-(%d+)%%")) or tonumber(string.match(s, "1:.-(%d+)%%"))
|
||||||
volume_now.muted = string.match(s, "muted: (%S+)")
|
volume_now.muted = string.match(s, "muted: (%S+)")
|
||||||
|
|
||||||
|
if scallback ~= nil then
|
||||||
|
pulseaudio.sink = scallback()
|
||||||
|
end
|
||||||
|
|
||||||
widget = pulseaudio.widget
|
widget = pulseaudio.widget
|
||||||
settings()
|
settings()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue