Debian Codegraph @

vicious/docs/source/contrib.rst

raw
1 Contrib Widget Types
2 ====================
3
4 Contrib libraries, or widget types, are extra snippets of code you can use.
5 Some are for less common hardware, and others were contributed by Vicious users.
6 The contrib directory also holds widget types that were obsoleted or rewritten.
7 Contrib widgets will not be imported by init unless you explicitly enable it,
8 or load them in your ``rc.lua``.
9
10 Usage within Awesome
11 --------------------
12
13 To use contrib widgets uncomment the line that loads them in ``init.lua``.
14 Or you can load them in your rc.lua after you require Vicious:
15
16 .. code-block:: lua
17
18 local vicious = require"vicious"
19 vicious.contrib = require"vicious.contrib"
20
21 Widget Types
22 ------------
23
24 Most widget types consist of worker functions that take the ``format`` argument
25 given to :lua:func:`vicious.register` as the first argument,
26 ``warg`` as the second, and return a table of values to insert in
27 the format string. But we have not insisted on this coding style in contrib.
28 So widgets like PulseAudio have emerged that are different. These widgets
29 could also depend on Lua libraries that are not distributed with the
30 core Lua distribution. Ease of installation and use does not necessarily
31 have to apply to contributed widgets.
32
33 vicious.contrib.ac
34 ^^^^^^^^^^^^^^^^^^
35
36 Provide status about the power supply (AC).
37
38 Supported platforms: GNU/Linux, requiring ``sysfs``.
39
40 * Argument: the AC device, i.e ``"AC"`` or ``"ACAD"``. The device is linked
41 under ``/sys/class/power_supply/`` and should have a file called ``online``.
42 * Returns ``{"On"}`` if AC is connected, else ``{"Off"}``.
43 If AC doesn't exist, returns ``{"N/A"}``.
44
45 vicious.contrib.ati
46 ^^^^^^^^^^^^^^^^^^^
47
48 Provides various info about ATI GPU status.
49
50 Supported platforms: GNU/Linux, requiring ``sysfs``.
51
52 * Argument: card ID, e.g. ``"card0"`` (and where possible,
53 uses ``debugfs`` to gather data on radeon power management)
54 * Returns a table with string keys: ``${method}``, ``${dpm_state}``,
55 ``${dpm_perf_level}``, ``${profile}``, ``${engine_clock mhz}``,
56 ``${engine_clock khz}``, ``${memory_clock mhz}``, ``${memory_clock khz}``,
57 ``${voltage v}``, ``${voltage mv}``
58
59 vicious.contrib.batpmu
60 ^^^^^^^^^^^^^^^^^^^^^^
61
62 vicious.contrib.batproc
63 ^^^^^^^^^^^^^^^^^^^^^^^
64
65 vicious.contrib.btc
66 ^^^^^^^^^^^^^^^^^^^
67
68 Provides current Bitcoin price in any currency by
69 [code](https://en.wikipedia.org/wiki/ISO_4217).
70
71
72 Platform independent, although requiring ``curl`` and either
73 [lua-cjson](https://github.com/mpx/lua-cjson/) or
74 [luajson](https://github.com/harningt/luajson/).
75
76 * Argument: currency code, e.g. ``"usd"``, ``"rub"`` and other.
77 Default to ``"usd"``.
78 * Returns a table with string key ``${price}``.
79
80 vicious.contrib.buildbot
81 ^^^^^^^^^^^^^^^^^^^^^^^^
82
83 Provides last build status for configured buildbot builders
84 (http://trac.buildbot.net/).
85
86 Supported platforms: platform independent, though requiring Lua JSON parser
87 [luajson](https://github.com/harningt/luajson/).
88
89 Returns build status in the format:
90 ``[<builderName>.<currentBuildNumber>.<lastSuccessfulBuildNumber>]``.
91 If ``<currentBuildNumber>`` is the same as ``<lastSuccessfulBuildNumber>``
92 only one number is displayed. ``<buildNumber>`` colors:
93 red---failed, green---successful, yellow---in progress.
94
95 vicious.contrib.countfiles
96 ^^^^^^^^^^^^^^^^^^^^^^^^^^
97
98 vicious.contrib.cmus
99 ^^^^^^^^^^^^^^^^^^^^
100
101 .. note::
102
103 This widget type has been promoted to :ref:`widgets`.
104
105 Provides cmus player information using ``cmus-remote``.
106
107 Supported platforms: platform independent.
108
109 * Argument: a table whose first field is the socket including host (or nil).
110 * Returns a table with string keys: ``${status}``, ``${artist}``, ``${title}``,
111 ``${duration}``, ``${file}``, ``${continue}``, ``${shuffle}``, ``${repeat}``.
112
113 vicious.contrib.dio
114 ^^^^^^^^^^^^^^^^^^^
115
116 Provides I/O statistics for requested storage devices.
117
118 * Argument: the disk as an argument, i.e. ``"sda"``, or a specific
119 partition, i.e. ``"sda/sda2"``
120 * Returns a table with string keys: ``${total_s}``, ``${total_kb}``,
121 ``${total_mb}``, ``${read_s}``, ``${read_kb}``, ``${read_mb}``,
122 ``${write_s}``, ``${write_kb}``, ``${write_mb}`` and ``${sched}``
123
124 vicious.contrib.mpc
125 ^^^^^^^^^^^^^^^^^^^
126
127 vicious.contrib.netcfg
128 ^^^^^^^^^^^^^^^^^^^^^^
129
130 vicious.contrib.net
131 ^^^^^^^^^^^^^^^^^^^
132
133 vicious.contrib.openweather
134 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
135
136 Provides weather information for a requested city from OpenWeatherMap (OWM)
137
138 * Argument: a table containing the fields ``city_id`` with the OWM city ID, e.g.
139 ``"2643743"`` and ``app_id`` with the the OWM app ID, e.g
140 ``"4c57f0c88d9844630327623633ce269cf826ab99"``
141 * Returns a table with string keys: ``${city}``, ``${humid}``, ``${press}``,
142 ``${sky}``, ``${sunrise}``, ``${sunset}``, ``${temp c}``, ``${temp max c}``,
143 ``${temp min c}``, ``${weather}``, ``${wind aim}``, ``${wind deg}``,
144 ``${wind kmh}`` and ``${wind mps}``,
145
146 vicious.contrib.nvinf
147 ^^^^^^^^^^^^^^^^^^^^^
148
149 Provides GPU utilization, core temperature, clock frequency information about
150 Nvidia GPU from nvidia-settings
151
152 Supported Platforms: platform independent
153
154 * Argument (optional): card ID as an argument, e.g. ``"1"``, default to ID 0
155 * Returns an array containing:
156
157 * ``$1``: Usage of GPU core
158 * ``$2``: Usage of GPU memory
159 * ``$3``: Usage of video engine
160 * ``$4``: Usage of PCIe bandwidth
161 * ``$5``: Temperature of requested graphics device
162 * ``$6``: Frequency of GPU core
163 * ``$7``: Memory transfer rate
164
165 vicious.contrib.nvsmi
166 ^^^^^^^^^^^^^^^^^^^^^
167
168 Provides (very basic) information about Nvidia GPU status from SMI
169
170 Supported platforms: platform independent
171
172 * Argument (optional): card ID as an argument, e.g. ``"1"``, default to ID 0
173 * Returns an array containing temperature of requested graphics device
174
175 vicious.contrib.ossvol
176 ^^^^^^^^^^^^^^^^^^^^^^
177
178 vicious.contrib.pop
179 ^^^^^^^^^^^^^^^^^^^
180
181 vicious.contrib.pulse
182 ^^^^^^^^^^^^^^^^^^^^^
183
184 Provides volume levels of requested pulseaudio sinks and functions to
185 manipulate them
186
187 * Argument (optional): name of a sink as an optional argument. A number will
188 be interpret as an index, if no argument is given, it will take the
189 first-best. To get a list of available sinks run
190 ``pacmd list-sinks | grep 'name:'``.
191 * Returns an array whose only element is the volume level
192
193 vicious.contrib.pulse.add(percent[, sink])
194 """"""""""""""""""""""""""""""""""""""""""
195
196 * ``percent`` is the percentage to increment or decrement the volume
197 from its current value
198 * Returns the exit status of ``pacmd``
199
200 vicious.contrib.pulse.toggle([sink])
201 """"""""""""""""""""""""""""""""""""
202
203 * Toggles mute state
204 * Returns the exit status of ``pacmd``
205
206 vicious.contrib.rss
207 ^^^^^^^^^^^^^^^^^^^
208
209 vicious.contrib.sensors
210 ^^^^^^^^^^^^^^^^^^^^^^^
211
212 vicious.contrib.wpa
213 ^^^^^^^^^^^^^^^^^^^
214
215 Provides information about the wifi status.
216
217 Supported Platforms: platform independent, requiring ``wpa_cli``.
218
219 * Argument: the interface, e.g. ``"wlan0"`` or ``"wlan1"``
220 * Returns a table with string keys:
221 ``${ssid}``, ``${qual}``, ``${ip}``, ``${bssid}``
222
223 Usage Examples
224 --------------
225
226 PulseAudio Widget
227 ^^^^^^^^^^^^^^^^^
228
229 .. code-block:: lua
230
231 vol = wibox.widget.textbox()
232 local sink = "alsa_output.pci-0000_00_1b.0.analog-stereo"
233 vicious.register(vol, vicious.contrib.pulse, " $1%", 2, sink)
234 vol:buttons(awful.util.table.join(
235 awful.button({}, 1, function () awful.util.spawn("pavucontrol") end),
236 awful.button({}, 4, function () vicious.contrib.pulse.add(5, sink) end),
237 awful.button({}, 5, function () vicious.contrib.pulse.add(-5, sink) end)))
238
239 Buildbot Widget
240 ^^^^^^^^^^^^^^^
241
242 .. code-block:: lua
243
244 buildbotwidget = wibox.widget.textbox()
245 vicious.register(
246 buildbotwidget, vicious.contrib.buildbot, "$1,", 3600,
247 { { builder="coverage", url="http://buildbot.buildbot.net" },
248 { builder="tarball-slave", url="http://buildbot.buildbot.net" } })