2013-09-07 14:35:43 +02:00
|
|
|
[<- widgets](https://github.com/copycat-killer/lain/wiki/Widgets)
|
|
|
|
|
2013-09-07 14:15:53 +02:00
|
|
|
Shows and controls alsa volume with a textbox.
|
2013-09-07 12:39:52 +02:00
|
|
|
|
2013-09-10 22:31:03 +02:00
|
|
|
volume = lain.widgets.alsa()
|
2013-09-07 12:39:52 +02:00
|
|
|
|
2013-09-10 22:25:23 +02:00
|
|
|
### input table
|
2013-09-07 12:39:52 +02:00
|
|
|
|
|
|
|
Variable | Meaning | Type | Default
|
|
|
|
--- | --- | --- | ---
|
2013-09-10 22:25:23 +02:00
|
|
|
`timeout` | Refresh timeout seconds | int | 5
|
2013-09-07 12:39:52 +02:00
|
|
|
`channel` | Mixer channel | string | "Master"
|
2013-09-10 22:25:23 +02:00
|
|
|
`settings` | User settings | function | empty function
|
|
|
|
|
2013-09-10 23:00:59 +02:00
|
|
|
`settings` can use the following variables:
|
2013-09-07 12:39:52 +02:00
|
|
|
|
2013-09-10 22:25:23 +02:00
|
|
|
Variable | Meaning | Type | Values
|
|
|
|
--- | --- | --- | ---
|
|
|
|
volume.level | Self explained | int | 0-100
|
|
|
|
volume.status | Device status | string | "on", "off"
|
2013-09-09 13:52:53 +02:00
|
|
|
|
2013-09-10 22:25:23 +02:00
|
|
|
### output table
|
2013-09-07 12:39:52 +02:00
|
|
|
|
2013-09-07 13:18:36 +02:00
|
|
|
Variable | Meaning | Type
|
|
|
|
--- | --- | ---
|
|
|
|
`widget` | The widget | `wibox.widget.textbox`
|
2013-09-11 18:39:38 +02:00
|
|
|
`update` | Update `widget` | function
|
2013-09-07 12:39:52 +02:00
|
|
|
|
2013-09-10 22:29:07 +02:00
|
|
|
You can control the widget with key bindings like these:
|
2013-09-07 12:39:52 +02:00
|
|
|
|
2013-09-07 13:35:37 +02:00
|
|
|
-- Volume control
|
|
|
|
awful.key({ altkey }, "Up",
|
|
|
|
function ()
|
2013-09-10 22:25:23 +02:00
|
|
|
awful.util.spawn("amixer sset Master 1%+")
|
2013-09-11 18:39:38 +02:00
|
|
|
volume.update()
|
2013-09-07 13:35:37 +02:00
|
|
|
end),
|
|
|
|
awful.key({ altkey }, "Down",
|
|
|
|
function ()
|
2013-09-10 22:25:23 +02:00
|
|
|
awful.util.spawn("amixer sset Master 1%-")
|
2013-09-11 18:39:38 +02:00
|
|
|
volume.update()
|
2013-09-07 13:35:37 +02:00
|
|
|
end),
|
|
|
|
awful.key({ altkey }, "m",
|
|
|
|
function ()
|
|
|
|
awful.util.spawn("amixer set Master playback toggle")
|
2013-09-11 18:39:38 +02:00
|
|
|
volume.update()
|
2013-09-07 13:35:37 +02:00
|
|
|
end),
|
|
|
|
awful.key({ altkey, "Control" }, "m",
|
|
|
|
function ()
|
|
|
|
awful.util.spawn("amixer set Master playback 100%", false )
|
2013-09-11 18:39:38 +02:00
|
|
|
volume.update()
|
2013-09-07 13:35:37 +02:00
|
|
|
end),
|
2013-09-07 12:39:52 +02:00
|
|
|
|
|
|
|
where `altkey = "Mod1"`.
|