2013-09-07 12:39:52 +02:00
|
|
|
Shows and controls alsa volume with a textbox.
|
|
|
|
|
|
|
|
myvolume = lain.widgets.alsa()
|
|
|
|
|
|
|
|
* Left click: Launch `alsamixer` in your `terminal`.
|
|
|
|
* Right click: Mute/unmute.
|
|
|
|
* Scroll wheel: Increase/decrase volume.
|
|
|
|
|
|
|
|
The function takes a table as optional argument, which can contain:
|
|
|
|
|
|
|
|
Variable | Meaning | Type | Default
|
|
|
|
--- | --- | --- | ---
|
|
|
|
`channel` | Mixer channel | string | "Master"
|
|
|
|
`step` | Step at which volume is increased/decreased | string | "1%"
|
|
|
|
`header` | Text to show before value | string | " Vol "
|
|
|
|
`header_color` | Header color | string | `beautiful.fg_normal` or "#FFFFFF"
|
|
|
|
`color` | Value color | string | `beautiful.fg_focus` or "#FFFFFF"
|
|
|
|
|
|
|
|
and outputs the following table:
|
|
|
|
|
2013-09-07 13:18:36 +02:00
|
|
|
Variable | Meaning | Type
|
|
|
|
--- | --- | ---
|
|
|
|
`widget` | The widget | `wibox.widget.textbox`
|
|
|
|
`channel` | Alsa channel | string
|
|
|
|
`step` | Increase/decrease step | string
|
2013-09-07 13:25:10 +02:00
|
|
|
`notify` | Update `widget` | function
|
2013-09-07 12:39:52 +02:00
|
|
|
|
|
|
|
Finally, you can control the widget with key bindings like these:
|
|
|
|
|
2013-09-07 13:35:37 +02:00
|
|
|
-- Volume control
|
|
|
|
awful.key({ altkey }, "Up",
|
|
|
|
function ()
|
|
|
|
awful.util.spawn("amixer sset " .. volume.channel .. " " .. volume.step .. "+")
|
|
|
|
volume.notify()
|
|
|
|
end),
|
|
|
|
awful.key({ altkey }, "Down",
|
|
|
|
function ()
|
|
|
|
awful.util.spawn("amixer sset " .. volume.channel .. " " .. volume.step .. "-")
|
|
|
|
volume.notify()
|
|
|
|
end),
|
|
|
|
awful.key({ altkey }, "m",
|
|
|
|
function ()
|
|
|
|
awful.util.spawn("amixer set Master playback toggle")
|
|
|
|
volume.notify()
|
|
|
|
end),
|
|
|
|
awful.key({ altkey, "Control" }, "m",
|
|
|
|
function ()
|
|
|
|
awful.util.spawn("amixer set Master playback 100%", false )
|
|
|
|
volume.notify()
|
|
|
|
end),
|
2013-09-07 12:39:52 +02:00
|
|
|
|
|
|
|
where `altkey = "Mod1"`.
|