a986d8f211f3c9492fc1ae1b1c5d1a23e15b1bcd
[dotfiles/.git] / .config / awesome / lain / wiki / alsabar.md
1 ## Usage
2
3 [Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage)
4
5 ### Description
6
7 Shows ALSA volume with a progressbar; provides tooltips and notifications.
8
9 ```lua
10 local volume = lain.widget.alsabar()
11 ```
12
13 ## Input table
14
15 Variable | Meaning | Type | Default
16 --- | --- | --- | ---
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
36
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`.
38
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.
40
41 To set the maximum number of ticks to display in the notification, define `max_ticks` (integer) in `notification_preset`.
42
43 `settings` can use the following variables:
44
45 Variable | Meaning | Type | Values
46 --- | --- | --- | ---
47 `volume_now.level` | Volume level | integer | 0-100
48 `volume_now.status` | Device status | string | "on", "off"
49
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.
51
52 ### Default colors
53
54 Variable | Meaning | Type | Default
55 --- | --- | --- | ---
56 `background` | Bar backgrund color | string | "#000000"
57 `mute` | Bar mute color | string | "#EB8F8F"
58 `unmute` | Bar unmute color | string | "#A4CE8A"
59
60 ### Default `notification_preset`
61
62 ```lua
63 notification_preset = {
64     font = "Monospace 10"
65 }
66 ```
67
68 ## Output table
69
70 Variable | Meaning | Type
71 --- | --- | ---
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`
77
78 ## Buttons
79
80 If you want buttons, just add the following after your widget in `rc.lua`.
81
82 ```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))
86     end),
87     awful.button({}, 2, function() -- middle click
88         os.execute(string.format("%s set %s 100%%", volume.cmd, volume.channel))
89         volume.update()
90     end),
91     awful.button({}, 3, function() -- right click
92         os.execute(string.format("%s set %s toggle", volume.cmd, volume.togglechannel or volume.channel))
93         volume.update()
94     end),
95     awful.button({}, 4, function() -- scroll up
96         os.execute(string.format("%s set %s 1%%+", volume.cmd, volume.channel))
97         volume.update()
98     end),
99     awful.button({}, 5, function() -- scroll down
100         os.execute(string.format("%s set %s 1%%-", volume.cmd, volume.channel))
101         volume.update()
102     end)
103 ))
104 ```
105
106 ## Keybindings
107
108 Read [here](https://github.com/lcpz/lain/wiki/alsa#keybindings). If you want notifications, use `volume.notify()` instead of `volume.update()`.