From e52c38e0f9ddf1299ff4d37c838007b4ebfdeaf7 Mon Sep 17 00:00:00 2001 From: Maxim Gordeev Date: Thu, 25 Feb 2016 07:37:01 +0300 Subject: [PATCH] Add callback function for to update sink --- widgets/pulseaudio.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index 589249f..d243b8d 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -23,6 +23,7 @@ local function worker(args) local args = args or {} local timeout = args.timeout or 5 local settings = args.settings or function() end + local scallback = args.scallback or function() end 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'", @@ -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.muted = string.match(s, "muted: (%S+)") + if scallback ~= nil then + pulseaudio.sink = scallback() + end + widget = pulseaudio.widget settings() end