mirror of https://github.com/lcpz/lain.git
Easy switching between default sink or source in pulseaudio widget
This commit is contained in:
parent
e015d5ec26
commit
c563603a2e
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue