3 [Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage)
7 Shows ALSA volume with a progressbar; provides tooltips and notifications.
10 local volume = lain.widget.alsabar()
15 Variable | Meaning | Type | Default
17 `timeout` | Refresh timeout (in seconds) | integer | 5
18 `settings` | User settings | function | empty function
19 `width` | Bar width | number | 63
20 `height` | Bar height | number | 1
21 `margins` | Bar margins | number | 1
22 `paddings` | Bar paddings | number | 1
23 `ticks` | Set bar ticks on | boolean | false
24 `ticks_size` | Ticks size | integer | 7
25 `tick` | String for a notification tick | string | "|"
26 `tick_pre` | String for the left notification delimeter | string | "["
27 `tick_post` | String for the right notification delimeter | string | "]"
28 `tick_none` | String for an empty notification tick | string | " "
29 `cmd` | ALSA mixer command | string | "amixer"
30 `channel` | Mixer channel | string | "Master"
31 `togglechannel` | Toggle channel | string | `nil`
32 `tick` | The character usef for ticks in the notification | string | "|"
33 `colors` | Bar colors | table | see [Default colors](https://github.com/lcpz/lain/wiki/alsabar#default-colors)
34 `notification_preset` | Notification preset | table | See [default `notification_preset`](https://github.com/lcpz/lain/wiki/alsabar#default-notification_preset)
35 `followtag` | Display the notification on currently focused screen | boolean | false
37 `cmd` is useful if you need to pass additional arguments to `amixer`. For instance, you may want to define `cmd = "amixer -c X"` in order to set amixer with card `X`.
39 In case mute toggling can't be mapped to master channel (this happens, for instance, when you are using an HDMI output), define `togglechannel` as your S/PDIF device. Read [`alsa`](https://github.com/lcpz/lain/wiki/alsa#toggle-channel) page to know how.
41 To set the maximum number of ticks to display in the notification, define `max_ticks` (integer) in `notification_preset`.
43 `settings` can use the following variables:
45 Variable | Meaning | Type | Values
47 `volume_now.level` | Volume level | integer | 0-100
48 `volume_now.status` | Device status | string | "on", "off"
50 With multiple screens, the default behaviour is to show a visual notification pop-up window on the first screen. By setting `followtag` to `true` it will be shown on the currently focused tag screen.
54 Variable | Meaning | Type | Default
56 `background` | Bar backgrund color | string | "#000000"
57 `mute` | Bar mute color | string | "#EB8F8F"
58 `unmute` | Bar unmute color | string | "#A4CE8A"
60 ### Default `notification_preset`
63 notification_preset = {
70 Variable | Meaning | Type
72 `bar` | The widget | `wibox.widget.progressbar`
73 `channel` | ALSA channel | string
74 `notify` | The notification | function
75 `update` | Update `bar` | function
76 `tooltip` | The tooltip | `awful.tooltip`
80 If you want buttons, just add the following after your widget in `rc.lua`.
83 volume.bar:buttons(awful.util.table.join(
84 awful.button({}, 1, function() -- left click
85 awful.spawn(string.format("%s -e alsamixer", terminal))
87 awful.button({}, 2, function() -- middle click
88 os.execute(string.format("%s set %s 100%%", volume.cmd, volume.channel))
91 awful.button({}, 3, function() -- right click
92 os.execute(string.format("%s set %s toggle", volume.cmd, volume.togglechannel or volume.channel))
95 awful.button({}, 4, function() -- scroll up
96 os.execute(string.format("%s set %s 1%%+", volume.cmd, volume.channel))
99 awful.button({}, 5, function() -- scroll down
100 os.execute(string.format("%s set %s 1%%-", volume.cmd, volume.channel))
108 Read [here](https://github.com/lcpz/lain/wiki/alsa#keybindings). If you want notifications, use `volume.notify()` instead of `volume.update()`.