Debian Codegraph @

obvious/volume_alsa/readme.md

raw symbols SCIP
1 ALSA volume widget
2 ==================
3
4 This widget uses amixer to get and set the current volume level and it also
5 exports functions you can use in keybindings to change the volume and
6 mute/unmute your soundcard.
7
8 To add this widget to your configuration, insert
9
10 ```lua
11 local volume_alsa = require 'obvious.volume_alsa'
12 ```
13
14 into the top of your rc.lua and add `volume_alsa()` to your wibox.
15
16 Optionally you can specify the cardid and channel to be controlled like this:
17
18 ```
19 volume_alsa(cardid, channel)
20 ```
21
22 the default channel is "Master"; you might need to set it to "PCM".
23
24 The following functions can be used to raise/lower the volume of a soundcard
25 and to mute it:
26
27 * `volume_alsa.raise(cardid, channel, v)` where `v` is optional and
28 the value to raise the volume by (1 is the default)
29 * `volume_alsa.lower(cardid, channel, v)` where `v` is optional and
30 the value to lower the volume by (1 is the default)
31 * `volume_alsa.mute(cardid, channel)`
32
33 If you left-click on a volume widget, the card is muted/unmuted. Right-clicking
34 opens a terminal with `alsamixer` in it. The terminal can be set with
35 `:set_term(t)` appended to the widget in the wibox. Changing it to `xterm`
36 would look like this:
37
38 ```lua
39 w.widgets = {
40 volume_alsa(0, "PCM"):set_term("xterm")
41 }
42 ```
43
44 Scrolling up and down on a widget changes the volume by 1. If you hold the
45 `Control` key while scrolling, the volume is changed by 5 and if you hold
46 `Shift`, it is changed by 10.
47
48 If you want to use the data gathered by this widget, you can use the function
49
50 ```lua
51 volume_alsa.get_data(cardid, channel)
52 ```
53
54 It returns nil on failure, otherwise it returns a table with the following fields:
55
56 * `volume`: a number representing the current volume from 0 to 100
57 * `mute` : a boolean value describing whether the channel is muted or not