My configuration files for Debian/Ubuntu applications
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. ## Usage
  2. [Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage)
  3. ### Description
  4. Shows ALSA volume.
  5. ```lua
  6. local volume = lain.widget.alsa()
  7. ```
  8. ## Input table
  9. Variable | Meaning | Type | Default
  10. --- | --- | --- | ---
  11. `timeout` | Refresh timeout (in seconds) | integer | 5
  12. `cmd` | Alsa mixer command | string | "amixer"
  13. `channel` | Mixer channel | string | "Master"
  14. `togglechannel` | Toggle channel | string | `nil`
  15. `settings` | User settings | function | empty function
  16. `widget` | Widget to render | function | `wibox.widget.textbox`
  17. `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`.
  18. `settings` can use the following variables:
  19. Variable | Meaning | Type | Values
  20. --- | --- | --- | ---
  21. `volume_now.level` | Volume level | integer | 0-100
  22. `volume_now.status` | Device status | string | "on", "off"
  23. ## Output table
  24. Variable | Meaning | Type
  25. --- | --- | ---
  26. `widget` | The widget | `wibox.widget.textbox`
  27. `channel` | ALSA channel | string
  28. `update` | Update `widget` | function
  29. ## Toggle channel
  30. 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. You can get the device ID with `scontents` command.
  31. For instance, if card number is 1 and S/PDIF number is 3:
  32. ```shell
  33. $ amixer -c 1 scontents
  34. Simple mixer control 'Master',0
  35. Capabilities: volume
  36. Playback channels: Front Left - Front Right
  37. Capture channels: Front Left - Front Right
  38. Limits: 0 - 255
  39. Front Left: 255 [100%]
  40. Front Right: 255 [100%]
  41. Simple mixer control 'IEC958',0
  42. Capabilities: pswitch pswitch-joined
  43. Playback channels: Mono
  44. Mono: Playback [on]
  45. Simple mixer control 'IEC958',1
  46. Capabilities: pswitch pswitch-joined
  47. Playback channels: Mono
  48. Mono: Playback [on]
  49. Simple mixer control 'IEC958',2
  50. Capabilities: pswitch pswitch-joined
  51. Playback channels: Mono
  52. Mono: Playback [on]
  53. Simple mixer control 'IEC958',3
  54. Capabilities: pswitch pswitch-joined
  55. Playback channels: Mono
  56. Mono: Playback [on]
  57. ```
  58. you have to set `togglechannel = "IEC958,3"`.
  59. ## Buttons
  60. If you want buttons, just add the following after your widget in `rc.lua`.
  61. ```lua
  62. volume.widget:buttons(awful.util.table.join(
  63. awful.button({}, 1, function() -- left click
  64. awful.spawn(string.format("%s -e alsamixer", terminal))
  65. end),
  66. awful.button({}, 2, function() -- middle click
  67. os.execute(string.format("%s set %s 100%%", volume.cmd, volume.channel))
  68. volume.update()
  69. end),
  70. awful.button({}, 3, function() -- right click
  71. os.execute(string.format("%s set %s toggle", volume.cmd, volume.togglechannel or volume.channel))
  72. volume.update()
  73. end),
  74. awful.button({}, 4, function() -- scroll up
  75. os.execute(string.format("%s set %s 1%%+", volume.cmd, volume.channel))
  76. volume.update()
  77. end),
  78. awful.button({}, 5, function() -- scroll down
  79. os.execute(string.format("%s set %s 1%%-", volume.cmd, volume.channel))
  80. volume.update()
  81. end)
  82. ))
  83. ```
  84. ## Keybindings
  85. You can control the widget with keybindings like these:
  86. ```lua
  87. -- ALSA volume control
  88. awful.key({ altkey }, "Up",
  89. function ()
  90. os.execute(string.format("amixer set %s 1%%+", volume.channel))
  91. volume.update()
  92. end),
  93. awful.key({ altkey }, "Down",
  94. function ()
  95. os.execute(string.format("amixer set %s 1%%-", volume.channel))
  96. volume.update()
  97. end),
  98. awful.key({ altkey }, "m",
  99. function ()
  100. os.execute(string.format("amixer set %s toggle", volume.togglechannel or volume.channel))
  101. volume.update()
  102. end),
  103. awful.key({ altkey, "Control" }, "m",
  104. function ()
  105. os.execute(string.format("amixer set %s 100%%", volume.channel))
  106. volume.update()
  107. end),
  108. awful.key({ altkey, "Control" }, "0",
  109. function ()
  110. os.execute(string.format("amixer set %s 0%%", volume.channel))
  111. volume.update()
  112. end),
  113. ```
  114. where `altkey = "Mod1"`.
  115. ### Muting with PulseAudio
  116. If you are using this widget in conjuction with PulseAudio, add the option `-D pulse` to the muting keybinding, like this:
  117. ```lua
  118. awful.key({ altkey }, "m",
  119. function ()
  120. os.execute(string.format("amixer -D pulse set %s toggle", volume.togglechannel or volume.channel))
  121. volume.update()
  122. end),
  123. ```