commit
66ce201557
651
README.md
651
README.md
|
@ -5,21 +5,14 @@ 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
|
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:
|
types, a few of them rewritten, and a good number of new ones:
|
||||||
|
|
||||||
- http://git.sysphere.org/vicious/about/
|
- http://git.sysphere.org/vicious/about/
|
||||||
|
|
||||||
Vicious widget types are a framework for creating your own
|
Vicious widget types are a framework for creating your own
|
||||||
widgets. Vicious contains modules that gather data about your system,
|
widgets. Vicious contains modules that gather data about your system,
|
||||||
and a few "awesome" helper functions that make it easier to register
|
and a few "awesome" helper functions that make it easier to register
|
||||||
timers, suspend widgets and so on.
|
timers, suspend widgets and so on. Vicious doesn't depend on any third party
|
||||||
|
Lua libraries, but may depend on additional system utilities (see widget
|
||||||
For now Vicious doesn't depend on any third party Lua libraries, to
|
description).
|
||||||
make it easier to install and use. That means some system utilities
|
|
||||||
are used instead, where available:
|
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
|
@ -36,6 +29,7 @@ manager (ie. Ion, WMII). It is compatible with both Lua v5.1 and v5.2.
|
||||||
100
|
100
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Usage within Awesome
|
Usage within Awesome
|
||||||
--------------------
|
--------------------
|
||||||
To use Vicious with Awesome, install the package from your operating
|
To use Vicious with Awesome, install the package from your operating
|
||||||
|
@ -63,39 +57,37 @@ vicious.register(widget, wtype, format, interval, warg)
|
||||||
|
|
||||||
**widget**
|
**widget**
|
||||||
|
|
||||||
- widget created with widget() or awful.widget() (in case of a
|
- widget created with widget() or awful.widget() (in case of a
|
||||||
graph or a progressbar)
|
graph or a progressbar)
|
||||||
|
|
||||||
**wtype**
|
**wtype**
|
||||||
|
|
||||||
- widget type or a function
|
- widget type or a function
|
||||||
* any of the available (default, or custom) widget types can
|
* any of the available (default, or custom) widget types can be used here,
|
||||||
be used here, see below for a list of those provided by
|
see below for a list of those provided by Vicious
|
||||||
Vicious
|
- function
|
||||||
- function
|
* custom functions from your own "awesome" configuration can be registered
|
||||||
* custom functions from your own "awesome" configuration can
|
as widget types, see the "Custom widget types" section
|
||||||
be registered as widget types, see the "Custom widget types"
|
|
||||||
section
|
|
||||||
|
|
||||||
**format**
|
**format**
|
||||||
|
|
||||||
- string argument or a function
|
- string argument or a function
|
||||||
* $1, $2, $3... will be replaced by their respective value
|
* $1, $2, $3... will be replaced by their respective value returned by the
|
||||||
returned by the widget type, some widget types return tables
|
widget type, some widget types return tables with string keys, in that
|
||||||
with string keys, in that case use: ${key}
|
case use: ${key}
|
||||||
- function
|
- function
|
||||||
* function(widget, args) can be used to manipulate data
|
* function(widget, args) can be used to manipulate data returned by the
|
||||||
returned by the widget type, more about this below
|
widget type, more about this below
|
||||||
|
|
||||||
**interval**
|
**interval**
|
||||||
|
|
||||||
- number of seconds between updates of the widget, 2s by
|
- number of seconds between updates of the widget, 2s by default, also read
|
||||||
default, also read the "Power" section below
|
the "Power" section below
|
||||||
|
|
||||||
**warg**
|
**warg**
|
||||||
|
|
||||||
- some widget types require an argument to be passed, for example
|
- some widget types require an argument to be passed, for example the battery
|
||||||
the battery ID
|
ID
|
||||||
|
|
||||||
|
|
||||||
Other functions
|
Other functions
|
||||||
|
@ -146,212 +138,351 @@ argument given to vicious.register as the first argument, *warg* as
|
||||||
the second, and return a table of values to insert in the format
|
the second, and return a table of values to insert in the format
|
||||||
string.
|
string.
|
||||||
|
|
||||||
|
**vicious.widgets.bat**
|
||||||
|
|
||||||
|
Provides state, charge, and remaining time for a requested battery.
|
||||||
|
Supported platforms: Linux (required tools: `sysfs`), FreeBSD (required tools:
|
||||||
|
`acpiconf`).
|
||||||
|
|
||||||
|
- Arguments (per platform):
|
||||||
|
* Linux: takes battery ID as an argument, i.e. `"BAT0"`
|
||||||
|
* FreeBSD: takes optional battery ID as an argument, i.e. `"batt"` or `"0"`
|
||||||
|
- Returns (per platform):
|
||||||
|
* Linux: returns 1st value as state of requested battery, 2nd as charge
|
||||||
|
level in percent, 3rd as remaining (charging or discharging) time and 4th
|
||||||
|
as the wear level in percent
|
||||||
|
* FreeBSD: see Linux, but there's is 5th value for the present dis-/charge
|
||||||
|
rate in mW.
|
||||||
|
|
||||||
**vicious.widgets.cpu**
|
**vicious.widgets.cpu**
|
||||||
|
|
||||||
- provides CPU usage for all available CPUs/cores
|
Provides CPU usage for all available CPUs/cores.
|
||||||
- returns 1st value as usage of all CPUs/cores, 2nd as usage of
|
Supported platforms: Linux, FreeBSD.
|
||||||
first CPU/core, 3rd as usage of second CPU/core etc.
|
|
||||||
|
|
||||||
**vicious.widgets.cpuinf**
|
- Arguments:
|
||||||
|
* None
|
||||||
- provides speed and cache information for all available CPUs/cores
|
- Returns:
|
||||||
- returns a table with string keys, using CPU ID as a base:
|
* returns 1st value as usage of all CPUs/cores, 2nd as usage of first
|
||||||
{cpu0 mhz}, {cpu0 ghz}, {cpu0 kb}, {cpu0 mb}, {cpu1 mhz} etc.
|
CPU/core, 3rd as usage of second CPU/core etc.
|
||||||
|
|
||||||
**vicious.widgets.cpufreq**
|
**vicious.widgets.cpufreq**
|
||||||
|
|
||||||
- provides freq, voltage and governor info for a requested CPU
|
Provides freq, voltage and governor info for a requested CPU.
|
||||||
- takes the CPU ID as an argument, i.e. "cpu0"
|
Supported platforms: Linux, FreeBSD.
|
||||||
- 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
|
|
||||||
|
|
||||||
**vicious.widgets.thermal**
|
- Arguments (per platform):
|
||||||
|
* Linux: takes the CPU ID as an argument, i.e. `"cpu0"`
|
||||||
|
* FreeBSD: takes the CPU ID as an argument, i.e. `"0"`
|
||||||
|
- Returns (per platform):
|
||||||
|
* Linux: 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
|
||||||
|
* FreeBSD: 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,
|
||||||
|
but only the first two are supported (other values will be always `"N/A"`)
|
||||||
|
|
||||||
- provides temperature levels of ACPI and coretemp thermal zones
|
**vicious.widgets.cpuinf**
|
||||||
- takes the thermal zone as an argument, i.e. "thermal\_zone0", or a
|
|
||||||
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
|
|
||||||
- returns 1st value as temperature of requested thermal zone
|
|
||||||
|
|
||||||
**vicious.widgets.uptime**
|
Provides speed and cache information for all available CPUs/cores.
|
||||||
|
Supported platforms: Linux.
|
||||||
|
|
||||||
- provides system uptime and load information
|
- Arguments:
|
||||||
- returns 1st value as uptime in days, 2nd as uptime in hours, 3rd
|
* None
|
||||||
as uptime in minutes, 4th as load average for past 1 minute, 5th
|
- Returns:
|
||||||
for 5 minutes and 6th for 15 minutes
|
* returns a table with string keys, using CPU ID as a base: `{cpu0 mhz}`,
|
||||||
|
`{cpu0 ghz}`, `{cpu0 kb}`, `{cpu0 mb}`, `{cpu1 mhz}` etc.
|
||||||
**vicious.widgets.bat**
|
|
||||||
|
|
||||||
- provides state, charge, and remaining time for a requested battery
|
|
||||||
- takes battery ID as an argument, i.e. "BAT0"
|
|
||||||
- returns 1st value as state of requested battery, 2nd as charge
|
|
||||||
level in percent, 3rd as remaining (charging or discharging)
|
|
||||||
time and 4th as the wear level in percent
|
|
||||||
|
|
||||||
**vicious.widgets.mem**
|
|
||||||
|
|
||||||
- provides RAM and Swap usage statistics
|
|
||||||
- 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
|
|
||||||
in percent, 6th as swap usage, 7th as total system swap, 8th as
|
|
||||||
free swap and 9th as memory usage with buffers and cache
|
|
||||||
|
|
||||||
**vicious.widgets.os**
|
|
||||||
|
|
||||||
- provides operating system information
|
|
||||||
- returns 1st value as the operating system in use, 2nd as the
|
|
||||||
release version, 3rd as your username, 4th the hostname, 5th as
|
|
||||||
available system entropy and 6th value as available entropy in
|
|
||||||
percent
|
|
||||||
|
|
||||||
**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
|
|
||||||
- returns a table with string keys, using mount points as a base:
|
|
||||||
{/ size_mb}, {/ size_gb}, {/ used_mb}, {/ used_gb}, {/ used_p},
|
|
||||||
{/ avail_mb}, {/ avail_gb}, {/ avail_p}, {/home size_mb} etc.
|
|
||||||
|
|
||||||
**vicious.widgets.dio**
|
|
||||||
|
|
||||||
- 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.
|
|
||||||
|
|
||||||
**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
|
|
||||||
|
|
||||||
**vicious.widgets.hddtemp**
|
|
||||||
|
|
||||||
- provides hard drive temperatures using the hddtemp daemon
|
|
||||||
- takes the hddtemp listening port as an argument, or defaults to
|
|
||||||
port 7634
|
|
||||||
- returns a table with string keys, using hard drives as a base:
|
|
||||||
{/dev/sda} and {/dev/sdc} for example
|
|
||||||
|
|
||||||
**vicious.widgets.net**
|
|
||||||
|
|
||||||
- provides state and usage statistics of all network interfaces
|
|
||||||
- returns a table with string keys, using net interfaces as a base:
|
|
||||||
{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.
|
|
||||||
|
|
||||||
**vicious.widgets.wifi**
|
|
||||||
|
|
||||||
- provides wireless information for a requested interface
|
|
||||||
- takes the network interface as an argument, i.e. "wlan0"
|
|
||||||
- returns a table with string keys: {ssid}, {mode}, {chan}, {rate},
|
|
||||||
{link}, {linp} (link quality in percent) and {sign} (signal level)
|
|
||||||
|
|
||||||
**vicious.widgets.wifiiw**
|
|
||||||
|
|
||||||
- similar to vicious.widgets.wifi, but uses iw instead of iwconfig
|
|
||||||
- provides wireless information for a requested interface
|
|
||||||
- takes the network interface as an argument, i.e. "wlan0"
|
|
||||||
- returns a table with string keys: {ssid}, {mode}, {chan}, {rate},
|
|
||||||
{freq}, {linp} (link quality in percent), {txpw} (tx power) and {sign} (signal level)
|
|
||||||
|
|
||||||
|
|
||||||
**vicious.widgets.mbox**
|
|
||||||
|
|
||||||
- provides the subject of last e-mail in a mbox file
|
|
||||||
- takes the full path to the mbox as an argument, or a table with
|
|
||||||
1st field as path, 2nd as maximum length and 3rd (optional) as
|
|
||||||
widget name - if 3rd field is present scrolling will be used (note: the
|
|
||||||
path will be escaped so special variables like ~ will not work, use
|
|
||||||
os.getenv("HOME").."mail" instead to access environment variables)
|
|
||||||
- returns 1st value as the subject of the last e-mail
|
|
||||||
|
|
||||||
**vicious.widgets.mboxc**
|
|
||||||
|
|
||||||
- provides the count of total, old and new messages in mbox files
|
|
||||||
- takes a table with full paths to mbox files as an argument
|
|
||||||
- returns 1st value as the total count of messages, 2nd as the count
|
|
||||||
of old messages and 3rd as the count of new messages
|
|
||||||
|
|
||||||
**vicious.widgets.mdir**
|
|
||||||
|
|
||||||
- provides the number of new and unread messages in Maildir
|
|
||||||
structures/directories
|
|
||||||
- takes a table with full paths to Maildir structures as an argument
|
|
||||||
- returns 1st value as the count of new messages and 2nd as the
|
|
||||||
count of "old" messages lacking the Seen flag
|
|
||||||
|
|
||||||
**vicious.widgets.gmail**
|
|
||||||
|
|
||||||
- provides count of new and subject of last e-mail on Gmail
|
|
||||||
- takes an (optional) argument, if it's a number subject will be
|
|
||||||
truncated, if a table, with 1st field as maximum length and 2nd
|
|
||||||
the widget name (i.e. "gmailwidget"), scrolling will be used
|
|
||||||
- keeps login information in the ~/.netrc file, example:
|
|
||||||
machine mail.google.com login user password pass
|
|
||||||
- returns a table with string keys: {count} and {subject}
|
|
||||||
- to be able to use this widget, make sure in your Gmail account
|
|
||||||
you disabled
|
|
||||||
[two step verification](https://support.google.com/accounts/answer/1064203)
|
|
||||||
and _then_
|
|
||||||
[allowed access to your account for less secure apps](https://www.google.com/settings/security/lesssecureapps)
|
|
||||||
|
|
||||||
**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
|
|
||||||
- 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
|
|
||||||
|
|
||||||
**vicious.widgets.pkg**
|
|
||||||
|
|
||||||
- provides number of pending updates on UNIX systems
|
|
||||||
- takes the distribution name as an argument, i.e. "Arch"
|
|
||||||
- returns 1st value as the count of available updates
|
|
||||||
|
|
||||||
**vicious.widgets.mpd**
|
|
||||||
|
|
||||||
- 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},
|
|
||||||
{Title}, {Album}, {Genre} and optionally {Name} and {file}
|
|
||||||
|
|
||||||
**vicious.widgets.volume**
|
|
||||||
|
|
||||||
- provides volume levels and state of requested ALSA mixers
|
|
||||||
- takes the ALSA mixer control as an argument, i.e. "Master",
|
|
||||||
optionally append the card ID or other options, i.e. "PCM -c 0"
|
|
||||||
- returns 1st value as the volume level and 2nd as the mute state of
|
|
||||||
the requested channel
|
|
||||||
|
|
||||||
**vicious.widgets.weather**
|
|
||||||
|
|
||||||
- provides weather information for a requested station
|
|
||||||
- takes the ICAO station code as an argument, i.e. "LDRI"
|
|
||||||
- returns a table with string keys: {city}, {wind}, {windmph},
|
|
||||||
{windkmh}, {sky}, {weather}, {tempf}, {tempc}, {humid}, {dewf},
|
|
||||||
{dewc}, {press}
|
|
||||||
|
|
||||||
**vicious.widgets.date**
|
**vicious.widgets.date**
|
||||||
|
|
||||||
- provides access to os.date, with optional time formatting provided
|
Provides access to os.date, with optional time formatting provided as the
|
||||||
as the format string - using regular date sequences
|
format string - using regular date sequences.
|
||||||
- takes optional time offset, in seconds, as an argument for example
|
Supported platforms: platform independent.
|
||||||
to calculate time zone differences, otherwise current time is
|
|
||||||
formatted
|
- Arguments:
|
||||||
- returns the output of os.date, formatted by provided sequences
|
* takes optional time offset, in seconds, as an argument for example to
|
||||||
|
calculate time zone differences, otherwise current time is formatted
|
||||||
|
- Returns:
|
||||||
|
* returns the output of os.date, formatted by provided sequences
|
||||||
|
|
||||||
|
**vicious.widgets.dio**
|
||||||
|
|
||||||
|
Provides I/O statistics for all available storage devices.
|
||||||
|
Supported platforms: Linux.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* None
|
||||||
|
- Returns:
|
||||||
|
* 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.
|
||||||
|
|
||||||
|
**vicious.widget.fanspeed**
|
||||||
|
|
||||||
|
Provides fanspeed information for specified fan.
|
||||||
|
Supported platforms: FreeBSD.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* Full sysctl string to entry, i.e. `"dev.acpi_ibm.0.fan_speed"`
|
||||||
|
- Returns:
|
||||||
|
* Speed of specified fan as number, `-1` for error (probably wrong string)
|
||||||
|
|
||||||
|
**vicious.widgets.fs**
|
||||||
|
|
||||||
|
Provides usage of file system disk space.
|
||||||
|
Supported platforms: platform independent.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* takes an (optional) argument which, if true, includes remote file systems,
|
||||||
|
only local file systems are included by default
|
||||||
|
- Returns:
|
||||||
|
* returns a table with string keys, using mount points as a base:
|
||||||
|
`{/ size_mb}`, `{/ size_gb}`, `{/ used_mb}`, `{/ used_gb}`, `{/ used_p}`,
|
||||||
|
`{/ avail_mb}`, `{/ avail_gb}`, `{/ avail_p}`, `{/home size_mb}` etc.
|
||||||
|
|
||||||
|
**vicious.widgets.gmail**
|
||||||
|
|
||||||
|
Provides count of new and subject of last e-mail on Gmail.
|
||||||
|
Supported platform: platform independent (required tools: `curl`).
|
||||||
|
|
||||||
|
This widget expects login information in your `~/.netrc` file, e. g.
|
||||||
|
`machine mail.google.com login user password pass` and you have to disable
|
||||||
|
[two step verification](https://support.google.com/accounts/answer/1064203).
|
||||||
|
[Allow access for less secure apps](https://www.google.com/settings/security/lesssecureapps)
|
||||||
|
afterwards. BE AWARE THAT MAKING THESE SETTINGS IS A SECURITY RISK!
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* takes an (optional) argument, if it's a number subject will be truncated,
|
||||||
|
if a table, with 1st field as maximum length and 2nd the widget name (i.e.
|
||||||
|
"gmailwidget"), scrolling will be used
|
||||||
|
- Returns:
|
||||||
|
* returns a table with string keys: {count} and {subject}
|
||||||
|
|
||||||
|
**vicious.widgets.hddtemp**
|
||||||
|
|
||||||
|
Provides hard drive temperatures using the hddtemp daemon.
|
||||||
|
Supported platforms: Linux (required tools: `hddtemp`, `curl`).
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* takes the hddtemp listening port as an argument, or defaults to port 7634
|
||||||
|
- Returns:
|
||||||
|
* returns a table with string keys, using hard drives as a base: `{/dev/sda}`
|
||||||
|
and `{/dev/sdc}` for example
|
||||||
|
|
||||||
|
**vicious.widgets.mbox**
|
||||||
|
|
||||||
|
Provides the subject of last e-mail in a mbox file.
|
||||||
|
Supported platforms: platform independent.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* takes the full path to the mbox as an argument, or a table with 1st field
|
||||||
|
as path, 2nd as maximum length and 3rd (optional) as widget name - if 3rd
|
||||||
|
field is present scrolling will be used (note: the path will be escaped so
|
||||||
|
special variables like ~ will not work, use os.getenv("HOME").."mail"
|
||||||
|
instead to access environment variables)
|
||||||
|
- Returns:
|
||||||
|
* returns 1st value as the subject of the last e-mail
|
||||||
|
|
||||||
|
**vicious.widgets.mboxc**
|
||||||
|
|
||||||
|
Provides the count of total, old and new messages in mbox files.
|
||||||
|
Supported platforms: platform independent.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* takes a table with full paths to mbox files as an argument
|
||||||
|
- Returns:
|
||||||
|
* returns 1st value as the total count of messages, 2nd as the count of old
|
||||||
|
messages and 3rd as the count of new messages
|
||||||
|
|
||||||
|
**vicious.widgets.mdir**
|
||||||
|
|
||||||
|
Provides the number of new and unread messages in Maildir
|
||||||
|
structures/directories.
|
||||||
|
Supported platforms: platform independent.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* takes a table with full paths to Maildir structures as an argument
|
||||||
|
- Returns:
|
||||||
|
* returns 1st value as the count of new messages and 2nd as the count of
|
||||||
|
"old" messages lacking the Seen flag
|
||||||
|
|
||||||
|
**vicious.widgets.mem**
|
||||||
|
|
||||||
|
Provides RAM and Swap usage statistics.
|
||||||
|
Supported platforms: Linux, FreeBSD.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* None
|
||||||
|
- Returns (per platform):
|
||||||
|
* Linux: 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 in percent, 6th
|
||||||
|
as swap usage, 7th as total system swap, 8th as free swap and 9th as
|
||||||
|
memory usage with buffers and cache
|
||||||
|
* FreeBSD: see above, but 10th value as memory usage with buffers and cache
|
||||||
|
as percent and 11th value as wired memory (memory used by kernel) is
|
||||||
|
reported
|
||||||
|
|
||||||
|
**vicious.widgets.mpd**
|
||||||
|
|
||||||
|
Provides Music Player Daemon information.
|
||||||
|
Supported platforms: platform independent (required tools: `curl`).
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* 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:
|
||||||
|
* returns a table with string keys: `{volume}`, `{state}`, `{Artist}`, `{Title}`,
|
||||||
|
`{Album}`, `{Genre}` and optionally `{Name}` and `{file}`
|
||||||
|
|
||||||
|
**vicious.widgets.net**
|
||||||
|
|
||||||
|
Provides state and usage statistics of network interfaces.
|
||||||
|
Supported platforms: Linux, FreeBSD.
|
||||||
|
|
||||||
|
- Arguments (per platform):
|
||||||
|
* Linux: none
|
||||||
|
* FreeBSD: desired interface, e.g. `wlan0`
|
||||||
|
- Returns (per platform):
|
||||||
|
* Linux: returns a table with string keys, using net interfaces as a base:
|
||||||
|
`{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.
|
||||||
|
* FreeBSD: returns a table with string keys:
|
||||||
|
`{carrier}`, `{rx_b}`, `{tx_b}`, `{rx_kb}`, `{tx_kb}`,
|
||||||
|
`{rx_mb}`, `{tx_mb}`, `{rx_gb}`, `{tx_gb}`, `{down_b}`,
|
||||||
|
`{up_b}`, `{down_kb}`, `{up_kb}`, `{down_mb}`,
|
||||||
|
`{up_mb}`, `{down_gb}`, `{up_gb}`
|
||||||
|
|
||||||
|
**vicious.widgets.org**
|
||||||
|
|
||||||
|
Provides agenda statistics for Emacs org-mode.
|
||||||
|
Supported platforms: platform independent.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* takes a table with full paths to agenda files, that will be parsed, as an
|
||||||
|
argument
|
||||||
|
- Returns:
|
||||||
|
* 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
|
||||||
|
|
||||||
|
**vicious.widgets.os**
|
||||||
|
|
||||||
|
Provides operating system information.
|
||||||
|
Supported platforms: platform independent.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* None
|
||||||
|
- Returns:
|
||||||
|
* returns 1st value as the operating system in use, 2nd as the release
|
||||||
|
version, 3rd as your username, 4th the hostname, 5th as available system
|
||||||
|
entropy and 6th value as available entropy in percent
|
||||||
|
|
||||||
|
**vicious.widgets.pkg**
|
||||||
|
|
||||||
|
Provides number of pending updates on UNIX systems. Be aware that some package
|
||||||
|
managers need to update their local databases (as root) before showing the
|
||||||
|
correct number of updates.
|
||||||
|
Supported platforms: platform independent.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* takes the Linux or BSD distribution name as an argument, i.e. "Arch",
|
||||||
|
"FreeBSD"
|
||||||
|
- Returns:
|
||||||
|
* returns 1st value as the count of available updates
|
||||||
|
|
||||||
|
**vicious.widgets.raid**
|
||||||
|
|
||||||
|
Provides state information for a requested RAID array.
|
||||||
|
Supported platforms: Linux.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* Takes the RAID array ID as an argument
|
||||||
|
- Returns:
|
||||||
|
* Returns 1st value as the number of assigned, and 2nd as active, devices in
|
||||||
|
the array
|
||||||
|
|
||||||
|
**vicious.widgets.thermal**
|
||||||
|
|
||||||
|
Provides temperature levels of several thermal zones.
|
||||||
|
Supported platforms: Linux, FreeBSD.
|
||||||
|
|
||||||
|
- Arguments (per platform):
|
||||||
|
* Linux: takes the thermal zone as an argument, i.e. `"thermal_zone0"`, or a
|
||||||
|
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
|
||||||
|
* FreeBSD: takes the full sysctl path to a thermal zone as an argument, i.e.
|
||||||
|
`"hw.acpi.thermal.tz0.temperature"`, or a table with multiple paths
|
||||||
|
- Returns:
|
||||||
|
* Linux: returns 1st value as temperature of requested thermal zone
|
||||||
|
* FreeBSD: returns a table with a entry for every input thermal zone
|
||||||
|
|
||||||
|
**vicious.widgets.uptime**
|
||||||
|
|
||||||
|
Provides system uptime and load information.
|
||||||
|
Supported platforms: Linux, FreeBSD.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* None
|
||||||
|
- Returns:
|
||||||
|
* 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
|
||||||
|
|
||||||
|
**vicious.widgets.volume**
|
||||||
|
|
||||||
|
Provides volume levels and state of requested mixers.
|
||||||
|
Supported platforms: Linux (required tool: amixer), FreeBSD.
|
||||||
|
|
||||||
|
- Arguments (per platform):
|
||||||
|
* Linux: takes the ALSA mixer control as an argument, i.e. `"Master"`,
|
||||||
|
optionally append the card ID or other options, i.e. `"PCM -c 0"`
|
||||||
|
* FreeBSD: takes the mixer control as an argument, i.e. `"vol"`
|
||||||
|
- Returns:
|
||||||
|
* Linux: returns 1st value as the volume level and 2nd as the mute state of
|
||||||
|
the requested control
|
||||||
|
* FreeBSD: returns 1st value as the volume level of the left channel, 2nd as
|
||||||
|
the volume level of the right channel and 3rd as the mute state of the
|
||||||
|
desired control
|
||||||
|
|
||||||
|
**vicious.widgets.weather**
|
||||||
|
|
||||||
|
Provides weather information for a requested station.
|
||||||
|
Supported platforms: platform independent (required tools: `curl`).
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* Takes the ICAO station code as an argument, i.e. `"LDRI"`
|
||||||
|
- Returns:
|
||||||
|
* Returns a table with string keys: `{city}`, `{wind}`, `{windmph}`,
|
||||||
|
`{windkmh}`, `{sky}`, `{weather}`, `{tempf}`, `{tempc}`, `{humid}`,
|
||||||
|
`{dewf}`, `{dewc}` and `{press}`
|
||||||
|
|
||||||
|
**vicious.widgets.wifi**
|
||||||
|
|
||||||
|
Provides wireless information for a requested interface.
|
||||||
|
Supported platforms: Linux.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* Takes the network interface as an argument, i.e. "wlan0"
|
||||||
|
- Returns:
|
||||||
|
* Returns a table with string keys: `{ssid}`, `{mode}`, `{chan}`, `{rate}`,
|
||||||
|
`{link}`, `{linp}` (link quality in percent) and `{sign}` (signal level)
|
||||||
|
|
||||||
|
**vicious.widgets.wifiiw**
|
||||||
|
|
||||||
|
Provides wireless information for a requested interface (similar to
|
||||||
|
vicious.widgets.wifi, but uses iw instead of iwconfig).
|
||||||
|
Supported platforms: Linux.
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* Takes the network interface as an argument, i.e. "wlan0"
|
||||||
|
- Returns:
|
||||||
|
* Returns a table with string keys: `{ssid}`, `{mode}`, `{chan}`, `{rate}`,
|
||||||
|
`{freq}`, `{linp}` (link quality in percent), `{txpw}` (tx power) and
|
||||||
|
`{sign}` (signal level)
|
||||||
|
|
||||||
|
|
||||||
Custom widget types
|
Custom widget types
|
||||||
|
@ -361,18 +492,12 @@ 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
|
in. How data will be formatted, will it be red or blue, should be
|
||||||
defined in rc.lua (or somewhere else, outside the actual module).
|
defined in rc.lua (or somewhere else, outside the actual module).
|
||||||
|
|
||||||
Before writing a widget type you should check if there is already one
|
Before writing a widget type you should check if there is already one in the
|
||||||
in the contrib directory of Vicious. The contrib directory contains
|
contrib directory of Vicious. The contrib directory contains extra widgets you
|
||||||
extra widgets you can use. Some are for less common hardware, and
|
can use. Some are for less common hardware, and other were contributed by
|
||||||
other were contributed by Vicious users. The contrib directory also
|
Vicious users. Most of the contrib widgets are obsolete. Contrib widgets will
|
||||||
holds widget types that were obsoleted or rewritten. Contrib widgets
|
not be imported by init unless you explicitly enable it, or load them in your
|
||||||
will not be imported by init unless you explicitly enable it, or load
|
rc.lua.
|
||||||
them in your rc.lua.
|
|
||||||
|
|
||||||
Rudi Siegel, a FreeBSD user, published his FreeBSD branch. If you are
|
|
||||||
also a BSD user you can find his work here:
|
|
||||||
|
|
||||||
- https://bitbucket.org/mutluyum/vicious_bsd/
|
|
||||||
|
|
||||||
Some users would like to avoid writing new modules. For them Vicious
|
Some users would like to avoid writing new modules. For them Vicious
|
||||||
kept the old Wicked functionality, possibility to register their own
|
kept the old Wicked functionality, possibility to register their own
|
||||||
|
@ -408,17 +533,15 @@ enables you to have multiple widgets using the same widget type. With
|
||||||
caching its worker function gets executed only once - which is also
|
caching its worker function gets executed only once - which is also
|
||||||
great for saving power.
|
great for saving power.
|
||||||
|
|
||||||
- Some widget types keep internal data and if you call one multiple
|
- Some widget types keep internal data and if you call one multiple times
|
||||||
times without caching, the widget that executes it first would
|
without caching, the widget that executes it first would modify stored
|
||||||
modify stored values. This can lead to problems and give you
|
values. This can lead to problems and give you inconsistent data. Remember
|
||||||
inconsistent data. Remember it for widget types like CPU and
|
it for widget types like CPU and Network usage, which compare the old set of
|
||||||
Network usage, which compare the old set of data with the new one
|
data with the new one to calculate current usage.
|
||||||
to calculate current usage.
|
|
||||||
|
|
||||||
- Widget types that require a widget argument to be passed should be
|
- Widget types that require a widget argument to be passed should be handled
|
||||||
handled carefully. If you are requesting information for different
|
carefully. If you are requesting information for different devices then
|
||||||
devices then caching should not be used, because you could get
|
caching should not be used, because you could get inconsistent data.
|
||||||
inconsistent data.
|
|
||||||
|
|
||||||
|
|
||||||
Security
|
Security
|
||||||
|
@ -536,8 +659,8 @@ change it or perform some action. You can change the color of the
|
||||||
battery widget when it goes below a certain point, hide widgets when
|
battery widget when it goes below a certain point, hide widgets when
|
||||||
they return a certain value or maybe use string.format for padding.
|
they return a certain value or maybe use string.format for padding.
|
||||||
|
|
||||||
- Do not confuse this with just coloring the widget, in those cases
|
- Do not confuse this with just coloring the widget, in those cases standard
|
||||||
standard pango markup can be inserted into the format string.
|
pango markup can be inserted into the format string.
|
||||||
|
|
||||||
The format function will get the widget as its first argument, table
|
The format function will get the widget as its first argument, table
|
||||||
with the values otherwise inserted into the format string as its
|
with the values otherwise inserted into the format string as its
|
||||||
|
@ -633,7 +756,7 @@ Other
|
||||||
-----
|
-----
|
||||||
Read *"awesome"* manual pages:
|
Read *"awesome"* manual pages:
|
||||||
|
|
||||||
- awesome(1) awesomerc(5)
|
- awesome(1) awesomerc(5)
|
||||||
|
|
||||||
[Awesome widgets explained](http://awesome.naquadah.org/wiki/Widgets_in_awesome)
|
[Awesome widgets explained](http://awesome.naquadah.org/wiki/Widgets_in_awesome)
|
||||||
|
|
||||||
|
@ -641,29 +764,29 @@ Read *"awesome"* manual pages:
|
||||||
|
|
||||||
Example "awesome" configuration:
|
Example "awesome" configuration:
|
||||||
|
|
||||||
- http://git.sysphere.org/awesome-configs/
|
- http://git.sysphere.org/awesome-configs/
|
||||||
|
|
||||||
|
|
||||||
Authors
|
Authors
|
||||||
-------
|
-------
|
||||||
Wicked written by:
|
Wicked written by:
|
||||||
|
|
||||||
- Lucas de Vries \<lucas glacicle.com\>
|
- Lucas de Vries \<lucas glacicle.com\>
|
||||||
|
|
||||||
Vicious written by:
|
Vicious written by:
|
||||||
|
|
||||||
- Adrian C. (anrxc) \<anrxc sysphere.org\>
|
- Adrian C. (anrxc) \<anrxc sysphere.org\>
|
||||||
|
|
||||||
Vicious major contributors:
|
Vicious major contributors:
|
||||||
|
|
||||||
- Benedikt Sauer \<filmor gmail.com\>
|
- Benedikt Sauer \<filmor gmail.com\>
|
||||||
- Greg D. \<jabbas jabbas.pl\>
|
- Greg D. \<jabbas jabbas.pl\>
|
||||||
- Henning Glawe \<glaweh debian.org\>
|
- Henning Glawe \<glaweh debian.org\>
|
||||||
- Rémy C. \<shikamaru mandriva.org\>
|
- Rémy C. \<shikamaru mandriva.org\>
|
||||||
- Hiltjo Posthuma \<hiltjo codemadness.org\>
|
- Hiltjo Posthuma \<hiltjo codemadness.org\>
|
||||||
- Hagen Schink \<troja84 googlemail.com\>
|
- Hagen Schink \<troja84 googlemail.com\>
|
||||||
- Jörg Thalheim \<jthalheim gmail.com\>
|
- Jörg Thalheim \<jthalheim gmail.com\>
|
||||||
- Arvydas Sidorenko \<asido4 gmail.com\>
|
- Arvydas Sidorenko \<asido4 gmail.com\>
|
||||||
- Dodo The Last <dodo.the.last gmail.com>
|
- Dodo The Last <dodo.the.last gmail.com>
|
||||||
- ...
|
- ...
|
||||||
- Consult git log for a complete list of contributors
|
- Consult git log for a complete list of contributors
|
||||||
|
|
154
contrib/README
154
contrib/README
|
@ -1,154 +0,0 @@
|
||||||
Contrib
|
|
||||||
-------
|
|
||||||
Contrib libraries, or widget types, are extra snippets of code you can
|
|
||||||
use. Some are for less common hardware, and other were contributed by
|
|
||||||
Vicious users. The contrib directory also holds widget types that were
|
|
||||||
obsoleted or rewritten. Contrib widgets will not be imported by init
|
|
||||||
unless you explicitly enable it, or load them in your rc.lua.
|
|
||||||
|
|
||||||
|
|
||||||
Usage within Awesome
|
|
||||||
--------------------
|
|
||||||
To use contrib widgets uncomment the line that loads them in
|
|
||||||
init.lua. Or you can load them in your rc.lua after you require
|
|
||||||
Vicious:
|
|
||||||
|
|
||||||
vicious = require("vicious")
|
|
||||||
vicious.contrib = require("vicious.contrib")
|
|
||||||
|
|
||||||
|
|
||||||
Widget types
|
|
||||||
------------
|
|
||||||
Most 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. But we have not insisted on this coding style in contrib. So
|
|
||||||
widgets like PulseAudio have emerged that are different. These widgets
|
|
||||||
could also depend on Lua libraries that are not distributed with the
|
|
||||||
core Lua distribution. Ease of installation and use does not
|
|
||||||
necessarily have to apply to contributed widgets.
|
|
||||||
|
|
||||||
vicious.contrib.ac
|
|
||||||
- provide status about the power supply (AC)
|
|
||||||
- takes the AC device as an argument, i.e "AC" or "ACAD"
|
|
||||||
- the device is linked under /sys/class/power_supply/ and should
|
|
||||||
have a file called "online"
|
|
||||||
- if AC is connected, $1 returns "On", if not it returns "Off",
|
|
||||||
if AC doesn't exist, $1 is "N/A"
|
|
||||||
|
|
||||||
vicious.contrib.ati
|
|
||||||
- provides various info about ATI GPU status
|
|
||||||
- takes card ID as an argument, i.e. "card0" (and where possible,
|
|
||||||
uses debugfs to gather data on radeon power management)
|
|
||||||
- returns a table with string keys: {method}, {dpm_state},
|
|
||||||
{dpm_perf_level}, {profile}, {engine_clock mhz}, {engine_clock khz},
|
|
||||||
{memory_clock mhz}, {memory_clock khz}, {voltage v}, {voltage mv}
|
|
||||||
|
|
||||||
vicious.contrib.batacpi
|
|
||||||
-
|
|
||||||
|
|
||||||
vicious.contrib.batpmu
|
|
||||||
-
|
|
||||||
|
|
||||||
vicious.contrib.batproc
|
|
||||||
-
|
|
||||||
|
|
||||||
vicious.contrib.dio
|
|
||||||
- provides I/O statistics for requested storage devices
|
|
||||||
- takes the disk as an argument, i.e. "sda" (or a specific
|
|
||||||
partition, i.e. "sda/sda2")
|
|
||||||
- returns a table with string keys: {total_s}, {total_kb}, {total_mb},
|
|
||||||
{read_s}, {read_kb}, {read_mb}, {write_s}, {write_kb}, {write_mb}
|
|
||||||
and {sched}
|
|
||||||
|
|
||||||
vicious.contrib.mpc
|
|
||||||
-
|
|
||||||
|
|
||||||
vicious.contrib.netcfg
|
|
||||||
-
|
|
||||||
|
|
||||||
vicious.contrib.net
|
|
||||||
-
|
|
||||||
|
|
||||||
vicious.contrib.openweather
|
|
||||||
- provides weather information for a requested city
|
|
||||||
- takes OpenWeatherMap city ID as an argument, i.e. "1275339"
|
|
||||||
- returns a table with string keys: {city}, {wind deg}, {wind aim},
|
|
||||||
{wind kmh}, {wind mps}, {sky}, {weather}, {temp c}, {humid}, {press}
|
|
||||||
|
|
||||||
vicious.contrib.nvinf
|
|
||||||
- provides GPU utilization, core temperature, clock frequency information
|
|
||||||
about Nvidia GPU from nvidia-settings
|
|
||||||
- takes optional card ID as an argument, i.e. "1", or defaults to ID 0
|
|
||||||
- returns first 4 values as usage of GPU core, memory, video engine and
|
|
||||||
PCIe bandwidth, 5th as temperature of requested graphics device, 6th
|
|
||||||
as frequency of GPU core, 7th as memory transfer rate
|
|
||||||
|
|
||||||
vicious.contrib.nvsmi
|
|
||||||
- provides (very basic) information about Nvidia GPU status from SMI
|
|
||||||
- takes optional card ID as an argument, i.e. "1", or defaults to ID 0
|
|
||||||
- returns 1st value as temperature of requested graphics device
|
|
||||||
|
|
||||||
vicious.contrib.ossvol
|
|
||||||
-
|
|
||||||
|
|
||||||
vicious.contrib.pop
|
|
||||||
-
|
|
||||||
|
|
||||||
vicious.contrib.pulse
|
|
||||||
- provides volume levels of requested pulseaudio sinks and
|
|
||||||
functions to manipulate them
|
|
||||||
- takes the name of a sink as an optional argument. a number will
|
|
||||||
be interpret as an index, if no argument is given, it will take
|
|
||||||
the first-best
|
|
||||||
- to get a list of available sinks use the command: pacmd
|
|
||||||
list-sinks | grep 'name:'
|
|
||||||
- returns 1st value as the volume level
|
|
||||||
- vicious.contrib.pulse.add(percent, sink)
|
|
||||||
- @percent is a number, which increments or decrements the volume
|
|
||||||
level by its value in percent
|
|
||||||
- @sink optional, same usage as in vicious.contrib.pulse
|
|
||||||
- returns the exit status of pacmd
|
|
||||||
- vicious.contrib.pulse.toggle(sink)
|
|
||||||
- inverts the volume state (mute -> unmute; unmute -> mute)
|
|
||||||
- @sink optional, same usage as in vicious.contrib.pulse
|
|
||||||
- returns the exit status of pacmd
|
|
||||||
|
|
||||||
vicious.contrib.rss
|
|
||||||
-
|
|
||||||
|
|
||||||
vicious.contrib.sensors
|
|
||||||
-
|
|
||||||
|
|
||||||
vicious.contrib.wpa
|
|
||||||
- provides information about the wifi status
|
|
||||||
- requires 'wpa_cli' from wpa_supplicant
|
|
||||||
- takes the interface as an argument, i.e "wlan0" or "wlan1"
|
|
||||||
- returns a table with string keys: {ssid}, {qual}, {ip}, {bssid}
|
|
||||||
|
|
||||||
vicious.contrib.buildbot
|
|
||||||
- provides last build status for configured buildbot builders (http://trac.buildbot.net/)
|
|
||||||
- returns build status in the format: [<builderName>.<currentBuildNumber>.<lastSuccessfulBuildNumber>]
|
|
||||||
- if <currentBuildNumber> is the same as <lastSuccessfulBuildNumber> only one number is displayed
|
|
||||||
- <buildNumber> colors: red - failed, green - successful, yellow - in progress
|
|
||||||
- it depends on lua json parser (e.g. liblua5.1-json on Ubuntu 12.04)
|
|
||||||
|
|
||||||
|
|
||||||
Usage examples
|
|
||||||
---------------------------------
|
|
||||||
Pulse Audio widget
|
|
||||||
vol = wibox.widget.textbox()
|
|
||||||
vicious.register(vol, vicious.contrib.pulse, " $1%", 2, "alsa_output.pci-0000_00_1b.0.analog-stereo")
|
|
||||||
vol:buttons(awful.util.table.join(
|
|
||||||
awful.button({ }, 1, function () awful.util.spawn("pavucontrol") end),
|
|
||||||
awful.button({ }, 4, function () vicious.contrib.pulse.add(5,"alsa_output.pci-0000_00_1b.0.analog-stereo") end),
|
|
||||||
awful.button({ }, 5, function () vicious.contrib.pulse.add(-5,"alsa_output.pci-0000_00_1b.0.analog-stereo") end)
|
|
||||||
))
|
|
||||||
|
|
||||||
Buildbot widget
|
|
||||||
buildbotwidget = wibox.widget.textbox()
|
|
||||||
local buildbotwidget_warg = {
|
|
||||||
{builder="coverage", url="http://buildbot.buildbot.net"},
|
|
||||||
{builder="tarball-slave", url="http://buildbot.buildbot.net"}
|
|
||||||
}
|
|
||||||
vicious.register(buildbotwidget, vicious.contrib.buildbot, "$1,", 3600, buildbotwidget_warg)
|
|
|
@ -0,0 +1,184 @@
|
||||||
|
Contrib
|
||||||
|
-------
|
||||||
|
Contrib libraries, or widget types, are extra snippets of code you can
|
||||||
|
use. Some are for less common hardware, and other were contributed by
|
||||||
|
Vicious users. The contrib directory also holds widget types that were
|
||||||
|
obsoleted or rewritten. Contrib widgets will not be imported by init
|
||||||
|
unless you explicitly enable it, or load them in your rc.lua.
|
||||||
|
|
||||||
|
|
||||||
|
Usage within Awesome
|
||||||
|
--------------------
|
||||||
|
To use contrib widgets uncomment the line that loads them in
|
||||||
|
init.lua. Or you can load them in your rc.lua after you require
|
||||||
|
Vicious:
|
||||||
|
|
||||||
|
vicious = require("vicious")
|
||||||
|
vicious.contrib = require("vicious.contrib")
|
||||||
|
|
||||||
|
|
||||||
|
Widget types
|
||||||
|
------------
|
||||||
|
Most 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. But we have not insisted on this coding style in contrib. So
|
||||||
|
widgets like PulseAudio have emerged that are different. These widgets
|
||||||
|
could also depend on Lua libraries that are not distributed with the
|
||||||
|
core Lua distribution. Ease of installation and use does not
|
||||||
|
necessarily have to apply to contributed widgets.
|
||||||
|
|
||||||
|
**vicious.contrib.ac**
|
||||||
|
|
||||||
|
Provide status about the power supply (AC)
|
||||||
|
Supported platforms: Linux (required tools: `sysfs`)
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* takes the AC device as an argument, i.e "AC" or "ACAD"
|
||||||
|
* the device is linked under /sys/class/power_supply/ and should
|
||||||
|
have a file called "online"
|
||||||
|
- Returns
|
||||||
|
* if AC is connected, $1 returns "On", if not it returns "Off",
|
||||||
|
if AC doesn't exist, $1 is "N/A"
|
||||||
|
|
||||||
|
**vicious.contrib.ati**
|
||||||
|
|
||||||
|
Provides various info about ATI GPU status.
|
||||||
|
Supported platforms: Linux (required tools: `sysfs`)
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* takes card ID as an argument, i.e. "card0" (and where possible,
|
||||||
|
uses debugfs to gather data on radeon power management)
|
||||||
|
- Returns:
|
||||||
|
* a table with string keys: {method}, {dpm_state},
|
||||||
|
{dpm_perf_level}, {profile}, {engine_clock mhz}, {engine_clock khz},
|
||||||
|
{memory_clock mhz}, {memory_clock khz}, {voltage v}, {voltage mv}
|
||||||
|
|
||||||
|
**vicious.contrib.batpmu**
|
||||||
|
|
||||||
|
**vicious.contrib.batproc**
|
||||||
|
|
||||||
|
**vicious.contrib.countfiles**
|
||||||
|
|
||||||
|
**vicious.contrib.dio**
|
||||||
|
|
||||||
|
Provides I/O statistics for requested storage devices
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
- takes the disk as an argument, i.e. "sda" (or a specific
|
||||||
|
partition, i.e. "sda/sda2")
|
||||||
|
- Returns:
|
||||||
|
- a table with string keys: {total_s}, {total_kb}, {total_mb},
|
||||||
|
{read_s}, {read_kb}, {read_mb}, {write_s}, {write_kb}, {write_mb}
|
||||||
|
and {sched}
|
||||||
|
|
||||||
|
**vicious.contrib.mpc**
|
||||||
|
|
||||||
|
vicious.contrib.netcfg
|
||||||
|
-
|
||||||
|
|
||||||
|
**vicious.contrib.net**
|
||||||
|
|
||||||
|
**vicious.contrib.openweather**
|
||||||
|
|
||||||
|
Provides weather information for a requested city
|
||||||
|
|
||||||
|
- Arguments
|
||||||
|
* takes OpenWeatherMap city ID as an argument, i.e. "1275339"
|
||||||
|
- Returns
|
||||||
|
* a table with string keys: {city}, {wind deg}, {wind aim},
|
||||||
|
{wind kmh}, {wind mps}, {sky}, {weather}, {temp c}, {humid}, {press}
|
||||||
|
|
||||||
|
**vicious.contrib.nvinf**
|
||||||
|
|
||||||
|
provides GPU utilization, core temperature, clock frequency information about Nvidia GPU from nvidia-settings
|
||||||
|
Supported Platforms: platform independent
|
||||||
|
|
||||||
|
- Arguments
|
||||||
|
* takes optional card ID as an argument, i.e. "1", or defaults to ID 0
|
||||||
|
- Returns
|
||||||
|
* first 4 values as usage of GPU core, memory, video engine and
|
||||||
|
PCIe bandwidth, 5th as temperature of requested graphics device, 6th
|
||||||
|
as frequency of GPU core, 7th as memory transfer rate
|
||||||
|
|
||||||
|
**vicious.contrib.nvsmi**
|
||||||
|
|
||||||
|
Provides (very basic) information about Nvidia GPU status from SMI
|
||||||
|
Supported Platforms: platform independent
|
||||||
|
|
||||||
|
- Arguments:
|
||||||
|
* takes optional card ID as an argument, i.e. "1", or defaults to ID 0
|
||||||
|
- Returns:
|
||||||
|
* returns 1st value as temperature of requested graphics device
|
||||||
|
|
||||||
|
**vicious.contrib.ossvol**
|
||||||
|
|
||||||
|
**vicious.contrib.pop**
|
||||||
|
|
||||||
|
**vicious.contrib.pulse**
|
||||||
|
|
||||||
|
Provides volume levels of requested pulseaudio sinks and functions to
|
||||||
|
manipulate them
|
||||||
|
|
||||||
|
- Arguments
|
||||||
|
* takes the name of a sink as an optional argument. a number will
|
||||||
|
be interpret as an index, if no argument is given, it will take
|
||||||
|
the first-best
|
||||||
|
* to get a list of available sinks use the command: pacmd
|
||||||
|
list-sinks | grep 'name:'
|
||||||
|
- Returns
|
||||||
|
* returns 1st value as the volume level
|
||||||
|
- vicious.contrib.pulse.add(percent, sink)
|
||||||
|
* @percent is a number, which increments or decrements the volume
|
||||||
|
level by its value in percent
|
||||||
|
* @sink optional, same usage as in vicious.contrib.pulse
|
||||||
|
* returns the exit status of pacmd
|
||||||
|
- vicious.contrib.pulse.toggle(sink)
|
||||||
|
* inverts the volume state (mute -> unmute; unmute -> mute)
|
||||||
|
* @sink optional, same usage as in vicious.contrib.pulse
|
||||||
|
* returns the exit status of pacmd
|
||||||
|
|
||||||
|
**vicious.contrib.rss**
|
||||||
|
|
||||||
|
**vicious.contrib.sensors**
|
||||||
|
|
||||||
|
**vicious.contrib.wpa**
|
||||||
|
|
||||||
|
Provides information about the wifi status
|
||||||
|
Supported Platforms: platform independent (`wpa_cli`)
|
||||||
|
|
||||||
|
- Arguments
|
||||||
|
- takes the interface as an argument, i.e "wlan0" or "wlan1"
|
||||||
|
- Returns
|
||||||
|
- a table with string keys: {ssid}, {qual}, {ip}, {bssid}
|
||||||
|
|
||||||
|
**vicious.contrib.buildbot**
|
||||||
|
|
||||||
|
Provides last build status for configured buildbot builders (http://trac.buildbot.net/)
|
||||||
|
Supported Platforms: platform independent
|
||||||
|
|
||||||
|
- Returns:
|
||||||
|
* returns build status in the format: [<builderName>.<currentBuildNumber>.<lastSuccessfulBuildNumber>]
|
||||||
|
* if <currentBuildNumber> is the same as <lastSuccessfulBuildNumber> only one number is displayed
|
||||||
|
* <buildNumber> colors: red - failed, green - successful, yellow - in progress
|
||||||
|
* it depends on lua json parser (e.g. liblua5.1-json on Ubuntu 12.04)
|
||||||
|
|
||||||
|
|
||||||
|
Usage examples
|
||||||
|
---------------------------------
|
||||||
|
Pulse Audio widget
|
||||||
|
vol = wibox.widget.textbox()
|
||||||
|
vicious.register(vol, vicious.contrib.pulse, " $1%", 2, "alsa_output.pci-0000_00_1b.0.analog-stereo")
|
||||||
|
vol:buttons(awful.util.table.join(
|
||||||
|
awful.button({ }, 1, function () awful.util.spawn("pavucontrol") end),
|
||||||
|
awful.button({ }, 4, function () vicious.contrib.pulse.add(5,"alsa_output.pci-0000_00_1b.0.analog-stereo") end),
|
||||||
|
awful.button({ }, 5, function () vicious.contrib.pulse.add(-5,"alsa_output.pci-0000_00_1b.0.analog-stereo") end)
|
||||||
|
))
|
||||||
|
|
||||||
|
Buildbot widget
|
||||||
|
buildbotwidget = wibox.widget.textbox()
|
||||||
|
local buildbotwidget_warg = {
|
||||||
|
{builder="coverage", url="http://buildbot.buildbot.net"},
|
||||||
|
{builder="tarball-slave", url="http://buildbot.buildbot.net"}
|
||||||
|
}
|
||||||
|
vicious.register(buildbotwidget, vicious.contrib.buildbot, "$1,", 3600, buildbotwidget_warg)
|
|
@ -14,7 +14,7 @@ local math = {
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
local ac = {}
|
local ac_linux = {}
|
||||||
|
|
||||||
-- {{{ AC widget type
|
-- {{{ AC widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
|
@ -32,4 +32,4 @@ end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
return setmetatable(_M, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(ac_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -17,8 +17,8 @@ local string = {
|
||||||
|
|
||||||
|
|
||||||
-- ATI: provides various info about ATI GPU status
|
-- ATI: provides various info about ATI GPU status
|
||||||
-- vicious.widgets.ati
|
-- vicious.contrib.ati
|
||||||
local ati = {}
|
local ati_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Define variables
|
-- {{{ Define variables
|
||||||
|
@ -76,4 +76,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(ati, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(ati_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -1,52 +0,0 @@
|
||||||
---------------------------------------------------
|
|
||||||
-- Licensed under the GNU General Public License v2
|
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
|
||||||
---------------------------------------------------
|
|
||||||
|
|
||||||
-- {{{ Grab environment
|
|
||||||
local tonumber = tonumber
|
|
||||||
local io = { popen = io.popen }
|
|
||||||
local setmetatable = setmetatable
|
|
||||||
local table = { insert = table.insert }
|
|
||||||
local string = { match = string.match }
|
|
||||||
-- }}}
|
|
||||||
|
|
||||||
|
|
||||||
-- Batacpi: provides state, charge, and remaining time for all batteries using acpitool
|
|
||||||
-- vicious.contrib.batacpi
|
|
||||||
local batacpi = {}
|
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Battery widget type
|
|
||||||
local function worker(format)
|
|
||||||
local battery_info = {}
|
|
||||||
local battery_state = {
|
|
||||||
["full"] = "↯",
|
|
||||||
["unknown"] = "⌁",
|
|
||||||
["charged"] = "↯",
|
|
||||||
["charging"] = "+",
|
|
||||||
["discharging"] = "-"
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Get data from acpitool
|
|
||||||
local f = io.popen("acpitool -b")
|
|
||||||
|
|
||||||
for line in f:lines() do
|
|
||||||
-- Check if the battery is present
|
|
||||||
if string.match(line, "^[%s]+Battery.*") then
|
|
||||||
-- Store state and charge information
|
|
||||||
table.insert(battery_info, (battery_state[string.match(line, "([%a]*),") or "unknown"]))
|
|
||||||
table.insert(battery_info, (tonumber(string.match(line, "([%d]?[%d]?[%d])%.")) or 0))
|
|
||||||
-- Store remaining time information
|
|
||||||
table.insert(battery_info, (string.match(line, "%%,%s(.*)") or "N/A"))
|
|
||||||
else
|
|
||||||
return {battery_state["unknown"], 0, "N/A"}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
f:close()
|
|
||||||
|
|
||||||
return battery_info
|
|
||||||
end
|
|
||||||
-- }}}
|
|
||||||
|
|
||||||
return setmetatable(batacpi, { __call = function(_, ...) return worker(...) end })
|
|
|
@ -21,7 +21,7 @@ local string = {
|
||||||
|
|
||||||
-- Batpmu: provides state, charge and remaining time for a requested battery using PMU
|
-- Batpmu: provides state, charge and remaining time for a requested battery using PMU
|
||||||
-- vicious.contrib.batpmu
|
-- vicious.contrib.batpmu
|
||||||
local batpmu = {}
|
local batpmu_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Battery widget type
|
-- {{{ Battery widget type
|
||||||
|
@ -76,4 +76,4 @@ local function worker(format, batid)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(batpmu, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(batpmu_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -21,7 +21,7 @@ local string = {
|
||||||
|
|
||||||
-- Batproc: provides state, charge, and remaining time for a requested battery using procfs
|
-- Batproc: provides state, charge, and remaining time for a requested battery using procfs
|
||||||
-- vicious.contrib.batproc
|
-- vicious.contrib.batproc
|
||||||
local batproc = {}
|
local batproc_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Battery widget type
|
-- {{{ Battery widget type
|
||||||
|
@ -83,4 +83,4 @@ local function worker(format, batid)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(batproc, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(batproc_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -17,10 +17,7 @@ local bb = {} --list of all buildbot builders
|
||||||
local bs = {OK=1, FAILED=2, RUNNING=3}
|
local bs = {OK=1, FAILED=2, RUNNING=3}
|
||||||
local bc = {"green", "red", "yellow"}
|
local bc = {"green", "red", "yellow"}
|
||||||
|
|
||||||
module("vicious.contrib.buildbot")
|
local buildbot_all = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BB = {}
|
BB = {}
|
||||||
BB.__index = BB
|
BB.__index = BB
|
||||||
|
@ -182,5 +179,5 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
setmetatable(_M, { __call = function(_, ...) return worker(...) end })
|
setmetatable(buildbot_all, { __call = function(_, ...) return worker(...) end })
|
||||||
|
|
|
@ -17,8 +17,9 @@ local pairs = pairs
|
||||||
-- Be carefull with directories, who contains a mass of files.
|
-- Be carefull with directories, who contains a mass of files.
|
||||||
-- "find" is usally fast, but will also produce delays, if the inodes get to big.
|
-- "find" is usally fast, but will also produce delays, if the inodes get to big.
|
||||||
-- So if you want to count your music library, you may want to use locate/updatedb instead.
|
-- So if you want to count your music library, you may want to use locate/updatedb instead.
|
||||||
module("vicious.contrib.countfiles")
|
|
||||||
|
|
||||||
|
-- vicious.contrib.countfiles
|
||||||
|
local countfiles_all = {}
|
||||||
|
|
||||||
-- {{{ Sum up widget type
|
-- {{{ Sum up widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
|
@ -47,4 +48,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
setmetatable(_M, { __call = function(_, ...) return worker(...) end })
|
setmetatable(countfiles_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -14,7 +14,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Disk I/O: provides I/O statistics for requested storage devices
|
-- Disk I/O: provides I/O statistics for requested storage devices
|
||||||
-- vicious.contrib.dio
|
-- vicious.contrib.dio
|
||||||
local dio = {}
|
local dio_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
|
@ -70,4 +70,4 @@ local function worker(format, disk)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(dio, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(dio_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -15,7 +15,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Mpc: provides the currently playing song in MPD
|
-- Mpc: provides the currently playing song in MPD
|
||||||
-- vicious.contrib.mpc
|
-- vicious.contrib.mpc
|
||||||
local mpc = {}
|
local mpc_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ MPC widget type
|
-- {{{ MPC widget type
|
||||||
|
@ -45,4 +45,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(mpc, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(mpc_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -18,7 +18,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Net: provides usage statistics for all network interfaces
|
-- Net: provides usage statistics for all network interfaces
|
||||||
-- vicious.contrib.net
|
-- vicious.contrib.net
|
||||||
local net = {}
|
local net_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- Initialise function tables
|
-- Initialise function tables
|
||||||
|
@ -136,4 +136,4 @@ local function worker(format, tignorelist)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(net, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(net_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -13,7 +13,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
|
|
||||||
-- vicious.widgets.nvinf
|
-- vicious.widgets.nvinf
|
||||||
local nvinf = {}
|
local nvinf_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ NVIDIA infomation widget type
|
-- {{{ NVIDIA infomation widget type
|
||||||
|
@ -32,4 +32,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(nvinf, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(nvinf_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -13,7 +13,7 @@ local string = { match = string.match }
|
||||||
|
|
||||||
-- nvsmi: provides GPU information from nvidia SMI
|
-- nvsmi: provides GPU information from nvidia SMI
|
||||||
-- vicious.contrib.nvsmi
|
-- vicious.contrib.nvsmi
|
||||||
local nvsmi = {}
|
local nvsmi_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ GPU Information widget type
|
-- {{{ GPU Information widget type
|
||||||
|
@ -39,4 +39,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(nvsmi, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(nvsmi_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -17,7 +17,7 @@ local math = {
|
||||||
|
|
||||||
-- Openweather: provides weather information for a requested station
|
-- Openweather: provides weather information for a requested station
|
||||||
-- vicious.widgets.openweather
|
-- vicious.widgets.openweather
|
||||||
local openweather = {}
|
local openweather_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
|
@ -91,4 +91,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(openweather, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(openweather_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -13,7 +13,7 @@ local string = { match = string.match }
|
||||||
|
|
||||||
-- Ossvol: provides volume levels of requested OSS mixers
|
-- Ossvol: provides volume levels of requested OSS mixers
|
||||||
-- vicious.contrib.ossvol
|
-- vicious.contrib.ossvol
|
||||||
local ossvol = {}
|
local ossvol_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Volume widget type
|
-- {{{ Volume widget type
|
||||||
|
@ -51,4 +51,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(ossvol, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(ossvol_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -20,7 +20,7 @@ end)
|
||||||
|
|
||||||
-- POP: provides the count of new messages in a POP3 mailbox
|
-- POP: provides the count of new messages in a POP3 mailbox
|
||||||
-- vicious.contrib.pop
|
-- vicious.contrib.pop
|
||||||
local pop = {}
|
local pop_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ POP3 count widget type
|
-- {{{ POP3 count widget type
|
||||||
|
@ -52,4 +52,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(pop, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(pop_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -26,7 +26,7 @@ local math = {
|
||||||
|
|
||||||
-- Pulse: provides volume levels of requested pulseaudio sinks and methods to change them
|
-- Pulse: provides volume levels of requested pulseaudio sinks and methods to change them
|
||||||
-- vicious.contrib.pulse
|
-- vicious.contrib.pulse
|
||||||
local pulse = {}
|
local pulse_all = {}
|
||||||
|
|
||||||
-- {{{ Helper function
|
-- {{{ Helper function
|
||||||
local function pacmd(args)
|
local function pacmd(args)
|
||||||
|
@ -87,7 +87,7 @@ end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Volume control helper
|
-- {{{ Volume control helper
|
||||||
function pulse.add(percent, sink)
|
function pulse_all.add(percent, sink)
|
||||||
sink = get_sink_name(sink)
|
sink = get_sink_name(sink)
|
||||||
if sink == nil then return end
|
if sink == nil then return end
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ function pulse.add(percent, sink)
|
||||||
return os.execute(cmd)
|
return os.execute(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
function pulse.toggle(sink)
|
function pulse_all.toggle(sink)
|
||||||
sink = get_sink_name(sink)
|
sink = get_sink_name(sink)
|
||||||
if sink == nil then return end
|
if sink == nil then return end
|
||||||
|
|
||||||
|
@ -121,4 +121,4 @@ function pulse.toggle(sink)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(pulse, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(pulse_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -15,7 +15,7 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- RSS: provides latest world news
|
-- RSS: provides latest world news
|
||||||
-- vicious.contrib.rss
|
-- vicious.contrib.rss
|
||||||
local rss = {}
|
local rss_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ RSS widget type
|
-- {{{ RSS widget type
|
||||||
|
@ -65,4 +65,4 @@ local function worker(format, input)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(rss, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(rss_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -17,7 +17,7 @@ local string = {
|
||||||
|
|
||||||
-- Sensors: provides access to lm_sensors data
|
-- Sensors: provides access to lm_sensors data
|
||||||
-- vicious.contrib.sensors
|
-- vicious.contrib.sensors
|
||||||
local sensors = {}
|
local sensors_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Split helper function
|
-- {{{ Split helper function
|
||||||
|
@ -66,4 +66,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(sensors, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(sensors_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -20,7 +20,7 @@ local string = {
|
||||||
|
|
||||||
|
|
||||||
-- Wifi: provides wireless information for a requested interface
|
-- Wifi: provides wireless information for a requested interface
|
||||||
local wpa = {}
|
local wpa_all = {}
|
||||||
|
|
||||||
local info = {
|
local info = {
|
||||||
["{ssid}"] = "N/A",
|
["{ssid}"] = "N/A",
|
||||||
|
@ -62,4 +62,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(_M, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(wpa_all, { __call = function(_, ...) return worker(...) end })
|
84
helpers.lua
84
helpers.lua
|
@ -12,13 +12,19 @@ local pairs = pairs
|
||||||
local rawget = rawget
|
local rawget = rawget
|
||||||
local require = require
|
local require = require
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local io = { open = io.open }
|
local io = {
|
||||||
|
open = io.open,
|
||||||
|
popen = io.popen
|
||||||
|
}
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local getmetatable = getmetatable
|
local getmetatable = getmetatable
|
||||||
local string = {
|
local string = {
|
||||||
upper = string.upper,
|
upper = string.upper,
|
||||||
|
lower = string.lower,
|
||||||
format = string.format
|
format = string.format
|
||||||
}
|
}
|
||||||
|
local pcall = pcall
|
||||||
|
local assert = assert
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,11 +38,45 @@ local scroller = {}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Helper functions
|
-- {{{ Helper functions
|
||||||
|
-- {{{ Determine operating system
|
||||||
|
function helpers.getos()
|
||||||
|
local f = io.popen("uname -s")
|
||||||
|
local uname = f:read("*line")
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
return string.lower(uname)
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Loader of vicious modules
|
-- {{{ Loader of vicious modules
|
||||||
function helpers.wrequire(table, key)
|
function helpers.wrequire(table, key)
|
||||||
local module = rawget(table, key)
|
local ret = rawget(table, key)
|
||||||
return module or require(table._NAME .. "." .. key)
|
|
||||||
|
if ret then
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
|
local ostable = {
|
||||||
|
linux = { "linux", "all" },
|
||||||
|
freebsd = { "freebsd", "bsd", "all" }
|
||||||
|
}
|
||||||
|
|
||||||
|
local os = ostable[helpers.getos()]
|
||||||
|
assert(os, "Vicious: platform not supported.")
|
||||||
|
|
||||||
|
for i = 1, #os do
|
||||||
|
local status, value = pcall(require, table._NAME .. "." .. key .. "_" .. os[i])
|
||||||
|
if status then
|
||||||
|
ret = value
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert(ret, "Vicious: widget " .. table._NAME .. "." .. key .. " not available for current platform.")
|
||||||
|
|
||||||
|
return ret
|
||||||
end
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Expose path as a Lua table
|
-- {{{ Expose path as a Lua table
|
||||||
function helpers.pathtotable(dir)
|
function helpers.pathtotable(dir)
|
||||||
|
@ -156,6 +196,44 @@ function helpers.scroll(text, maxlen, widget)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ Return result from one sysctl variable as string
|
||||||
|
function helpers.sysctl(path)
|
||||||
|
local fd = io.popen("sysctl -n " .. helpers.shellquote(path))
|
||||||
|
|
||||||
|
if not fd then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local ret = fd:read()
|
||||||
|
|
||||||
|
fd:close()
|
||||||
|
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ Return result from multiple sysctl variables as table
|
||||||
|
function helpers.sysctl_table(syspath)
|
||||||
|
return setmetatable({ _path = syspath },
|
||||||
|
{ __index = function(table, index)
|
||||||
|
local path = "sysctl -n " .. helpers.shellquote(table._path .. "." .. index)
|
||||||
|
local f = io.popen(path)
|
||||||
|
if f then
|
||||||
|
local s = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
if select(2, s:gsub("\n", "\n")) > 1 then
|
||||||
|
local o = { _path = path}
|
||||||
|
setmetatable(o, getmetatable(table))
|
||||||
|
return o
|
||||||
|
else
|
||||||
|
return s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
return helpers
|
return helpers
|
||||||
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local tonumber = tonumber
|
||||||
|
local io = { popen = io.popen }
|
||||||
|
local math = { floor = math.floor }
|
||||||
|
local helpers = require("vicious.helpers")
|
||||||
|
local string = {
|
||||||
|
gmatch = string.gmatch,
|
||||||
|
match = string.match,
|
||||||
|
format = string.format
|
||||||
|
|
||||||
|
}
|
||||||
|
-- }}}
|
||||||
|
local bat_freebsd = {}
|
||||||
|
|
||||||
|
local function worker(format, warg)
|
||||||
|
local battery = warg or "batt"
|
||||||
|
local bat_info = {}
|
||||||
|
local f = io.popen("acpiconf -i " .. helpers.shellquote(battery))
|
||||||
|
for line in f:lines("*line") do
|
||||||
|
for key,value in string.gmatch(line, "(.+):%s+(.+)") do
|
||||||
|
bat_info[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
-- current state
|
||||||
|
local state
|
||||||
|
if bat_info["State"] == "high" then
|
||||||
|
state = "↯"
|
||||||
|
elseif bat_info["State"] == "charging" then
|
||||||
|
state = "+"
|
||||||
|
elseif bat_info["State"] == "discharging" then
|
||||||
|
state = "-"
|
||||||
|
else
|
||||||
|
state = "⌁"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- battery capacity in percent
|
||||||
|
local percent = tonumber(string.match(bat_info["Remaining capacity"], "[%d]+"))
|
||||||
|
|
||||||
|
-- use remaining (charging or discharging) time calculated by acpiconf
|
||||||
|
local time = bat_info["Remaining time"]
|
||||||
|
if time == "unknown" then
|
||||||
|
time = "∞"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- calculate wear level from (last full / design) capacity
|
||||||
|
local wear = "N/A"
|
||||||
|
if bat_info["Last full capacity"] and bat_info["Design capacity"] then
|
||||||
|
local l_full = tonumber(string.match(bat_info["Last full capacity"], "[%d]+"))
|
||||||
|
local design = tonumber(string.match(bat_info["Design capacity"], "[%d]+"))
|
||||||
|
wear = math.floor(100 - (l_full / design * 100))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- dis-/charging rate as presented by battery
|
||||||
|
local rate = string.match(bat_info["Present rate"], "([%d]+)%smW")
|
||||||
|
rate = string.format("%2.1f", tonumber(rate / 1000))
|
||||||
|
|
||||||
|
-- returns
|
||||||
|
-- * state (high "↯", discharging "-", charging "+", N/A "⌁" }
|
||||||
|
-- * remaining_capacity (percent)
|
||||||
|
-- * remaining_time, by battery
|
||||||
|
-- * wear level (percent)
|
||||||
|
-- * present_rate (mW)
|
||||||
|
return {state, percent, time, wear, rate}
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(bat_freebsd, { __call = function(_, ...) return worker(...) end })
|
|
@ -18,7 +18,7 @@ local math = {
|
||||||
|
|
||||||
-- Bat: provides state, charge, remaining time, and wear for a requested battery
|
-- Bat: provides state, charge, remaining time, and wear for a requested battery
|
||||||
-- vicious.widgets.bat
|
-- vicious.widgets.bat
|
||||||
local bat = {}
|
local bat_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Battery widget type
|
-- {{{ Battery widget type
|
||||||
|
@ -91,4 +91,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(bat, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(bat_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -0,0 +1,69 @@
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local helpers = require("vicious.helpers")
|
||||||
|
local tonumber = tonumber
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local math = { floor = math.floor }
|
||||||
|
local string = { gmatch = string.gmatch }
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
-- Cpu: provides CPU usage for all available CPUs/cores
|
||||||
|
-- vicious.widgets.cpu_freebsd
|
||||||
|
local cpu_freebsd = {}
|
||||||
|
|
||||||
|
-- Initialize function tables
|
||||||
|
local cpu_total = {}
|
||||||
|
local cpu_idle = {}
|
||||||
|
|
||||||
|
-- {{{ CPU widget type
|
||||||
|
local function worker(format)
|
||||||
|
local cp_times = helpers.sysctl("kern.cp_times")
|
||||||
|
local matches = {}
|
||||||
|
local tmp_total = {}
|
||||||
|
local tmp_idle = {}
|
||||||
|
local tmp_usage = {}
|
||||||
|
|
||||||
|
-- Read input data
|
||||||
|
for v in string.gmatch(cp_times, "([%d]+)") do
|
||||||
|
table.insert(matches, v)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set first value of function tables
|
||||||
|
if #cpu_total == 0 then -- check for empty table
|
||||||
|
for i = 1, #matches / 5 + 1 do
|
||||||
|
cpu_total[i] = 0
|
||||||
|
cpu_idle[i] = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
for i = 1, #matches / 5 + 1 do
|
||||||
|
tmp_total[i] = 0
|
||||||
|
tmp_idle[i] = 0
|
||||||
|
tmp_usage[i] = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
-- CPU usage
|
||||||
|
for i, v in ipairs(matches) do
|
||||||
|
local index = math.floor((i-1) / 5) + 2 -- current cpu
|
||||||
|
|
||||||
|
tmp_total[1] = tmp_total[1] + v
|
||||||
|
tmp_total[index] = tmp_total[index] + v
|
||||||
|
|
||||||
|
if (i-1) % 5 == 4 then
|
||||||
|
tmp_idle[1] = tmp_idle[1] + v
|
||||||
|
tmp_idle[index] = tmp_idle[index] + v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, #tmp_usage do
|
||||||
|
tmp_usage[i] = tmp_total[i] - cpu_total[i]
|
||||||
|
tmp_usage[i] = math.floor((tmp_usage[i] - (tmp_idle[i] - cpu_idle[i])) / tmp_usage[i] * 100)
|
||||||
|
end
|
||||||
|
|
||||||
|
cpu_total = tmp_total
|
||||||
|
cpu_idle = tmp_idle
|
||||||
|
|
||||||
|
return tmp_usage
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
return setmetatable(cpu_freebsd, { __call = function(_, ...) return worker(...) end })
|
|
@ -20,7 +20,7 @@ local string = {
|
||||||
|
|
||||||
-- Cpu: provides CPU usage for all available CPUs/cores
|
-- Cpu: provides CPU usage for all available CPUs/cores
|
||||||
-- vicious.widgets.cpu
|
-- vicious.widgets.cpu
|
||||||
local cpu = {}
|
local cpu_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
|
@ -77,4 +77,4 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(cpu, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(cpu_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -0,0 +1,34 @@
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local tonumber = tonumber
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local helpers = require("vicious.helpers")
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
||||||
|
-- vicious.widgets.cpufreq
|
||||||
|
local cpufreq_freebsd = {}
|
||||||
|
|
||||||
|
|
||||||
|
-- {{{ CPU frequency widget type
|
||||||
|
local function worker(format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
|
||||||
|
-- Default frequency and voltage values
|
||||||
|
local freqv = {
|
||||||
|
["mhz"] = "N/A", ["ghz"] = "N/A",
|
||||||
|
["v"] = "N/A", ["mv"] = "N/A",
|
||||||
|
}
|
||||||
|
|
||||||
|
local freq = tonumber(helpers.sysctl("dev.cpu." .. warg .. ".freq"))
|
||||||
|
|
||||||
|
freqv.mhz = freq
|
||||||
|
freqv.ghz = freq / 1000
|
||||||
|
|
||||||
|
local governor = "N/A"
|
||||||
|
|
||||||
|
return {freqv.mhz, freqv.ghz, freqv.mv, freqv.v, governor}
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
return setmetatable(cpufreq_freebsd, { __call = function(_, ...) return worker(...) end })
|
|
@ -13,7 +13,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
||||||
-- vicious.widgets.cpufreq
|
-- vicious.widgets.cpufreq
|
||||||
local cpufreq = {}
|
local cpufreq_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ CPU frequency widget type
|
-- {{{ CPU frequency widget type
|
||||||
|
@ -58,4 +58,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(cpufreq, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(cpufreq_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -13,7 +13,7 @@ local string = { gmatch = string.gmatch }
|
||||||
|
|
||||||
-- Cpuinf: provides speed and cache information for all available CPUs/cores
|
-- Cpuinf: provides speed and cache information for all available CPUs/cores
|
||||||
-- vicious.widgets.cpuinf
|
-- vicious.widgets.cpuinf
|
||||||
local cpuinf = {}
|
local cpuinf_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ CPU Information widget type
|
-- {{{ CPU Information widget type
|
||||||
|
@ -41,4 +41,4 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(cpuinf, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(cpuinf_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -15,7 +15,7 @@ local os = {
|
||||||
|
|
||||||
-- Date: provides access to os.date with optional time formatting
|
-- Date: provides access to os.date with optional time formatting
|
||||||
-- vicious.widgets.date
|
-- vicious.widgets.date
|
||||||
local date = {}
|
local date_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Date widget type
|
-- {{{ Date widget type
|
||||||
|
@ -24,4 +24,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(date, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(date_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -18,7 +18,7 @@ local os = {
|
||||||
|
|
||||||
-- Disk I/O: provides I/O statistics for requested storage devices
|
-- Disk I/O: provides I/O statistics for requested storage devices
|
||||||
-- vicious.widgets.dio
|
-- vicious.widgets.dio
|
||||||
local dio = {}
|
local dio_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
|
@ -70,4 +70,4 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(dio, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(dio_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -0,0 +1,28 @@
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local helpers = require("vicious.helpers")
|
||||||
|
local tonumber = tonumber
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
-- fanspeed: provides speed level of main fan
|
||||||
|
--
|
||||||
|
-- expects one (1) full sysctl string to entry
|
||||||
|
-- e.g.: "dev.acpi_ibm.0.fan_speed"
|
||||||
|
|
||||||
|
local fanspeed_freebsd = {}
|
||||||
|
|
||||||
|
local function worker(format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
|
||||||
|
local fanspeed = helpers.sysctl(warg)
|
||||||
|
|
||||||
|
if not fanspeed then
|
||||||
|
-- use negative fanspeed to indicate error
|
||||||
|
return {-1}
|
||||||
|
else
|
||||||
|
return {tonumber(fanspeed)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(fanspeed_freebsd, { __call = function(_, ...) return worker(...) end })
|
|
@ -15,7 +15,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- FS: provides file system disk space usage
|
-- FS: provides file system disk space usage
|
||||||
-- vicious.widgets.fs
|
-- vicious.widgets.fs
|
||||||
local fs = {}
|
local fs_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- Variable definitions
|
-- Variable definitions
|
||||||
|
@ -49,4 +49,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(fs_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -17,7 +17,7 @@ local string = {
|
||||||
|
|
||||||
-- Gmail: provides count of new and subject of last e-mail on Gmail
|
-- Gmail: provides count of new and subject of last e-mail on Gmail
|
||||||
-- vicious.widgets.gmail
|
-- vicious.widgets.gmail
|
||||||
local gmail = {}
|
local gmail_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Variable definitions
|
-- {{{ Variable definitions
|
||||||
|
@ -74,4 +74,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(gmail, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(gmail_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -14,7 +14,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
|
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
|
||||||
-- vicious.widgets.hddtemp
|
-- vicious.widgets.hddtemp
|
||||||
local hddtemp = {}
|
local hddtemp_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ HDD Temperature widget type
|
-- {{{ HDD Temperature widget type
|
||||||
|
@ -37,4 +37,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(hddtemp, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(hddtemp_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -14,7 +14,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Mbox: provides the subject of last e-mail in a mbox file
|
-- Mbox: provides the subject of last e-mail in a mbox file
|
||||||
-- vicious.widgets.mbox
|
-- vicious.widgets.mbox
|
||||||
local mbox = {}
|
local mbox_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- Initialize variables
|
-- Initialize variables
|
||||||
|
@ -50,4 +50,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(mbox, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(mbox_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -12,7 +12,7 @@ local string = { find = string.find }
|
||||||
|
|
||||||
-- Mboxc: provides the count of total, old and new messages in mbox files
|
-- Mboxc: provides the count of total, old and new messages in mbox files
|
||||||
-- vicious.widgets.mboxc
|
-- vicious.widgets.mboxc
|
||||||
local mboxc = {}
|
local mboxc_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Mbox count widget type
|
-- {{{ Mbox count widget type
|
||||||
|
@ -55,4 +55,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(mboxc, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(mboxc_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -13,7 +13,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Mdir: provides the number of new and unread messages in Maildir structures/dirs
|
-- Mdir: provides the number of new and unread messages in Maildir structures/dirs
|
||||||
-- vicious.widgets.mdir
|
-- vicious.widgets.mdir
|
||||||
local mdir = {}
|
local mdir_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Maildir widget type
|
-- {{{ Maildir widget type
|
||||||
|
@ -40,4 +40,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(mdir, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(mdir_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -0,0 +1,70 @@
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local tonumber = tonumber
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local math = { floor = math.floor }
|
||||||
|
local helpers = require("vicious.helpers")
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
-- Mem: provides RAM and Swap usage statistics
|
||||||
|
-- vicious.widgets.mem_freebsd
|
||||||
|
local mem_freebsd = {}
|
||||||
|
|
||||||
|
|
||||||
|
-- {{{ Memory widget type
|
||||||
|
local function worker(format)
|
||||||
|
local pagesize = tonumber(helpers.sysctl("hw.pagesize"))
|
||||||
|
local vm_stats = helpers.sysctl_table("vm.stats.vm")
|
||||||
|
local _mem = { buf = {}, total = nil }
|
||||||
|
|
||||||
|
_mem.total = tonumber(vm_stats.v_page_count) * pagesize
|
||||||
|
_mem.buf.f = tonumber(vm_stats.v_free_count) * pagesize
|
||||||
|
_mem.buf.a = tonumber(vm_stats.v_active_count) * pagesize
|
||||||
|
_mem.buf.i = tonumber(vm_stats.v_inactive_count) * pagesize
|
||||||
|
_mem.buf.c = tonumber(vm_stats.v_cache_count) * pagesize
|
||||||
|
_mem.buf.w = tonumber(vm_stats.v_wire_count) * pagesize
|
||||||
|
|
||||||
|
-- rework into Megabytes
|
||||||
|
_mem.total = math.floor(_mem.total/(1024*1024))
|
||||||
|
_mem.buf.f = math.floor(_mem.buf.f/(1024*1024))
|
||||||
|
_mem.buf.a = math.floor(_mem.buf.a/(1024*1024))
|
||||||
|
_mem.buf.i = math.floor(_mem.buf.i/(1024*1024))
|
||||||
|
_mem.buf.c = math.floor(_mem.buf.c/(1024*1024))
|
||||||
|
_mem.buf.w = math.floor(_mem.buf.w/(1024*1024))
|
||||||
|
|
||||||
|
-- Calculate memory percentage
|
||||||
|
_mem.free = _mem.buf.f + _mem.buf.c
|
||||||
|
_mem.inuse = _mem.buf.a + _mem.buf.i
|
||||||
|
_mem.wire = _mem.buf.w
|
||||||
|
_mem.bcuse = _mem.total - _mem.buf.f
|
||||||
|
_mem.usep = math.floor(_mem.inuse / _mem.total * 100)
|
||||||
|
_mem.inusep= math.floor(_mem.inuse / _mem.total * 100)
|
||||||
|
_mem.buffp = math.floor(_mem.bcuse / _mem.total * 100)
|
||||||
|
_mem.wirep = math.floor(_mem.wire / _mem.total * 100)
|
||||||
|
|
||||||
|
-- Get swap states
|
||||||
|
local vm = helpers.sysctl_table("vm")
|
||||||
|
local _swp = { buf = {}, total = nil }
|
||||||
|
|
||||||
|
if tonumber(vm.swap_enabled) == 1 and tonumber(vm.swap_total) > 0 then
|
||||||
|
-- Get swap space
|
||||||
|
_swp.total = tonumber(vm.swap_total)
|
||||||
|
_swp.buf.f = _swp.total - tonumber(vm_stats.v_swapin)
|
||||||
|
-- Rework into megabytes
|
||||||
|
_swp.total = math.floor(_swp.total/(1024*1024))
|
||||||
|
_swp.buf.f = math.floor(_swp.buf.f/(1024*1024))
|
||||||
|
-- Calculate percentage
|
||||||
|
_swp.inuse = _swp.total - _swp.buf.f
|
||||||
|
_swp.usep = math.floor(_swp.inuse / _swp.total * 100)
|
||||||
|
else
|
||||||
|
_swp.usep = -1
|
||||||
|
_swp.inuse = -1
|
||||||
|
_swp.total = -1
|
||||||
|
_swp.buf.f = -1
|
||||||
|
end
|
||||||
|
|
||||||
|
return { _mem.usep, _mem.inuse, _mem.total, _mem.free,
|
||||||
|
_swp.usep, _swp.inuse, _swp.total, _swp.buf.f,
|
||||||
|
_mem.bcuse, _mem.buffp, _mem.wirep }
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(mem_freebsd, { __call = function(_, ...) return worker(...) end })
|
|
@ -14,7 +14,7 @@ local string = { gmatch = string.gmatch }
|
||||||
|
|
||||||
-- Mem: provides RAM and Swap usage statistics
|
-- Mem: provides RAM and Swap usage statistics
|
||||||
-- vicious.widgets.mem
|
-- vicious.widgets.mem
|
||||||
local mem = {}
|
local mem_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Memory widget type
|
-- {{{ Memory widget type
|
||||||
|
@ -49,4 +49,4 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(mem, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(mem_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -14,7 +14,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Mpd: provides Music Player Daemon information
|
-- Mpd: provides Music Player Daemon information
|
||||||
-- vicious.widgets.mpd
|
-- vicious.widgets.mpd
|
||||||
local mpd = {}
|
local mpd_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ MPD widget type
|
-- {{{ MPD widget type
|
||||||
|
@ -61,4 +61,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(mpd, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(mpd_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -0,0 +1,83 @@
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local tonumber = tonumber
|
||||||
|
local os = { time = os.time }
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local helpers = require("vicious.helpers")
|
||||||
|
local io = { popen = io.popen }
|
||||||
|
local string = { match = string.match }
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
-- Net: provides state and usage statistics of all network interfaces
|
||||||
|
-- vicious.widgets.net
|
||||||
|
local net_freebsd = {}
|
||||||
|
|
||||||
|
|
||||||
|
-- Initialize function tables
|
||||||
|
local nets = {}
|
||||||
|
-- Variable definitions
|
||||||
|
local unit = { ["b"] = 1, ["kb"] = 1024,
|
||||||
|
["mb"] = 1024^2, ["gb"] = 1024^3
|
||||||
|
}
|
||||||
|
|
||||||
|
-- {{{ Net widget type
|
||||||
|
local function worker(format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
|
||||||
|
local args = {}
|
||||||
|
local buffer = nil
|
||||||
|
local f = io.popen("netstat -n -b -I " .. helpers.shellquote(warg))
|
||||||
|
local now = os.time()
|
||||||
|
|
||||||
|
for line in f:lines() do
|
||||||
|
if not (line:find("<Link") or line:find("Name")) then -- skipping missleading lines
|
||||||
|
local split = { line:match(("([^%s]*)%s*"):rep(12)) }
|
||||||
|
|
||||||
|
if buffer == nil then
|
||||||
|
buffer = { tonumber(split[8]), tonumber(split[11]) } -- recv (field 8) and send (field 11)
|
||||||
|
else
|
||||||
|
buffer = { buffer[1] + tonumber(split[8]), buffer[2] + tonumber(split[11]) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
if buffer == nil then
|
||||||
|
args["{carrier}"] = 0
|
||||||
|
helpers.uformat(args, "rx", 0, unit)
|
||||||
|
helpers.uformat(args, "tx", 0, unit)
|
||||||
|
helpers.uformat(args, "down", 0, unit)
|
||||||
|
helpers.uformat(args, "up", 0, unit)
|
||||||
|
else
|
||||||
|
args["{carrier}"] = 1
|
||||||
|
helpers.uformat(args, "rx", buffer[1], unit)
|
||||||
|
helpers.uformat(args, "tx", buffer[2], unit)
|
||||||
|
|
||||||
|
if next(nets) == nil then
|
||||||
|
helpers.uformat(args, "down", 0, unit)
|
||||||
|
helpers.uformat(args, "up", 0, unit)
|
||||||
|
else
|
||||||
|
local interval = now - nets["time"]
|
||||||
|
if interval <= 0 then interval = 1 end
|
||||||
|
|
||||||
|
local down = (buffer[1] - nets[1]) / interval
|
||||||
|
local up = (buffer[2] - nets[2]) / interval
|
||||||
|
|
||||||
|
helpers.uformat(args, "down", down, unit)
|
||||||
|
helpers.uformat(args, "up", up, unit)
|
||||||
|
end
|
||||||
|
|
||||||
|
nets["time"] = now
|
||||||
|
|
||||||
|
-- Store totals
|
||||||
|
nets[1] = buffer[1]
|
||||||
|
nets[2] = buffer[2]
|
||||||
|
end
|
||||||
|
|
||||||
|
return args
|
||||||
|
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
return setmetatable(net_freebsd, { __call = function(_, ...) return worker(...) end })
|
|
@ -16,7 +16,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Net: provides state and usage statistics of all network interfaces
|
-- Net: provides state and usage statistics of all network interfaces
|
||||||
-- vicious.widgets.net
|
-- vicious.widgets.net
|
||||||
local net = {}
|
local net_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
|
@ -77,4 +77,4 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(net, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(net_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -17,7 +17,7 @@ local os = {
|
||||||
|
|
||||||
-- Org: provides agenda statistics for Emacs org-mode
|
-- Org: provides agenda statistics for Emacs org-mode
|
||||||
-- vicious.widgets.org
|
-- vicious.widgets.org
|
||||||
local org = {}
|
local org_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ OrgMode widget type
|
-- {{{ OrgMode widget type
|
||||||
|
@ -59,4 +59,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(org, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(org_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -20,7 +20,7 @@ local string = {
|
||||||
|
|
||||||
-- OS: provides operating system information
|
-- OS: provides operating system information
|
||||||
-- vicious.widgets.os
|
-- vicious.widgets.os
|
||||||
local os = {}
|
local os_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Operating system widget type
|
-- {{{ Operating system widget type
|
||||||
|
@ -70,4 +70,4 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(os, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(os_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -12,7 +12,7 @@ local setmetatable = setmetatable
|
||||||
|
|
||||||
-- Pkg: provides number of pending updates on UNIX systems
|
-- Pkg: provides number of pending updates on UNIX systems
|
||||||
-- vicious.widgets.pkg
|
-- vicious.widgets.pkg
|
||||||
local pkg = {}
|
local pkg_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Packages widget type
|
-- {{{ Packages widget type
|
||||||
|
@ -28,7 +28,7 @@ local function worker(format, warg)
|
||||||
["Debian"] = { cmd = "apt-show-versions -u -b" },
|
["Debian"] = { cmd = "apt-show-versions -u -b" },
|
||||||
["Ubuntu"] = { cmd = "aptitude search '~U'" },
|
["Ubuntu"] = { cmd = "aptitude search '~U'" },
|
||||||
["Fedora"] = { cmd = "yum list updates", sub = 3 },
|
["Fedora"] = { cmd = "yum list updates", sub = 3 },
|
||||||
["FreeBSD"] ={ cmd = "pkg_version -I -l '<'" },
|
["FreeBSD"] ={ cmd = "pkg version -I -l '<'" },
|
||||||
["Mandriva"]={ cmd = "urpmq --auto-select" }
|
["Mandriva"]={ cmd = "urpmq --auto-select" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,4 +45,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(pkg, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(pkg_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -17,7 +17,7 @@ local string = {
|
||||||
|
|
||||||
-- Raid: provides state information for a requested RAID array
|
-- Raid: provides state information for a requested RAID array
|
||||||
-- vicious.widgets.raid
|
-- vicious.widgets.raid
|
||||||
local raid = {}
|
local raid_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
|
@ -57,4 +57,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(raid, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(raid_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -0,0 +1,34 @@
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local string = { match = string.match }
|
||||||
|
local helpers = require("vicious.helpers")
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
-- Thermal: provides temperature levels of ACPI and coretemp thermal zones
|
||||||
|
-- vicious.widgets.thermal
|
||||||
|
local thermal_freebsd = {}
|
||||||
|
|
||||||
|
|
||||||
|
-- {{{ Thermal widget type
|
||||||
|
local function worker(format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
if type(warg) ~= "table" then warg = { warg } end
|
||||||
|
|
||||||
|
local thermals = {}
|
||||||
|
|
||||||
|
for i=1, #warg do
|
||||||
|
local output = helpers.sysctl(warg[i])
|
||||||
|
|
||||||
|
if not output then
|
||||||
|
thermals[i] = -1
|
||||||
|
else
|
||||||
|
thermals[i] = string.match(output, "[%d]+")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return thermals
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
return setmetatable(thermal_freebsd, { __call = function(_, ...) return worker(...) end })
|
|
@ -15,7 +15,7 @@ local math = { floor = math.floor }
|
||||||
|
|
||||||
-- Thermal: provides temperature levels of ACPI and coretemp thermal zones
|
-- Thermal: provides temperature levels of ACPI and coretemp thermal zones
|
||||||
-- vicious.widgets.thermal
|
-- vicious.widgets.thermal
|
||||||
local thermal = {}
|
local thermal_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Thermal widget type
|
-- {{{ Thermal widget type
|
||||||
|
@ -46,4 +46,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(thermal, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(thermal_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -0,0 +1,30 @@
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local tonumber = tonumber
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local math = { floor = math.floor }
|
||||||
|
local string = { match = string.match }
|
||||||
|
local helpers = require("vicious.helpers")
|
||||||
|
local os = { time = os.time }
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
-- Uptime: provides system uptime and load information
|
||||||
|
-- vicious.widgets.uptime
|
||||||
|
local uptime_freebsd = {}
|
||||||
|
|
||||||
|
|
||||||
|
-- {{{ Uptime widget type
|
||||||
|
local function worker(format)
|
||||||
|
local l1, l5, l15 = string.match(helpers.sysctl("vm.loadavg"), "{ ([%d]+%.[%d]+) ([%d]+%.[%d]+) ([%d]+%.[%d]+) }")
|
||||||
|
local up_t = os.time() - tonumber(string.match(helpers.sysctl("kern.boottime"), "sec = ([%d]+)"))
|
||||||
|
|
||||||
|
-- Get system uptime
|
||||||
|
local up_d = math.floor(up_t / (3600 * 24))
|
||||||
|
local up_h = math.floor((up_t % (3600 * 24)) / 3600)
|
||||||
|
local up_m = math.floor(((up_t % (3600 * 24)) % 3600) / 60)
|
||||||
|
|
||||||
|
return {up_d, up_h, up_m, l1, l5, l15}
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
return setmetatable(uptime_freebsd, { __call = function(_, ...) return worker(...) end })
|
|
@ -14,7 +14,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Uptime: provides system uptime and load information
|
-- Uptime: provides system uptime and load information
|
||||||
-- vicious.widgets.uptime
|
-- vicious.widgets.uptime
|
||||||
local uptime = {}
|
local uptime_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Uptime widget type
|
-- {{{ Uptime widget type
|
||||||
|
@ -33,4 +33,4 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(uptime, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(uptime_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -0,0 +1,38 @@
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local tonumber = tonumber
|
||||||
|
local io = { popen = io.popen }
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local string = { match = string.match }
|
||||||
|
local helpers = require("vicious.helpers")
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
-- Volume: provides volume levels and state of requested mixer
|
||||||
|
-- vicious.widgets.volume_freebsd
|
||||||
|
local volume_freebsd = {}
|
||||||
|
|
||||||
|
|
||||||
|
-- {{{ Volume widget type
|
||||||
|
local function worker(format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
|
||||||
|
local mixer_state = { "♫", "♩" }
|
||||||
|
|
||||||
|
-- Get mixer control contents
|
||||||
|
f = io.popen("mixer -s " .. helpers.shellquote(warg))
|
||||||
|
local mixer = f:read()
|
||||||
|
f:close()
|
||||||
|
|
||||||
|
-- Capture mixer control state: [5%] ... ... [on]
|
||||||
|
local voll, volr = string.match(mixer, "([%d]+):([%d]+)$")
|
||||||
|
|
||||||
|
if voll == "0" and volr == "0" then
|
||||||
|
return {0, 0, mixer_state[2]}
|
||||||
|
else
|
||||||
|
return {voll, volr, mixer_state[1]}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
return setmetatable(volume_freebsd, { __call = function(_, ...) return worker(...) end })
|
|
@ -14,7 +14,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Volume: provides volume levels and state of requested ALSA mixers
|
-- Volume: provides volume levels and state of requested ALSA mixers
|
||||||
-- vicious.widgets.volume
|
-- vicious.widgets.volume
|
||||||
local volume = {}
|
local volume_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Volume widget type
|
-- {{{ Volume widget type
|
||||||
|
@ -51,4 +51,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(volume, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(volume_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -15,7 +15,7 @@ local helpers = require("vicious.helpers")
|
||||||
|
|
||||||
-- Weather: provides weather information for a requested station
|
-- Weather: provides weather information for a requested station
|
||||||
-- vicious.widgets.weather
|
-- vicious.widgets.weather
|
||||||
local weather = {}
|
local weather_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
|
@ -91,4 +91,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(weather, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(weather_all, { __call = function(_, ...) return worker(...) end })
|
|
@ -21,7 +21,7 @@ local string = {
|
||||||
|
|
||||||
-- Wifi: provides wireless information for a requested interface
|
-- Wifi: provides wireless information for a requested interface
|
||||||
-- vicious.widgets.wifi
|
-- vicious.widgets.wifi
|
||||||
local wifi = {}
|
local wifi_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Variable definitions
|
-- {{{ Variable definitions
|
||||||
|
@ -89,4 +89,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(wifi, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(wifi_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -20,7 +20,7 @@ local string = {
|
||||||
|
|
||||||
-- Wifiiw: provides wireless information for a requested interface using iw instead of deprecated iwconfig
|
-- Wifiiw: provides wireless information for a requested interface using iw instead of deprecated iwconfig
|
||||||
-- vicious.widgets.wifiiw
|
-- vicious.widgets.wifiiw
|
||||||
local wifiiw = {}
|
local wifiiw_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Wireless widget type
|
-- {{{ Wireless widget type
|
||||||
|
@ -63,4 +63,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(wifiiw, { __call = function(_, ...) return worker(...) end })
|
return setmetatable(wifiiw_linux, { __call = function(_, ...) return worker(...) end })
|
Loading…
Reference in New Issue