@@ -130,6 +130,15 @@ enable caching of values returned by a widget type
130130
131131widget argument is a table with one or more widgets that will be updated
132132
133+ ** Get data from a widget:**
134+
135+ ``` Lua
136+ vicious .call (wtype , format , warg )
137+ ```
138+
139+ Fetch data from a widget to use it outside from the titlebar (see example
140+ section)
141+
133142
134143Widget types
135144------------
@@ -147,12 +156,10 @@ Supported platforms: Linux (required tools: `sysfs`), FreeBSD (required tools:
147156- Arguments (per platform):
148157 * Linux: takes battery ID as an argument, i.e. ` "BAT0" `
149158 * FreeBSD: takes optional battery ID as an argument, i.e. ` "batt" ` or ` "0" `
150- - Returns (per platform):
151- * Linux: returns 1st value as state of requested battery, 2nd as charge
152- level in percent, 3rd as remaining (charging or discharging) time, 4th
153- as the wear level in percent and 5th value for the present dis-/charge
154- rate in Watt.
155- * FreeBSD: see Linux
159+ - Returns:
160+ * Returns 1st value as state of requested battery, 2nd as charge level in
161+ percent, 3rd as remaining (charging or discharging) time, 4th as the wear
162+ level in percent and 5th value for the present dis-/charge rate in Watt.
156163
157164** vicious.widgets.cpu**
158165
@@ -162,7 +169,7 @@ Supported platforms: Linux, FreeBSD.
162169- Arguments:
163170 * None
164171- Returns:
165- * returns 1st value as usage of all CPUs/cores, 2nd as usage of first
172+ * Returns 1st value as usage of all CPUs/cores, 2nd as usage of first
166173 CPU/core, 3rd as usage of second CPU/core etc.
167174
168175** vicious.widgets.cpufreq**
@@ -188,7 +195,7 @@ Supported platforms: Linux.
188195- Arguments:
189196 * None
190197- Returns:
191- * returns a table with string keys, using CPU ID as a base: ` {cpu0 mhz} ` ,
198+ * Returns a table with string keys, using CPU ID as a base: ` {cpu0 mhz} ` ,
192199 ` {cpu0 ghz} ` , ` {cpu0 kb} ` , ` {cpu0 mb} ` , ` {cpu1 mhz} ` etc.
193200
194201** vicious.widgets.date**
@@ -198,10 +205,10 @@ format string - using regular date sequences.
198205Supported platforms: platform independent.
199206
200207- Arguments:
201- * takes optional time offset, in seconds, as an argument for example to
208+ * Takes optional time offset, in seconds, as an argument for example to
202209 calculate time zone differences, otherwise current time is formatted
203210- Returns:
204- * returns the output of os.date, formatted by provided sequences
211+ * Returns the output of os.date, formatted by provided sequences
205212
206213** vicious.widgets.dio**
207214
@@ -211,7 +218,7 @@ Supported platforms: Linux.
211218- Arguments:
212219 * None
213220- Returns:
214- * returns a table with string keys: ` {sda total_s} ` , ` {sda total_kb} ` ,
221+ * Returns a table with string keys: ` {sda total_s} ` , ` {sda total_kb} ` ,
215222 ` {sda total_mb} ` , ` {sda read_s} ` , ` {sda read_kb} ` , ` {sda read_mb} ` , ` {sda write_s} ` ,
216223 ` {sda write_kb} ` , ` {sda write_mb} ` , ` {sda iotime_ms} ` , ` {sda iotime_s} ` , ` {sdb1 total_s} ` etc.
217224
@@ -231,10 +238,10 @@ Provides usage of file system disk space.
231238Supported platforms: platform independent.
232239
233240- Arguments:
234- * takes an (optional) argument which, if true, includes remote file systems,
241+ * Takes an (optional) argument which, if true, includes remote file systems,
235242 only local file systems are included by default
236243- Returns:
237- * returns a table with string keys, using mount points as a base:
244+ * Returns a table with string keys, using mount points as a base:
238245 ` {/ size_mb} ` , ` {/ size_gb} ` , ` {/ used_mb} ` , ` {/ used_gb} ` , ` {/ used_p} ` ,
239246 ` {/ avail_mb} ` , ` {/ avail_gb} ` , ` {/ avail_p} ` , ` {/home size_mb} ` etc.
240247
@@ -250,21 +257,21 @@ This widget expects login information in your `~/.netrc` file, e. g.
250257afterwards. BE AWARE THAT MAKING THESE SETTINGS IS A SECURITY RISK!
251258
252259- Arguments:
253- * takes an (optional) argument, if it's a number subject will be truncated,
260+ * Takes an (optional) argument, if it's a number subject will be truncated,
254261 if a table, with 1st field as maximum length and 2nd the widget name (i.e.
255262 "gmailwidget"), scrolling will be used
256263- Returns:
257- * returns a table with string keys: {count} and {subject}
264+ * Returns a table with string keys: {count} and {subject}
258265
259266** vicious.widgets.hddtemp**
260267
261268Provides hard drive temperatures using the hddtemp daemon.
262269Supported platforms: Linux (required tools: ` hddtemp ` , ` curl ` ).
263270
264271- Arguments:
265- * takes the hddtemp listening port as an argument, or defaults to port 7634
272+ * Takes the hddtemp listening port as an argument, or defaults to port 7634
266273- Returns:
267- * returns a table with string keys, using hard drives as a base: ` {/dev/sda} `
274+ * Returns a table with string keys, using hard drives as a base: ` {/dev/sda} `
268275 and ` {/dev/sdc} ` for example
269276
270277** vicious.widgets.mbox**
@@ -273,23 +280,23 @@ Provides the subject of last e-mail in a mbox file.
273280Supported platforms: platform independent.
274281
275282- Arguments:
276- * takes the full path to the mbox as an argument, or a table with 1st field
283+ * Takes the full path to the mbox as an argument, or a table with 1st field
277284 as path, 2nd as maximum length and 3rd (optional) as widget name - if 3rd
278285 field is present scrolling will be used (note: the path will be escaped so
279286 special variables like ` ~ ` will not work, use ` os.getenv("HOME").."mail" `
280287 instead to access environment variables)
281288- Returns:
282- * returns 1st value as the subject of the last e-mail
289+ * Returns 1st value as the subject of the last e-mail
283290
284291** vicious.widgets.mboxc**
285292
286293Provides the count of total, old and new messages in mbox files.
287294Supported platforms: platform independent.
288295
289296- Arguments:
290- * takes a table with full paths to mbox files as an argument
297+ * Takes a table with full paths to mbox files as an argument
291298- Returns:
292- * returns 1st value as the total count of messages, 2nd as the count of old
299+ * Returns 1st value as the total count of messages, 2nd as the count of old
293300 messages and 3rd as the count of new messages
294301
295302** vicious.widgets.mdir**
@@ -299,9 +306,9 @@ structures/directories.
299306Supported platforms: platform independent.
300307
301308- Arguments:
302- * takes a table with full paths to Maildir structures as an argument
309+ * Takes a table with full paths to Maildir structures as an argument
303310- Returns:
304- * returns 1st value as the count of new messages and 2nd as the count of
311+ * Returns 1st value as the count of new messages and 2nd as the count of
305312 "old" messages lacking the Seen flag
306313
307314** vicious.widgets.mem**
@@ -326,12 +333,12 @@ Provides Music Player Daemon information.
326333Supported platforms: platform independent (required tools: ` curl ` ).
327334
328335- Arguments:
329- * takes a table as an argument, 1st field should be the password (or nil),
336+ * Takes a table as an argument, 1st field should be the password (or nil),
330337 2nd the hostname (or nil) and 3rd port (or nil) - if no argument is
331338 provided connection attempt will be made to localhost port 6600 with no
332339 password
333340- Returns:
334- * returns a table with string keys: ` {volume} ` , ` {state} ` , ` {Artist} ` , ` {Title} ` ,
341+ * Returns a table with string keys: ` {volume} ` , ` {state} ` , ` {Artist} ` , ` {Title} ` ,
335342 ` {Album} ` , ` {Genre} ` and optionally ` {Name} ` and ` {file} `
336343
337344** vicious.widgets.net**
@@ -360,10 +367,10 @@ Provides agenda statistics for Emacs org-mode.
360367Supported platforms: platform independent.
361368
362369- Arguments:
363- * takes a table with full paths to agenda files, that will be parsed, as an
370+ * Takes a table with full paths to agenda files, that will be parsed, as an
364371 argument
365372- Returns:
366- * returns 1st value as count of tasks you forgot to do, 2nd as count of
373+ * Returns 1st value as count of tasks you forgot to do, 2nd as count of
367374 tasks for today, 3rd as count of tasks for the next 3 days and 4th as
368375 count of tasks to do in the week
369376
@@ -375,7 +382,7 @@ Supported platforms: platform independent.
375382- Arguments:
376383 * None
377384- Returns:
378- * returns 1st value as the operating system in use, 2nd as the release
385+ * Returns 1st value as the operating system in use, 2nd as the release
379386 version, 3rd as your username, 4th the hostname, 5th as available system
380387 entropy and 6th value as available entropy in percent
381388
@@ -387,10 +394,10 @@ correct number of updates.
387394Supported platforms: platform independent.
388395
389396- Arguments:
390- * takes the Linux or BSD distribution name as an argument, i.e. ` "Arch" ` ,
397+ * Takes the Linux or BSD distribution name as an argument, i.e. ` "Arch" ` ,
391398 ` "FreeBSD" `
392399- Returns:
393- * returns 1st value as the count of available updates
400+ * Returns 1st value as the count of available updates
394401
395402** vicious.widgets.raid**
396403
@@ -668,7 +675,6 @@ second argument, and will return the text/data to be used for the
668675widget.
669676
670677** Example**
671-
672678``` Lua
673679 mpdwidget = widget ({ type = " textbox" })
674680 vicious .register (mpdwidget , vicious .widgets .mpd ,
@@ -683,7 +689,6 @@ hides the mpd widget when no song is playing, updated every 2
683689seconds (the default interval)
684690
685691** Example**
686-
687692``` Lua
688693 uptimewidget = widget ({ type = " textbox" })
689694 vicious .register (uptimewidget , vicious .widgets .uptime ,
@@ -700,7 +705,6 @@ textbox widgets by changing their .width field (by default width is
700705automatically adapted to text width).
701706
702707** Example**
703-
704708``` Lua
705709 uptimewidget = widget ({ type = " textbox" })
706710 uptimewidget .width , uptimewidget .align = 50 , " right"
@@ -715,7 +719,6 @@ color index arguments elegantly. But they are not unusable, far from
715719it.
716720
717721** Example**
718-
719722``` Lua
720723 ctext = widget ({ type = " textbox" })
721724 cgraph = awful .widget .graph ()
@@ -739,6 +742,7 @@ A lot of users are not happy with default symbols used in volume,
739742battery, cpufreq and other widget types. You can use your own symbols
740743without any need to modify modules.
741744
745+ ** Example**
742746``` Lua
743747 volumewidget = wibox .widget .textbox ()
744748 vicious .register (volumewidget , vicious .widgets .volume ,
@@ -751,6 +755,42 @@ without any need to modify modules.
751755 - uses a custom table map to modify symbols representing the mixer
752756 state; on or off/mute
753757
758+ How to get the data from a widget to use it outside from the taskbar? This
759+ could be useful for naughty notification and scripts.
760+
761+ ** Example**
762+ ``` Lua
763+ -- Battery widget
764+ mybattery = wibox .widget .textbox ()
765+ vicious .register (mybattery , vicious .widgets .bat , " $2%" , 17 , " 0" )
766+ mybattery :buttons (awful .util .table .join (
767+ awful .button ({ }, 1 , function ()
768+ naughty .notify ({ title = " Battery indicator" ,
769+ text = vicious .call (vicious .widgets .bat , " Remaining time: $3" , " 0" ) })
770+ end )
771+ ))
772+ ```
773+
774+ Format functions can be used as well:
775+
776+ ** Example**
777+ ``` Lua
778+ -- Battery widget
779+ mybattery = wibox .widget .textbox ()
780+ vicious .register (mybattery , vicious .widgets .bat , " $2%" , 17 , " 0" )
781+ mybattery :buttons (awful .util .table .join (
782+ awful .button ({ }, 1 , function ()
783+ naughty .notify ({ title = " Battery indicator" ,
784+ text = vicious .call (vicious .widgets .bat , function (widget , args )
785+ return string.format (" %s: %10sh\n %s: %14d%%\n %s: %12dW" ,
786+ " Remaining time" , args [3 ],
787+ " Wear level" , args [4 ],
788+ " Present rate" , args [5 ])
789+ end , " 0" ) })
790+ end )
791+ ))
792+ ```
793+
754794
755795Other
756796-----
0 commit comments