volume: allow to pass multiple arguments to amixer (#44)
* Added option for a table to configure volume widget, allowing device specification also. * Updated README.md with new configuration options for volume widget * volume: allow passing a list of commandline arguments
This commit is contained in:
parent
983253a27f
commit
750532a1d8
|
@ -447,8 +447,10 @@ Provides volume levels and state of requested mixers.
|
||||||
Supported platforms: Linux (required tool: amixer), FreeBSD.
|
Supported platforms: Linux (required tool: amixer), FreeBSD.
|
||||||
|
|
||||||
- Arguments (per platform):
|
- Arguments (per platform):
|
||||||
* Linux: takes the ALSA mixer control as an argument, i.e. `"Master"`,
|
* Linux: takes either a single argument containing the ALSA mixer control as
|
||||||
optionally append the card ID or other options, i.e. `"PCM -c 0"`
|
an argument, i.e. `"Master"`, or a table passed as command line arguments
|
||||||
|
to [amixer(1)](https://linux.die.net/man/1/amixer),
|
||||||
|
i.e `{"PCM", "-c", "0"}` or `{"Master", "-D", "pulse"}`.
|
||||||
* FreeBSD: takes the mixer control as an argument, i.e. `"vol"`
|
* FreeBSD: takes the mixer control as an argument, i.e. `"vol"`
|
||||||
- Returns:
|
- Returns:
|
||||||
* Linux: returns 1st value as the volume level and 2nd as the mute state of
|
* Linux: returns 1st value as the volume level and 2nd as the mute state of
|
||||||
|
|
|
@ -26,8 +26,17 @@ local function worker(format, warg)
|
||||||
["off"] = "♩" -- "M"
|
["off"] = "♩" -- "M"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if type(warg) ~= "table" then
|
||||||
|
warg = { warg }
|
||||||
|
end
|
||||||
|
|
||||||
|
local cmd = "amixer -M get "
|
||||||
|
for _, arg in ipairs(warg) do
|
||||||
|
cmd = cmd .. " " .. helpers.shellquote(arg)
|
||||||
|
end
|
||||||
|
|
||||||
-- Get mixer control contents
|
-- Get mixer control contents
|
||||||
local f = io.popen("amixer -M get " .. helpers.shellquote(warg))
|
local f = io.popen(cmd)
|
||||||
local mixer = f:read("*all")
|
local mixer = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue