Easy switching between default sink or source in pulseaudio widget

This commit is contained in:
Calvin Timmer 2017-02-02 14:47:42 +01:00
parent e015d5ec26
commit c563603a2e
1 changed files with 5 additions and 3 deletions

View File

@ -19,11 +19,12 @@ local string = { gmatch = string.gmatch,
local function factory(args)
local pulseaudio = {}
local args = args or {}
local devicetype = args.devicetype or "sink"
local timeout = args.timeout or 5
local settings = args.settings or function() end
local scallback = args.scallback
pulseaudio.cmd = args.cmd or "pacmd list-sinks | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'"
pulseaudio.cmd = args.cmd or "pacmd list-" .. devicetype .. "s | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'"
pulseaudio.widget = wibox.widget.textbox()
@ -33,8 +34,9 @@ local function factory(args)
helpers.async({ shell, "-c", pulseaudio.cmd }, function(s)
volume_now = {
index = string.match(s, "index: (%S+)") or "N/A",
sink = string.match(s, "device.string = \"(%S+)\"") or "N/A",
muted = string.match(s, "muted: (%S+)") or "N/A"
device = string.match(s, "device.string = \"(%S+)\"") or "N/A",
sink = device, -- legacy API
muted = string.match(s, "muted: (%S+)") or "N/A"
}
local ch = 1