diff --git a/README.md b/README.md index 985a2cc..a246c3f 100644 --- a/README.md +++ b/README.md @@ -447,8 +447,10 @@ Provides volume levels and state of requested mixers. Supported platforms: Linux (required tool: amixer), FreeBSD. - Arguments (per platform): - * Linux: takes the ALSA mixer control as an argument, i.e. `"Master"`, - optionally append the card ID or other options, i.e. `"PCM -c 0"` + * Linux: takes either a single argument containing the ALSA mixer control as + 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"` - Returns: * Linux: returns 1st value as the volume level and 2nd as the mute state of diff --git a/widgets/volume_linux.lua b/widgets/volume_linux.lua index c7751d4..0fd6820 100644 --- a/widgets/volume_linux.lua +++ b/widgets/volume_linux.lua @@ -26,8 +26,17 @@ local function worker(format, warg) ["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 - local f = io.popen("amixer -M get " .. helpers.shellquote(warg)) + local f = io.popen(cmd) local mixer = f:read("*all") f:close()