aboutsummaryrefslogtreecommitdiff
path: root/README
blob: 7c3bc08bf3c1c10587284b175393062371bfa1e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
vicious
=======
vicious is a modular widget library for "awesome" window manager,
derived from the "Wicked" widget library. It has some of the old
Wicked widget types, a few of them rewritten, and a good number of
new widgets:

  http://git.sysphere.org/vicious/


Usage
-----
To use vicious copy it to the ~/.config/awesome directory, edit
init.lua and comment out all the widgets you don't need from the
"Configure widgets" list. Then add:

  require("vicious")

...to the top of your rc.lua.


Once you create a widget (as a: textbox, graph or a progressbar) call
vicious.register() to register it with vicious:

  vicious.register(widget, type, format, interval, warg)

    widget
      - widget created with widget() or awful.widget() (in case of a
        graph or a progressbar)

    type
      - one of the available widget types, see below for a list

    format
      - string argument or a function
        - $1, $2, $3... will be replaced by their respective value
          returned by the widget type, some widget types return tables
          with custom keys, in that case use: ${key}
      - function
        - function(widget, args) can be used to manipulate data
          returned by the widget type, more about this below

    interval
      - number of seconds between updates of the widget, 2s by
        default, also read the "Power" section below

    warg
      - some widget types require an argument to be passed, for example
        the battery ID


Other Functions
---------------
Unregister a widget:

  vicious.unregister(widget, keep)

    keep
      - if true widget will be suspended, waiting to be activated

Suspend all widgets:

  vicious.suspend()

    - example automation script for the "laptop-mode-tools" start-stop
      module: http://sysphere.org/~anrxc/local/sources/lmt-vicious.sh

Restart suspended widgets:

  vicious.activate(widget)

    widget
      - if provided, only that widget will be activated

Enable caching for a widget:

  vicious.enable_caching(widget_type)

    - enable caching of values returned by a widget type


Power
-----
When a lot of widgets are in use they, and awesome, can generate a lot
of wake-ups and also be very expensive for system resources. This is
especially important when running on battery power. Suspending widgets
is one way to prevent widgets from draining your battery.

Vicious can also cache values returned by widget types. Caching
enables you to have multiple widgets using the same widget type and
its worker function will be executed only once. However be careful
with those widgets that require a widget argument to be passed. If you
are requesting information for different devices then caching is
useless and can lead to confusion.

Update intervals also play a big role, and you can save a lot of power
with a smart approach to intervals. You should avoid intervals like:
5, 10, 30, 60... to avoid harmonics. If you take the 60-second mark as
an example, all of your widgets would be executed at that
point. Instead think about using only prime numbers, in that case you
will have only a few widgets executed at any given time interval. When
choosing intervals also consider what a widget actually does. Some
widgets read files that reside in memory, others call external
utilities and some, like the mbox widget, read very big files.


Widget types
------------
Widget types consist of worker functions that take the "format"
argument given to vicious.register as the first argument, "warg" as
the second, and return a table of values to insert in the format
string.

vicious.widgets.cpu
  - provides CPU usage for all available CPUs/cores

vicious.widgets.cpuinf
  - provides speed and cache information for all available CPUs/cores

vicious.widgets.cpufreq
  - provides freq, voltage and governor info for a requested CPU
  - takes the CPU ID as an argument, i.e. "cpu0"

vicious.widgets.thermal
  - provides temperature levels of ACPI thermal zones
  - takes the thermal zone as an argument, i.e. "TZS0"

vicious.widgets.load
  - provides system load averages for the past 1, 5, and 15 minutes

vicious.widgets.uptime
  - provides system uptime information

vicious.widgets.bat
  - provides state, charge, and remaining time for a requested battery
  - takes battery ID as an argument, i.e. "BAT0"

vicious.widgets.batat
  - provides state, charge, and remaining time for all batteries using
    acpitool

vicious.widgets.mem
  - provides RAM and Swap usage statistics

vicious.widgets.fs
  - provides file system disk space usage
  - takes an (optional) argument which, if true, includes remote file
    systems, only local file systems are included by default

vicious.widgets.dio
  - provides I/O statistics for requested storage devices
  - takes the disk as an argument, i.e. "/dev/hda"

vicious.widgets.hddtemp
  - provides hard drive temperatures using the hddtemp daemon
  - takes the hddtemp listening port as an argument, or defaults to
    port 7634

vicious.widgets.net
  - provides usage statistics for all network interfaces

vicious.widgets.wifi
  - provides wireless information for a requested interface
  - takes the network interface as an argument, i.e. "wlan0"

vicious.widgets.mbox
  - provides the subject of last e-mail in a mbox file
  - takes the full path to the mbox as an argument

vicious.widgets.mboxc
  - provides the count of total, old and new messages in a mbox
  - takes the full path to the mbox as an argument

vicious.widgets.mdir
  - provides a number of new and unread messages in a Maildir
    structure
  - takes the full path to the Maildir structure as an argument

vicious.widgets.gmail
  - provides count of new and subject of last e-mail in a Gmail inbox
  - takes a table with Gmail login information as an argument

vicious.widgets.entropy
  - provides available system entropy
  - takes the poolsize as an argument, or defaults to Linux 2.6
    default entropy pool of 4096-bits

vicious.widgets.org
  - provides agenda statistics for Emacs org-mode
  - takes a table with full paths to agenda files, that will be
    parsed, as an argument

vicious.widgets.pacman
  - provides number of pending updates on Arch Linux

vicious.widgets.mpd
  - provides the currently playing song in MPD

vicious.widgets.volume
  - provides volume levels of requested ALSA mixers
  - takes the ALSA channel as an argument, i.e. "Master"

vicious.widgets.weather
  - provides weather information for a requested station
  - takes the ICAO station code as an argument, i.e. "LDRI"

vicious.widgets.date
  - provides access to os.date, with optional custom formatting;
    provided as the format string


Custom widget types
-------------------
Use any of the existing widgets as a starting point for your
own. Write a quick worker function that does the work and plug it
in. How data will be formatted, will it be red or blue, should be
defined in rc.lua (or somewhere else, outside the actual widget).


Format functions
----------------
You can use a function instead of a string as the format parameter, so
you are able to check the value returned by the widget type and change
it. You can change the color of the battery widget when it goes below
a certain point, or hide widgets when they return a certain value,
or...

  - do not confuse this with just coloring the widget, in those cases
    standard markup can be inserted into the format string

The format function will get the widget as its first argument, and a
table with the values otherwise inserted into the format string as its
second argument, and should return the text to be used for the widget.

Example widget
  mpdwidget = widget({ type = 'textbox', name = 'mpdwidget' })
  vicious.register(mpdwidget,vicious.widgets.mpd, 
    function (widget, args)
      if   args[1] == "Stopped" then return ''
      else return '<span color="white">MPD:</span> '..args[1]
      end
    end)

  - hides the mpd widget when there is no song playing, executed every
    2 seconds (the default interval)


Usage examples
--------------
Remember, beside creating and registering widgets you have to add them
to a wibox in order to display them.

MPD widget
  mpdwidget = widget({ type = 'textbox', name = 'mpdwidget' })
  vicious.register(mpdwidget, vicious.widgets.mpd, '$1', 11)

  - executed every 11 seconds, takes no arguments

Memory widget
  memwidget = widget({ type = 'textbox', name = 'memwidget' })
  vicious.enable_caching(vicious.widgets.mem)
  vicious.register(memwidget, vicious.widgets.mem, '$1 ($2MB/$3MB)', 13)

  - executed every 13 seconds, appends "MB" to 2nd and 3rd returned
    values and enables caching of this widget type

HDD temperature widget
  hddtempwidget = widget({ type = 'textbox', name = 'hddtempwidget' })
  vicious.register(hddtempwidget, vicious.widgets.hddtemp, '${/dev/sda}°C', 19)

  - executed every 19 seconds, requests the temperature level of the
    ${/dev/sda} key/disk and appends "°C" to the returned value, does
    not provide the port argument so default port is used

Mbox widget
  mboxwidget = widget({ type = 'textbox', name = 'mboxwidget' })
  vicious.register(mboxwidget, vicious.widgets.mbox, '$1', 5, '/home/user/mail/Inbox')

  - executed every 5 seconds, provides full path to the mbox as an
    argument

Gmail widget
  gmailwidget = widget({ type = 'textbox', name = 'gmailwidget' })
  vicious.register(gmailwidget, vicious.widgets.gmail, 'Mail: ${count}', 601, {'user', 'pass'})

  - executed every 10 minutes, provides a table with login information
    as an argument, prepends "Mail: " to the returned value

Battery widget
  batwidget = awful.widget.progressbar({ layout = awful.widget.layout.horizontal.rightleft })
  batwidget:set_width(8)
  batwidget:set_height(10)
  batwidget:set_vertical(true)
  batwidget:set_background_color('#494B4F')
  batwidget:set_border_color(nil)
  batwidget:set_color('#AECF96')
  batwidget:set_gradient_colors({
    '#AECF96',
    '#88A175',
    '#FF5656' })
  vicious.register(batwidget, vicious.widgets.bat, '$2', 61, 'BAT0')

  - executed every 61 seconds, requests the current battery charge
    level and display a progressbar, provides "BAT0" battery ID as an
    argument

CPU usage widget
  cpuwidget = awful.widget.graph({ layout = awful.widget.layout.horizontal.rightleft })
  cpuwidget:set_width(50)
  cpuwidget:set_scale(false)
  cpuwidget:set_max_value(100)
  cpuwidget:set_background_color('#494B4F')
  cpuwidget:set_border_color('#3F3F3F')
  cpuwidget:set_color('#FF5656')
  cpuwidget:set_gradient_colors({
    '#FF5656',
    '#88A175',
    '#AECF96' })
  vicious.register(cpuwidget, vicious.widgets.cpu, '$1', 3)

  - executed every 3 seconds, feeds the graph with total usage
    percentage of all CPUs/cores


All other widgets are used in the same manner, read each widget you
are interested in to see what data it returns. You can also use
authors rc.lua as a reference to see how it all fits into the big
picture:

  http://git.sysphere.org/awesome-configs/


Other
-----
Also read "awesome" manual pages:

  awesome(1)  awesomerc(5) 


Authors
-------
Vicious, written by:
  Adrian C. (anrxc) <anrxc@sysphere.org>

Wicked, written by:
  Lucas de Vries <lucas@glacicle.com>