2009-09-29 23:08:18 +02:00
|
|
|
Vicious
|
|
|
|
-------
|
2013-06-01 00:09:51 +02:00
|
|
|
Vicious is a modular widget library for window managers, but mostly
|
|
|
|
catering to users of the "awesome" window manager. It was derived from
|
|
|
|
the old "Wicked" widget library, and has some of the old Wicked widget
|
|
|
|
types, a few of them rewritten, and a good number of new ones:
|
2009-09-20 15:30:30 +02:00
|
|
|
|
2010-03-13 00:34:26 +01:00
|
|
|
- http://git.sysphere.org/vicious/about/
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2013-06-01 00:09:51 +02:00
|
|
|
Vicious widget types are a framework for creating your own
|
2010-03-14 19:06:39 +01:00
|
|
|
widgets. Vicious contains modules that gather data about your system,
|
2013-06-01 00:09:51 +02:00
|
|
|
and a few "awesome" helper functions that make it easier to register
|
|
|
|
timers, suspend widgets and so on.
|
2009-10-10 00:24:23 +02:00
|
|
|
|
2010-03-13 00:34:26 +01:00
|
|
|
For now Vicious doesn't depend on any third party Lua libraries, to
|
|
|
|
make it easier to install and use. That means some system utilities
|
|
|
|
are used instead, where available:
|
|
|
|
|
2010-03-14 03:37:40 +01:00
|
|
|
- hddtemp for the HDD Temperature widget type
|
|
|
|
- alsa-utils for the Volume widget type
|
|
|
|
- wireless_tools for the Wireless widget type
|
|
|
|
- curl for widget types accessing network resources
|
2010-03-13 00:34:26 +01:00
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
2013-06-01 00:09:51 +02:00
|
|
|
When provided by an operating system package, or installed from source
|
|
|
|
into the Lua library path Vicious can be used as a regular Lua
|
|
|
|
library, to be used stand-alone or to feed widgets of any window
|
|
|
|
manager (ie. Ion, WMII). It is compatible with both Lua v5.1 and v5.2.
|
|
|
|
|
|
|
|
$ lua
|
|
|
|
> widgets = require("vicious.widgets")
|
|
|
|
> print(widgets.volume(nil, "Master")[1])
|
|
|
|
100
|
|
|
|
|
|
|
|
|
|
|
|
Usage within Awesome
|
|
|
|
--------------------
|
|
|
|
To use Vicious with Awesome, install the package from your operating
|
|
|
|
system provider, or download the source code and move it to your
|
|
|
|
awesome configuration directory in $XDG_CONFIG_HOME (usually ~/.config):
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-10-10 00:24:23 +02:00
|
|
|
$ mv vicious $XDG_CONFIG_HOME/awesome/
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2011-05-10 00:47:58 +02:00
|
|
|
Vicious will only load modules for widget types you intend to use in
|
|
|
|
your awesome configuration, to avoid having useless modules sitting in
|
|
|
|
your memory.
|
2009-09-14 20:55:53 +02:00
|
|
|
|
2009-10-10 00:24:23 +02:00
|
|
|
Then add the following to the top of your rc.lua:
|
|
|
|
|
2012-08-02 02:15:53 +02:00
|
|
|
vicious = require("vicious")
|
2009-09-20 15:30:30 +02:00
|
|
|
|
2009-10-10 00:24:23 +02:00
|
|
|
Once you create a widget (a textbox, graph or a progressbar) call
|
2010-11-03 03:33:49 +01:00
|
|
|
vicious.register() to register it with Vicious:
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2010-03-07 04:10:57 +01:00
|
|
|
vicious.register(widget, wtype, format, interval, warg)
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-09-20 15:30:30 +02:00
|
|
|
widget
|
|
|
|
- widget created with widget() or awful.widget() (in case of a
|
|
|
|
graph or a progressbar)
|
2009-09-19 21:41:53 +02:00
|
|
|
|
2010-03-07 04:10:57 +01:00
|
|
|
wtype
|
2011-12-10 17:34:38 +01:00
|
|
|
- widget type or a function
|
|
|
|
- any of the available (default, or custom) widget types can
|
|
|
|
be used here, see below for a list of those provided by
|
|
|
|
Vicious
|
|
|
|
- function
|
|
|
|
- custom functions from your own "awesome" configuration can
|
|
|
|
be registered as widget types, see the "Custom widget types"
|
|
|
|
section
|
2009-09-19 21:41:53 +02:00
|
|
|
|
2009-09-20 15:30:30 +02:00
|
|
|
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
|
2009-12-15 00:25:58 +01:00
|
|
|
with string keys, in that case use: ${key}
|
2009-09-20 15:30:30 +02:00
|
|
|
- function
|
|
|
|
- function(widget, args) can be used to manipulate data
|
|
|
|
returned by the widget type, more about this below
|
2009-09-19 21:41:53 +02:00
|
|
|
|
2009-09-20 15:30:30 +02:00
|
|
|
interval
|
|
|
|
- number of seconds between updates of the widget, 2s by
|
|
|
|
default, also read the "Power" section below
|
2009-09-19 21:41:53 +02:00
|
|
|
|
2009-09-20 15:30:30 +02:00
|
|
|
warg
|
|
|
|
- some widget types require an argument to be passed, for example
|
|
|
|
the battery ID
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
|
2009-10-02 22:46:12 +02:00
|
|
|
Other functions
|
2009-07-30 04:44:22 +02:00
|
|
|
---------------
|
2009-09-20 15:30:30 +02:00
|
|
|
Unregister a widget:
|
2009-07-30 04:44:22 +02:00
|
|
|
vicious.unregister(widget, keep)
|
|
|
|
|
2009-10-10 00:24:23 +02:00
|
|
|
- if keep is true widget will be suspended, waiting to be
|
|
|
|
activated
|
2009-09-20 15:30:30 +02:00
|
|
|
|
|
|
|
Suspend all widgets:
|
2009-07-30 04:44:22 +02:00
|
|
|
vicious.suspend()
|
|
|
|
|
2009-09-20 15:30:30 +02:00
|
|
|
- example automation script for the "laptop-mode-tools" start-stop
|
|
|
|
module: http://sysphere.org/~anrxc/local/sources/lmt-vicious.sh
|
2009-09-07 23:02:56 +02:00
|
|
|
|
2009-09-20 15:30:30 +02:00
|
|
|
Restart suspended widgets:
|
2009-07-30 04:44:22 +02:00
|
|
|
vicious.activate(widget)
|
|
|
|
|
2009-10-10 00:24:23 +02:00
|
|
|
- if widget is provided only that widget will be activated
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2010-03-07 02:39:26 +01:00
|
|
|
Enable caching of a widget type:
|
2010-03-07 04:10:57 +01:00
|
|
|
vicious.cache(wtype)
|
2009-09-25 21:31:20 +02:00
|
|
|
|
|
|
|
- enable caching of values returned by a widget type
|
|
|
|
|
2010-03-07 03:09:44 +01:00
|
|
|
Force update of widgets:
|
|
|
|
vicious.force({ widget, })
|
|
|
|
|
|
|
|
- widget argument is a table with one or more widgets that will be
|
|
|
|
updated
|
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
Widget types
|
|
|
|
------------
|
|
|
|
Widget types consist of worker functions that take the "format"
|
2009-08-05 21:50:41 +02:00
|
|
|
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.
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
vicious.widgets.cpu
|
|
|
|
- provides CPU usage for all available CPUs/cores
|
2009-10-10 00:24:23 +02:00
|
|
|
- returns 1st value as usage of all CPUs/cores, 2nd as usage of
|
|
|
|
first CPU/core, 3rd as usage of second CPU/core etc.
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-08-06 18:21:13 +02:00
|
|
|
vicious.widgets.cpuinf
|
|
|
|
- provides speed and cache information for all available CPUs/cores
|
2009-12-15 00:25:58 +01:00
|
|
|
- returns a table with string keys, using CPU ID as a base:
|
2009-10-10 00:24:23 +02:00
|
|
|
{cpu0 mhz}, {cpu0 ghz}, {cpu0 kb}, {cpu0 mb}, {cpu1 mhz} etc.
|
2009-08-06 18:21:13 +02:00
|
|
|
|
2009-08-03 04:40:55 +02:00
|
|
|
vicious.widgets.cpufreq
|
|
|
|
- provides freq, voltage and governor info for a requested CPU
|
|
|
|
- takes the CPU ID as an argument, i.e. "cpu0"
|
2009-10-10 00:24:23 +02:00
|
|
|
- returns 1st value as frequency of requested CPU in MHz, 2nd in
|
|
|
|
GHz, 3rd as voltage in mV, 4th as voltage in V and 5th as the
|
|
|
|
governor state
|
2009-08-03 04:40:55 +02:00
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
vicious.widgets.thermal
|
2010-02-10 02:49:26 +01:00
|
|
|
- provides temperature levels of ACPI and coretemp thermal zones
|
|
|
|
- takes the thermal zone as an argument, i.e. "thermal_zone0", or a
|
2012-03-31 20:58:10 +02:00
|
|
|
table with 1st field as thermal zone, 2nd as data source -
|
|
|
|
available data sources are "proc", "core" and "sys" (which is the
|
|
|
|
default when only the zone is provided) and 3rd optional argument
|
|
|
|
as a temperature input file to read
|
2009-10-10 00:24:23 +02:00
|
|
|
- returns 1st value as temperature of requested thermal zone
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
vicious.widgets.uptime
|
2009-11-11 03:55:03 +01:00
|
|
|
- provides system uptime and load information
|
|
|
|
- returns 1st value as uptime in days, 2nd as uptime in hours, 3rd
|
|
|
|
as uptime in minutes, 4th as load average for past 1 minute, 5th
|
|
|
|
for 5 minutes and 6th for 15 minutes
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
vicious.widgets.bat
|
|
|
|
- provides state, charge, and remaining time for a requested battery
|
2009-11-10 15:46:54 +01:00
|
|
|
- takes battery ID as an argument, i.e. "BAT0"
|
|
|
|
- returns 1st value as state of requested battery, 2nd as charge
|
|
|
|
level in percent and 3rd as remaining (charging or discharging)
|
|
|
|
time
|
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
vicious.widgets.mem
|
|
|
|
- provides RAM and Swap usage statistics
|
2009-10-10 00:24:23 +02:00
|
|
|
- returns 1st value as memory usage in percent, 2nd as memory usage,
|
|
|
|
3rd as total system memory, 4th as free memory, 5th as swap usage
|
2011-06-30 01:06:43 +02:00
|
|
|
in percent, 6th as swap usage, 7th as total system swap, 8th as
|
|
|
|
free swap and 9th as memory usage with buffers and cache
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2010-03-12 03:37:39 +01:00
|
|
|
vicious.widgets.os
|
|
|
|
- provides operating system information
|
|
|
|
- returns 1st value as the operating system in use, 2nd as the
|
2010-03-15 17:52:02 +01:00
|
|
|
release version, 3rd as your username, 4th the hostname, 5th as
|
|
|
|
available system entropy and 6th value as available entropy in
|
|
|
|
percent
|
2010-03-12 03:37:39 +01:00
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
vicious.widgets.fs
|
2009-08-06 21:59:12 +02:00
|
|
|
- provides file system disk space usage
|
2009-09-14 20:55:53 +02:00
|
|
|
- takes an (optional) argument which, if true, includes remote file
|
|
|
|
systems, only local file systems are included by default
|
2009-12-15 00:25:58 +01:00
|
|
|
- returns a table with string keys, using mount points as a base:
|
2009-11-18 00:52:55 +01:00
|
|
|
{/ size_mb}, {/ size_gb}, {/ used_mb}, {/ used_gb}, {/ used_p},
|
2010-03-10 01:57:25 +01:00
|
|
|
{/ avail_mb}, {/ avail_gb}, {/ avail_p}, {/home size_mb} etc.
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
vicious.widgets.dio
|
2011-03-29 02:21:53 +02:00
|
|
|
- provides I/O statistics for all available storage devices
|
|
|
|
- returns a table with string keys: {sda total_s}, {sda total_kb},
|
|
|
|
{sda total_mb}, {sda read_s}, {sda read_kb}, {sda read_mb},
|
|
|
|
{sda write_s}, {sda write_kb}, {sda write_mb}, {sdb1 total_s} etc.
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2010-03-26 00:59:01 +01:00
|
|
|
vicious.widgets.raid
|
|
|
|
- provides state information for a requested RAID array
|
|
|
|
- takes the RAID array ID as an argument
|
|
|
|
- returns 1st value as the number of assigned, and 2nd as active,
|
|
|
|
devices in the array
|
|
|
|
|
2009-08-06 02:41:46 +02:00
|
|
|
vicious.widgets.hddtemp
|
|
|
|
- provides hard drive temperatures using the hddtemp daemon
|
2009-09-19 21:41:53 +02:00
|
|
|
- takes the hddtemp listening port as an argument, or defaults to
|
|
|
|
port 7634
|
2009-12-15 00:25:58 +01:00
|
|
|
- returns a table with string keys, using hard drives as a base:
|
|
|
|
{/dev/sda} and {/dev/sdc} for example
|
2009-08-06 02:41:46 +02:00
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
vicious.widgets.net
|
2010-07-19 02:12:00 +02:00
|
|
|
- provides state and usage statistics of all network interfaces
|
2009-12-15 00:25:58 +01:00
|
|
|
- returns a table with string keys, using net interfaces as a base:
|
2010-07-19 02:12:00 +02:00
|
|
|
{eth0 carrier}, {eth0 rx_b}, {eth0 tx_b}, {eth0 rx_kb}, {eth0 tx_kb},
|
|
|
|
{eth0 rx_mb}, {eth0 tx_mb}, {eth0 rx_gb}, {eth0 tx_gb}, {eth0 down_b},
|
|
|
|
{eth0 up_b}, {eth0 down_kb}, {eth0 up_kb}, {eth0 down_mb},
|
|
|
|
{eth0 up_mb}, {eth0 down_gb}, {eth0 up_gb}, {eth1 rx_b} etc.
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
vicious.widgets.wifi
|
|
|
|
- provides wireless information for a requested interface
|
|
|
|
- takes the network interface as an argument, i.e. "wlan0"
|
2009-12-15 00:25:58 +01:00
|
|
|
- returns a table with string keys: {ssid}, {mode}, {chan}, {rate},
|
2013-12-02 19:06:41 +01:00
|
|
|
{link}, {linp} (link quality in percent) and {sign} (signal level)
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
vicious.widgets.mbox
|
|
|
|
- provides the subject of last e-mail in a mbox file
|
2009-11-11 04:36:30 +01:00
|
|
|
- takes the full path to the mbox as an argument, or a table with
|
|
|
|
1st field as path, 2nd as maximum lenght and 3rd (optional) as
|
|
|
|
widget name - if 3rd field is present scrolling will be used
|
2009-10-10 00:24:23 +02:00
|
|
|
- returns 1st value as the subject of the last e-mail
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-07-31 07:49:28 +02:00
|
|
|
vicious.widgets.mboxc
|
2009-10-01 11:46:28 +02:00
|
|
|
- provides the count of total, old and new messages in mbox files
|
|
|
|
- takes a table with full paths to mbox files as an argument
|
2009-10-10 00:24:23 +02:00
|
|
|
- returns 1st value as the total count of messages, 2nd as the count
|
|
|
|
of old messages and 3rd as the count of new messages
|
2009-07-31 07:49:28 +02:00
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
vicious.widgets.mdir
|
2010-03-02 23:19:44 +01:00
|
|
|
- provides the number of new and unread messages in Maildir
|
2009-11-11 22:06:27 +01:00
|
|
|
structures/directories
|
|
|
|
- takes a table with full paths to Maildir structures as an argument
|
2009-10-10 00:24:23 +02:00
|
|
|
- returns 1st value as the count of new messages and 2nd as the
|
|
|
|
count of "old" messages lacking the Seen flag
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-09-08 22:46:59 +02:00
|
|
|
vicious.widgets.gmail
|
2009-10-01 12:11:21 +02:00
|
|
|
- provides count of new and subject of last e-mail on Gmail
|
2009-11-11 04:36:30 +01:00
|
|
|
- takes an (optional) argument, if it's a number subject will be
|
|
|
|
truncated, if a table, with 1st field as maximum lenght and 2nd
|
|
|
|
the widget name (i.e. "gmailwidget"), scrolling will be used
|
2010-03-10 21:59:15 +01:00
|
|
|
- keeps login information in the ~/.netrc file, example:
|
|
|
|
machine mail.google.com login user password pass
|
2009-12-15 00:25:58 +01:00
|
|
|
- returns a table with string keys: {count} and {subject}
|
2009-09-08 22:46:59 +02:00
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
vicious.widgets.org
|
|
|
|
- provides agenda statistics for Emacs org-mode
|
|
|
|
- takes a table with full paths to agenda files, that will be
|
2009-09-08 22:46:59 +02:00
|
|
|
parsed, as an argument
|
2009-10-10 00:24:23 +02:00
|
|
|
- returns 1st value as count of tasks you forgot to do, 2nd as count
|
|
|
|
of tasks for today, 3rd as count of tasks for the next 3 days and
|
|
|
|
4th as count of tasks to do in the week
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2010-02-04 20:45:11 +01:00
|
|
|
vicious.widgets.pkg
|
2010-08-29 13:53:26 +02:00
|
|
|
- provides number of pending updates on UNIX systems
|
2010-02-04 20:45:11 +01:00
|
|
|
- takes the distribution name as an argument, i.e. "Arch"
|
2009-10-10 00:24:23 +02:00
|
|
|
- returns 1st value as the count of available updates
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
vicious.widgets.mpd
|
2010-03-12 21:56:17 +01:00
|
|
|
- provides Music Player Daemon information
|
|
|
|
- takes a table as an argument, 1st field should be the password (or
|
|
|
|
nil), 2nd the hostname (or nil) and 3rd port (or nil) - if no
|
|
|
|
argument is provided connection attempt will be made to localhost
|
|
|
|
port 6600 with no password
|
|
|
|
- returns a table with string keys: {volume}, {state}, {Artist},
|
2010-08-22 14:59:05 +02:00
|
|
|
{Title}, {Album}, {Genre} and optionally {Name} and {file}
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
vicious.widgets.volume
|
2010-03-06 22:12:47 +01:00
|
|
|
- provides volume levels and state of requested ALSA mixers
|
2010-02-18 21:42:09 +01:00
|
|
|
- takes the ALSA mixer control as an argument, i.e. "Master",
|
|
|
|
optionally append the card ID or other options, i.e. "PCM -c 0"
|
2010-03-06 22:12:47 +01:00
|
|
|
- returns 1st value as the volume level and 2nd as the mute state of
|
|
|
|
the requested channel
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
vicious.widgets.weather
|
|
|
|
- provides weather information for a requested station
|
2009-09-20 15:30:30 +02:00
|
|
|
- takes the ICAO station code as an argument, i.e. "LDRI"
|
2009-12-15 00:25:58 +01:00
|
|
|
- returns a table with string keys: {city}, {wind}, {windmph},
|
2013-12-15 02:48:00 +01:00
|
|
|
{windkmh}, {sky}, {weather}, {tempf}, {tempc}, {humid}, {dewf},
|
|
|
|
{dewc}, {press}
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
vicious.widgets.date
|
2010-10-03 18:48:02 +02:00
|
|
|
- provides access to os.date, with optional time formatting provided
|
2010-10-04 22:42:31 +02:00
|
|
|
as the format string - using regular date sequences
|
|
|
|
- takes optional time offset, in seconds, as an argument for example
|
|
|
|
to calculate time zone differences, otherwise current time is
|
|
|
|
formatted
|
2010-11-03 03:33:49 +01:00
|
|
|
- returns the output of os.date, formatted by provided sequences
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
Custom widget types
|
|
|
|
-------------------
|
2009-10-10 00:24:23 +02:00
|
|
|
Use any of the existing widget types as a starting point for your
|
2009-09-14 20:55:53 +02:00
|
|
|
own. Write a quick worker function that does the work and plug it
|
2009-09-07 23:02:56 +02:00
|
|
|
in. How data will be formatted, will it be red or blue, should be
|
2009-10-10 00:24:23 +02:00
|
|
|
defined in rc.lua (or somewhere else, outside the actual module).
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2010-03-12 22:30:58 +01:00
|
|
|
Before writing a widget type you should check if there is already one
|
2010-09-13 23:01:13 +02:00
|
|
|
in the contrib directory of Vicious. The contrib directory contains
|
2010-03-12 22:30:58 +01:00
|
|
|
extra widgets you can use. Some are for less common hardware, and
|
2010-09-13 23:01:13 +02:00
|
|
|
other were contributed by Vicious users. The contrib directory also
|
|
|
|
holds widget types that were obsoleted or rewritten. Contrib widgets
|
2012-06-25 01:22:53 +02:00
|
|
|
will not be imported by init unless you explicitly enable it, or load
|
|
|
|
them in your rc.lua.
|
2010-03-12 22:30:58 +01:00
|
|
|
|
|
|
|
Richard Kolkovich, a FreeBSD user, published his vicious-fbsd
|
|
|
|
branch. If you are also a BSD user you can find his work here:
|
|
|
|
|
2010-03-13 00:34:26 +01:00
|
|
|
- http://git.sigil.org/vicious-fbsd/
|
2010-03-12 22:30:58 +01:00
|
|
|
|
2010-11-03 03:33:49 +01:00
|
|
|
Some users would like to avoid writing new modules. For them Vicious
|
|
|
|
kept the old Wicked functionality, possibility to register their own
|
|
|
|
functions as widget types. By providing them as the second argument to
|
|
|
|
vicious.register. Your function can accept "format" and "warg"
|
|
|
|
arguments, just like workers.
|
|
|
|
|
2010-03-12 22:30:58 +01:00
|
|
|
|
|
|
|
Power and Caching
|
|
|
|
-----------------
|
|
|
|
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. It was a big
|
|
|
|
problem with awesome v2 and widgets that used shell scripts to gather
|
|
|
|
data, and with widget libraries written in languages like Ruby.
|
|
|
|
|
|
|
|
Lua is an extremely fast and efficient programming language, and
|
|
|
|
Vicious takes advantage of that. But suspending Vicious widgets is one
|
|
|
|
way to prevent them from draining your battery, despite that.
|
|
|
|
|
|
|
|
Update intervals also play a big role, and you can save a lot of power
|
|
|
|
with a smart approach. Don't use 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 widget types read
|
|
|
|
files that reside in memory, others call external utilities and some,
|
|
|
|
like the mbox widget, read big files.
|
|
|
|
|
|
|
|
Vicious can also cache values returned by widget types. Caching
|
|
|
|
enables you to have multiple widgets using the same widget type. With
|
|
|
|
caching its worker function gets executed only once - which is also
|
|
|
|
great for saving power.
|
|
|
|
|
|
|
|
- Some widget types keep internal data and if you call one multiple
|
|
|
|
times without caching, the widget that executes it first would
|
|
|
|
modify stored values. This can lead to problems and give you
|
|
|
|
inconsistent data. Remember it for widget types like CPU and
|
|
|
|
Network usage, which compare the old set of data with the new one
|
|
|
|
to calculate current usage.
|
|
|
|
|
|
|
|
- Widget types that require a widget argument to be passed should be
|
|
|
|
handled carefully. If you are requesting information for different
|
|
|
|
devices then caching should not be used, because you could get
|
|
|
|
inconsistent data.
|
|
|
|
|
|
|
|
|
|
|
|
Security
|
|
|
|
--------
|
|
|
|
At the moment only one widget type (Gmail) requires auth. information
|
|
|
|
in order to get to the data. In the future there could be more, and
|
|
|
|
you should give some thought to the issue of protecting your data. The
|
|
|
|
Gmail widget type by default stores login information in the ~/.netrc
|
|
|
|
file, and you are advised to make sure that file is only readable by
|
|
|
|
the owner. Other than that we can not force all users to conform to
|
|
|
|
one standard, one way of keeping it secure, like in some keyring.
|
|
|
|
|
|
|
|
First let's clear why we simply don't encrypt the login information
|
2010-05-17 21:41:36 +02:00
|
|
|
and store it in ciphertext. By exposing the algorithm anyone can
|
|
|
|
reverse the encryption steps. Some claim even that's better than
|
2010-03-12 22:30:58 +01:00
|
|
|
plaintext but it's just security trough obscurity.
|
|
|
|
|
|
|
|
Here are some ideas actually worth your time. Users that have KDE (or
|
|
|
|
parts of it) installed could store their login information into the
|
|
|
|
Kwallet service and request it via DBus from the widget type. It can
|
|
|
|
be done with tools like "dbus-send" and "qdbus". The Gnome keyring
|
|
|
|
should support the same, so those with parts of Gnome installed could
|
|
|
|
use that keyring.
|
|
|
|
|
|
|
|
Users of GnuPG (and its agent) could consider encrypting the netrc
|
|
|
|
file with their GPG key. Trough the GPG Passphrase Agent they could
|
|
|
|
then decrypt the file transparently while their session is active.
|
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2013-11-02 18:34:55 +01:00
|
|
|
Usage examples
|
2013-01-22 23:55:45 +01:00
|
|
|
---------------------------------
|
2009-10-10 00:24:23 +02:00
|
|
|
Start with a simple widget, like date. Then build your setup from
|
|
|
|
there, one widget at a time. Also remember that besides creating and
|
|
|
|
registering widgets you have to add them to a wibox (statusbar) in
|
|
|
|
order to actually display them.
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-10-10 00:24:23 +02:00
|
|
|
Date widget
|
2013-11-02 18:34:55 +01:00
|
|
|
datewidget = wibox.widget.textbox()
|
2010-03-12 22:06:31 +01:00
|
|
|
vicious.register(datewidget, vicious.widgets.date, "%b %d, %R")
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-10-12 18:15:12 +02:00
|
|
|
- updated every 2 seconds (the default interval), uses standard
|
2009-10-10 00:24:23 +02:00
|
|
|
date sequences as the format string
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
Memory widget
|
2013-11-02 18:34:55 +01:00
|
|
|
memwidget = wibox.widget.textbox()
|
2010-03-07 00:56:42 +01:00
|
|
|
vicious.cache(vicious.widgets.mem)
|
2010-03-12 22:06:31 +01:00
|
|
|
vicious.register(memwidget, vicious.widgets.mem, "$1 ($2MB/$3MB)", 13)
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-10-12 18:15:12 +02:00
|
|
|
- updated every 13 seconds, appends "MB" to 2nd and 3rd returned
|
2009-09-25 21:31:20 +02:00
|
|
|
values and enables caching of this widget type
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-08-06 02:41:46 +02:00
|
|
|
HDD temperature widget
|
2013-11-02 18:34:55 +01:00
|
|
|
hddtempwidget = wibox.widget.textbox()
|
2010-03-12 22:06:31 +01:00
|
|
|
vicious.register(hddtempwidget, vicious.widgets.hddtemp, "${/dev/sda} °C", 19)
|
2009-08-06 02:41:46 +02:00
|
|
|
|
2009-10-12 18:15:12 +02:00
|
|
|
- updated every 19 seconds, requests the temperature level of the
|
2009-10-10 00:24:23 +02:00
|
|
|
{/dev/sda} key/disk and appends "°C" to the returned value, does
|
2009-09-19 21:41:53 +02:00
|
|
|
not provide the port argument so default port is used
|
2009-08-06 02:41:46 +02:00
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
Mbox widget
|
2013-11-02 18:34:55 +01:00
|
|
|
mboxwidget = wibox.widget.textbox()
|
2010-03-12 22:06:31 +01:00
|
|
|
vicious.register(mboxwidget, vicious.widgets.mbox, "$1", 5, "/home/user/mail/Inbox")
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-10-12 18:15:12 +02:00
|
|
|
- updated every 5 seconds, provides full path to the mbox as an
|
2009-07-30 04:44:22 +02:00
|
|
|
argument
|
|
|
|
|
2009-09-21 02:01:12 +02:00
|
|
|
Battery widget
|
2009-10-12 18:15:12 +02:00
|
|
|
batwidget = awful.widget.progressbar()
|
2009-09-21 02:01:12 +02:00
|
|
|
batwidget:set_width(8)
|
|
|
|
batwidget:set_height(10)
|
|
|
|
batwidget:set_vertical(true)
|
2010-03-12 22:06:31 +01:00
|
|
|
batwidget:set_background_color("#494B4F")
|
2009-09-21 02:01:12 +02:00
|
|
|
batwidget:set_border_color(nil)
|
2013-11-02 18:34:55 +01:00
|
|
|
batwidget:set_color({ type = "linear", from = { 0, 0 }, to = { 0, 10 },
|
|
|
|
stops = { { 0, "#AECF96" }, { 0.5, "#88A175" }, { 1, "#FF5656" }})
|
2010-03-12 22:06:31 +01:00
|
|
|
vicious.register(batwidget, vicious.widgets.bat, "$2", 61, "BAT0")
|
2009-09-21 02:01:12 +02:00
|
|
|
|
2009-10-12 18:15:12 +02:00
|
|
|
- updated every 61 seconds, requests the current battery charge
|
2009-10-02 20:20:37 +02:00
|
|
|
level and displays a progressbar, provides "BAT0" battery ID as an
|
2009-09-21 02:01:12 +02:00
|
|
|
argument
|
|
|
|
|
|
|
|
CPU usage widget
|
2009-10-12 18:15:12 +02:00
|
|
|
cpuwidget = awful.widget.graph()
|
2009-09-21 02:01:12 +02:00
|
|
|
cpuwidget:set_width(50)
|
2010-03-12 22:06:31 +01:00
|
|
|
cpuwidget:set_background_color("#494B4F")
|
2013-11-02 18:34:55 +01:00
|
|
|
cpuwidget:set_color({ type = "linear", from = { 0, 0 }, to = { 50, 0 },
|
|
|
|
stops = { { 0, "#FF5656" }, { 0.5, "#88A175" }, { 1, "#AECF96" }})
|
2013-11-26 18:10:41 +01:00
|
|
|
vicious.cache(vicious.widgets.cpu)
|
2010-03-12 22:06:31 +01:00
|
|
|
vicious.register(cpuwidget, vicious.widgets.cpu, "$1", 3)
|
2009-09-21 02:01:12 +02:00
|
|
|
|
2009-10-12 18:15:12 +02:00
|
|
|
- updated every 3 seconds, feeds the graph with total usage
|
2013-11-26 18:10:41 +01:00
|
|
|
percentage of all CPUs/cores and enable caching of this widget
|
|
|
|
type
|
2009-09-21 02:01:12 +02:00
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-10-10 00:24:23 +02:00
|
|
|
Format functions
|
|
|
|
----------------
|
|
|
|
You can use a function instead of a string as the format parameter.
|
|
|
|
Then you are able to check the value returned by the widget type and
|
|
|
|
change it or perform some action. You can change the color of the
|
2009-10-12 18:15:12 +02:00
|
|
|
battery widget when it goes below a certain point, hide widgets when
|
|
|
|
they return a certain value or maybe use string.format for padding.
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-10-10 00:24:23 +02:00
|
|
|
- Do not confuse this with just coloring the widget, in those cases
|
2010-02-04 21:01:15 +01:00
|
|
|
standard pango markup can be inserted into the format string.
|
2009-10-10 00:24:23 +02:00
|
|
|
|
2009-12-07 02:06:01 +01:00
|
|
|
The format function will get the widget as its first argument, table
|
|
|
|
with the values otherwise inserted into the format string as its
|
|
|
|
second argument, and will return the text/data to be used for the
|
|
|
|
widget.
|
2009-10-10 00:24:23 +02:00
|
|
|
|
2009-10-12 18:15:12 +02:00
|
|
|
Example
|
2013-11-02 18:34:55 +01:00
|
|
|
mpdwidget = wibox.widget.textbox()
|
2010-03-12 21:56:17 +01:00
|
|
|
vicious.register(mpdwidget, vicious.widgets.mpd,
|
2009-10-10 00:24:23 +02:00
|
|
|
function (widget, args)
|
2010-03-12 21:56:17 +01:00
|
|
|
if args["{state}"] == "Stop" then return ""
|
|
|
|
else return '<span color="white">MPD:</span> '..
|
|
|
|
args["{Artist}"]..' - '.. args["{Title}"]
|
2009-10-10 00:24:23 +02:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2009-12-07 02:06:01 +01:00
|
|
|
- hides the mpd widget when no song is playing, updated every 2
|
|
|
|
seconds (the default interval)
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2009-10-12 18:15:12 +02:00
|
|
|
Example
|
2013-11-02 18:34:55 +01:00
|
|
|
uptimewidget = wibox.widget.textbox()
|
2009-10-12 18:15:12 +02:00
|
|
|
vicious.register(uptimewidget, vicious.widgets.uptime,
|
|
|
|
function (widget, args)
|
2010-03-12 22:06:31 +01:00
|
|
|
return string.format("Uptime: %2dd %02d:%02d ", args[1], args[2], args[3])
|
2009-10-12 18:15:12 +02:00
|
|
|
end, 61)
|
|
|
|
|
|
|
|
- uses string.format for padding uptime values to a minimum amount
|
|
|
|
of digits, updated every 61 seconds
|
|
|
|
|
2010-02-04 21:01:15 +01:00
|
|
|
When it comes to padding it is also useful to mention how a widget can
|
|
|
|
be configured to have a fixed width. You can set a fixed width on your
|
|
|
|
textbox widgets by changing their .width field (by default width is
|
|
|
|
automatically adapted to text width).
|
|
|
|
|
|
|
|
Example
|
2013-11-02 18:34:55 +01:00
|
|
|
uptimewidget = wibox.widget.textbox()
|
|
|
|
uptimewidget:set_align("right")
|
2010-03-12 22:06:31 +01:00
|
|
|
vicious.register(uptimewidget, vicious.widgets.uptime, "$1 $2:$3", 61)
|
2013-11-02 18:34:55 +01:00
|
|
|
uptimewidget = wibox.layout.constraint(uptimewidget, "exact", 50, nil)
|
2010-02-04 21:01:15 +01:00
|
|
|
|
2010-03-14 19:06:39 +01:00
|
|
|
- forces a fixed width of 50px to the uptime widget, and aligns its
|
2010-02-04 21:01:15 +01:00
|
|
|
text to the right
|
|
|
|
|
2011-08-07 22:17:26 +02:00
|
|
|
Another use case are stacked graphs (aka multigraphs) which Vicious
|
|
|
|
does not handle on its own at the moment, as it's hard to pass on
|
|
|
|
color index arguments elegantly. But they are not unusable, far from
|
|
|
|
it.
|
|
|
|
|
|
|
|
Example
|
2013-11-02 18:34:55 +01:00
|
|
|
ctext = wibox.widget.textbox()
|
2011-08-07 22:17:26 +02:00
|
|
|
cgraph = awful.widget.graph()
|
|
|
|
cgraph:set_width(100):set_height(20)
|
|
|
|
cgraph:set_stack(true):set_max_value(100)
|
|
|
|
cgraph:set_background_color("#494B4F")
|
|
|
|
cgraph:set_stack_colors({ "#FF5656", "#88A175", "#AECF96" })
|
|
|
|
vicious.register(ctext, vicious.widgets.cpu,
|
|
|
|
function (widget, args)
|
|
|
|
cgraph:add_value(args[2], 1) -- Core 1, color 1
|
|
|
|
cgraph:add_value(args[3], 2) -- Core 2, color 2
|
|
|
|
cgraph:add_value(args[4], 3) -- Core 3, color 3
|
|
|
|
end, 3)
|
|
|
|
|
|
|
|
- enables graph stacking/multigraph and plots usage of all three CPU
|
|
|
|
cores on a single graph, the textbox "ctext" is just an empty
|
|
|
|
placeholder, graph is updated every 3 seconds
|
|
|
|
|
2012-01-20 14:35:07 +01:00
|
|
|
A lot of users are not happy with default symbols used in volume,
|
|
|
|
battery, cpufreq and other widget types. You can use your own symbols
|
|
|
|
without any need to modify modules.
|
|
|
|
|
2013-11-02 18:34:55 +01:00
|
|
|
volumewidget = wibox.widget.textbox()
|
2012-01-20 14:35:07 +01:00
|
|
|
vicious.register(volumewidget, vicious.widgets.volume,
|
|
|
|
function(widget, args)
|
|
|
|
local label = { ["♫"] = "O", ["♩"] = "M" }
|
|
|
|
return "Volume: " .. args[1] .. "% State: " .. label[args[2]]
|
|
|
|
end, 2, "PCM")
|
|
|
|
|
|
|
|
- uses a custom table map to modify symbols representing the mixer
|
|
|
|
state; on or off/mute
|
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
Other
|
|
|
|
-----
|
2009-10-10 00:24:23 +02:00
|
|
|
Read "awesome" manual pages:
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2010-03-13 21:51:40 +01:00
|
|
|
- awesome(1) awesomerc(5)
|
2009-07-30 04:44:22 +02:00
|
|
|
|
2010-03-07 01:01:37 +01:00
|
|
|
Awesome widgets explained:
|
|
|
|
|
2010-03-13 00:34:26 +01:00
|
|
|
- http://awesome.naquadah.org/wiki/Widgets_in_awesome
|
2010-03-07 01:01:37 +01:00
|
|
|
|
2009-12-07 02:06:01 +01:00
|
|
|
Example "awesome" configuration:
|
2009-10-10 00:24:23 +02:00
|
|
|
|
2010-03-13 00:34:26 +01:00
|
|
|
- http://git.sysphere.org/awesome-configs/
|
2009-10-10 00:24:23 +02:00
|
|
|
|
2009-07-30 04:44:22 +02:00
|
|
|
|
|
|
|
Authors
|
|
|
|
-------
|
2010-03-12 23:10:42 +01:00
|
|
|
Wicked written by:
|
2010-03-13 00:34:26 +01:00
|
|
|
- Lucas de Vries <lucas glacicle.com>
|
2010-03-12 23:10:42 +01:00
|
|
|
|
|
|
|
Vicious written by:
|
2010-03-13 00:34:26 +01:00
|
|
|
- Adrian C. (anrxc) <anrxc sysphere.org>
|
2010-03-12 23:10:42 +01:00
|
|
|
|
|
|
|
Vicious contributors:
|
2010-03-13 00:34:26 +01:00
|
|
|
- Michael Unterkalmsteiner <miciu gmx.de>
|
|
|
|
- Martin Striz <striz raynet.cz>
|
|
|
|
- Benedikt Sauer <filmor gmail.com>
|
|
|
|
- Greg D. <jabbas jabbas.pl>
|
|
|
|
- Henning Glawe <glaweh debian.org>
|
|
|
|
- Rémy C. <shikamaru mandriva.org>
|
|
|
|
- Hiltjo Posthuma <hiltjo codemadness.org>
|
2010-03-26 00:59:01 +01:00
|
|
|
- Hagen Schink <troja84 googlemail.com>
|
2011-03-15 05:02:55 +01:00
|
|
|
- Jörg Thalheim <jthalheim gmail.com>
|
2012-06-18 02:09:36 +02:00
|
|
|
- Arvydas Sidorenko <asido4 gmail.com>
|