Merge pull request #94 from vicious-widgets/copyright

Add copyright notices and contributing guidelines
This commit is contained in:
Nguyễn Gia Phong 2019-10-24 21:08:54 +07:00 committed by GitHub
commit eca31413bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 1961 additions and 556 deletions

View File

@ -6,6 +6,12 @@ read_globals = {
"timer", -- deprecated, but used in older versions.
}
include_files = {
"*.lua", -- libraries
"widgets/*.lua", -- officially supported widget types
"templates/*.lua", -- officially supported widget types
}
-- Warnings to be ignored
ignore = {
"212", -- Unused argument.

318
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,318 @@
# How to contribute to Vicious
## Filing an Issue
* Ensure the bug was not already reported by searching GitHub Issues.
* If you're unable to find an open issue addressing the problem,
open a new one. Be sure to include a title and clear description,
as much relevant information as possible, such as Awesome errors,
and a config sample or an executable test case
(using Vicious as a stand-alone library)
demonstrating the expected behavior that is not occurring.
Please re-read your issue once again to avoid a couple of common mistakes
(you can and should use this as a checklist):
* Is the description of the issue itself sufficient?
Make sure that it's obvious
- What the problem is
- How it could be fixed
- How your proposed solution would look like
* Have you provide the versions of Vicious and related software?
We would like to how you installed Vicious, which OS you're using,
the version of the software or what kind of hardware you are trying
to get information from.
* Is the issue already documented?
* Does the issue involve one problem, and one problem only?
Some people seem to think there is a limit of issues they can or should open.
There is no limit of issues they can or should open.
While it may seem appealing to be able to dump all your issues
into one ticket, that means that someone who solves one of your issues
cannot mark the issue as closed.
* Is anyone going to need the feature? Only post features that you
(or an incapacitated friend you can personally talk to) require.
Do not post features because they seem like a good idea.
If they're really useful, they'll be requested by someone who requires them.
## Requesting for Merging a Patch
1. [Fork this repository](https://github.com/vicious-widgets/vicious/fork)
2. Check out the source code with:
git clone git@github.com:YOUR_GITHUB_USERNAME/vicious.git
cd vicious
3. Start working on your patch. If you want to add a new widget type,
see the `templates` directory for a more detailed guide.
4. Have a look at `helpers.lua` and `spawn.lua` for possible helper functions.
5. Make sure your code follows the coding conventions below and check the code
with `luacheck`. This *should fail* at first, but you can continually
re-run it until you're done.
luacheck --config .luacheckrc .
6. Make sure your code works under all Lua versions claimed supported
by Vicious, namely 5.1, 5.2 and 5.3.
7. Update the copyright notices of the files you modified. Vicious is
collectively licensed under GPLv2+, and to protect the freedom of the users,
copyright holders need to be properly documented.
8. Try to note your changes under `Changes.md`. If you find it is
difficult to phrase the changes, you can leave it for us.
9. [Add](https://git-scm.com/docs/git-add) the changes,
[commit](https://git-scm.com/docs/git-commit) them
and [push](https://git-scm.com/docs/git-push) the result, like this:
git add widgets/bar_baz.lua README.md
git commit -m '[bar_baz] Add widget type'
git add helpers.lua Changes.md
git commit -m '[helpers] Fix foo'
git push
10. Finally, [create a pull request](https://help.github.com/articles/creating-a-pull-request).
We'll then review and merge it.
In any case, thank you very much for your contributions!
## Coding Conventions
This section introduces a guideline for writing idiomatic, robust
and future-proof widget type code.
### Whitespace in Expressions and Statements
Avoid extraneous whitespace in the following situations:
* Immediately inside parentheses or brackets. Braces, however, are exceptions
to this rule:
```lua
foo(bar[1], { baz = 2 }) -- yes
foo( bar[ 1 ], {baz = 2} ) -- no
```
* Immediately before a comma, semicolon, or colon.
* Immediately before the open parenthesis, braces, quote, etc.
that starts the argument list of a function call; or the open bracket
that starts an indexing. In other words, prefer these:
```lua
foo(bar, baz)
foo{ bar, baz }
foo"bar"
foo[[bar]]
foo[bar]
```
* Trailing at the end of line or (newline) at the end of file.
Always surround these binary operators with a single space on either side:
assignment (`=`), comparisons, Booleans (`and`, `or`, `not`).
If operators with different priorities are used, consider adding whitespace
around the operators with the lowest priorities. Use your own judgment;
however, never use more than one space, and always have
the same amount of whitespace on both sides of a binary operator.
### Indentation
Use 4 *spaces* per indentation level.
Continuation lines should align wrapped elements either vertically
inside parentheses, brackets and braces, or using a hanging indent
(the opening parenthesis of a parenthesized statement is the last
non-whitespace character of the line, with subsequent lines being indented
until the closing parenthesis), e.g.
```lua
-- Vertically aligned
long_function_call{ foo, bar,
baz }
-- Hanging indentation
long_function_call(
foo, bar
baz)
```
The closing brace or bracket on multi-line constructs may either line up under
the first character of the line that starts the construct, as in:
```lua
long_function_call{
foo = 1, bar = 2,
baz = 3,
}
```
In this case, and this case only, the trailing comma is acceptable
to avoid diff noises when more values are added,
but since Vicious often deal with system APIs which rarely ever change,
it's occasionally helpful to do so.
Trailing right parentheses, however, are not allowed.
### Maximum Line Length
If possible, try to limit all *code* lines to a maximum
of 80 characters. In case you find some lines in your patch would be
more readable exceeding this limit, feel free to discuss with us.
Comments and long strings need not to follow this restriction however.
As one might have noticed, the syntactic sugars `f{<fields>}`
(for `f({<fields>})`) and `f'<string>'` (or `f"<string>"`/`f[[<string>]]`,
for `f('<string>')`) are especially preferred to squeeze
the line length to this limit.
### Blank Lines
Surround function definitions with a single blank line. Extra blank lines
may be used (sparingly) to separate groups of related functions.
Blank lines may be omitted between a bunch of related one-liners
(e.g. a set of dummy implementations).
Use blank lines in functions, sparingly, to indicate logical sections.
### Requiring Libraries
All standard libraries should be localized before used
for the matter of performance.
`require`s should always be put at the top of the source file,
just after the copyright header, and before module globals and constants,
and grouped in the following order:
1. Standard libraries
2. Related third-party libraries
3. Local libraries
For example,
```lua
local type = type
local table = { concat = table.concat, insert = table.insert }
local awful = require("awful")
local helpers = require("vicious.helpers")
```
### String Quotes
In Lua, single-quoted strings and double-quoted strings are the same,
so the choice is totally up to you, but please be consistent within a module.
When a string contains single or double quote characters, however,
use the other one to avoid backslashes in the string. It improves readability:
```lua
'"key": "value"' -- good
"\"key\": \"value\"" -- no good
```
It is preferable to add a newline immediately after the opening long bracket:
```lua
foo = [[
this is a really,
really,
really long text]]
```
### Naming Conventions
Avoid using the characters `l` (lowercase letter el), `O` (uppercase letter oh),
or `I` (uppercase letter eye) as single character variable names.
In some fonts, these characters are indistinguishable from the 1's and 0's.
#### Constants
Constants are usually defined on a module level
and written in all capital letters with underscores separating words.
Examples include `MAX_OVERFLOW` and `TOTAL`.
#### Function and Variable Names
Function names should be lowercase, with words separated by underscores
as necessary to improve readability.
Variable names follow the same convention as function names.
When you find it difficult to give descriptive names,
use the functions and variable anonymously.
### Performance Tips
Vicious is meant to be run as part of the Awesome window manager,
thus any little overhead may defect the responsiveness of the UI.
While Lua is famous for its performance, there are a few things
one can do to make use of all of its power.
**Never** use global variables. This includes the standard libraries,
which, again, must be localized before use. Remember, every widget type
is to be called repeatedly every few seconds.
Use closures when possible:
* Define constants on the module level.
* Avoid re-fetching the values that are not not meant to change.
However, declare a variable only when you need it, to avoid declaring it
without an initial value (and therefore you seldom forget to initialize it).
Moreover, you shorten the scope of the variable, which increases readability.
### Copyright Header
Vicious is released under the GNU GNU General Public License
version 2 or later and each contributor holds the copyright
on their contributions. To make this collective control effective,
each source file must include a notice of the following format
denoting the name of all authors
```lua
-- <one line to give the program's name and a brief idea of what it does.>
-- Copyright (C) <year> <name of author> <<email that can be use for contact>>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
```
### Comments
Comments that contradict the code are worse than no comments.
Always make a priority of keeping the comments up-to-date when the code changes!
You should use two spaces after a sentence-ending period
in multi-sentence comments, except after the final sentence.
#### Block Comments
Block comments generally apply to some (or all) code that follows them,
and are indented to the same level as that code. Each line of a block comment
starts with `--` and a single space, unless text inside the comment is indented,
or it is to comment out code.
Paragraphs inside a block comment are separated by a line containing `--` only.
The best example is the copyright notice in the section above.
The `--[[...]]` style may only be used for commenting out source code.
#### Inline Comments
An inline comment is a comment on the same line as a statement.
Inline comments should be separated by at least two spaces from the statement.
They should start with `-- `.
## Influences
These contributing guideline are heavily influenced by that of `youtube-dl`,
PEP 8, Programming in Lua and the performance tips in Lua Programming Gems.

View File

@ -1,4 +1,4 @@
# Changes in 2.4.0 (WIP)
# Changes in 2.4.0
IMPORTANT:
@ -16,6 +16,11 @@ Added:
- `helpers.setasyncall` to avoid writing redundant workers for asynchronous
widget types. Note that these workers are only needed in case Vicious is used
as a stand-alone library.
- `helpers.setcall` for registering functions as widget types.
- `headergen` script for automatic generation of copyright notices.
- `templates` for the ease of adding new widget types.
- `CONTRIBUTING.md` which guide contributors through the steps
of filing an issue or submitting a patch.
Fixed:
@ -26,10 +31,12 @@ Fixed:
* bat_openbsd
* volume, gmail, mdir, mpd, fs
- [mpd] Lua 5.3 compatibility (for real this time); also correct a typo
- [mbox] Update the deprecated `string.gfind` to `string.gmatch`
- [pkg,weather,contrib/btc] Allow function call without Awesome
- [pkg] Use more updated front-ends for Debian/Ubuntu (apt) and Fedora (dnf)
- [os] Splitted os_all into os_linux and os_bsd (and refactored to async)
- Tweak `.luacheckrc` to suit functional style and soft-limit text width to 80
- Update copyright headers for libraries and widget types
Removed:

111
README.md
View File

@ -3,9 +3,7 @@
Vicious is a modular widget library for window managers, but mostly
catering to users of the *awesome* window manager. It was derived from
the old *Wicked* widget library, and has some of the old *Wicked* widget
types, a few of them rewritten, and a good number of new ones:
* https://github.com/vicious-widgets/vicious
types, a few of them rewritten, and a good number of new ones.
Vicious widget types are a framework for creating your own
widgets. Vicious contains modules that gather data about your system,
@ -14,12 +12,13 @@ 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
description).
## Usage
When provided by an operating system package, or installed from source
into the Lua library path Vicious can be used as a regular Lua
library, to be used stand-alone or to feed widgets of any window
manager (e.g. Ion, WMII). It is compatible with both Lua v5.1 and v5.2.
manager (e.g. Ion, WMII). It is compatible with Lua version 5.1 and above.
```lua
> widgets = require("vicious.widgets.init")
@ -27,6 +26,7 @@ manager (e.g. Ion, WMII). It is compatible with both Lua v5.1 and v5.2.
100
```
## Usage within Awesome
To use Vicious with Awesome, install the package from your operating
@ -34,6 +34,7 @@ system provider, or download the source code and move it to your
awesome configuration directory in `$XDG_CONFIG_HOME` (usually `~/.config`):
```bash
$ git clone https://github.com/vicious-widgets/vicious.git
$ mv vicious $XDG_CONFIG_HOME/awesome/
```
@ -47,17 +48,19 @@ Then add the following to the top of your `rc.lua`:
local vicious = require("vicious")
```
### Register a widget
Once you create a widget (a textbox, graph or a progressbar) call
`vicious.register()` to register it with Vicious:
vicious.register(widget, wtype, format, interval, warg)
### widget
#### widget
*Awesome* widget created with `widget()` or `awful.widget()` (in case of a
graph or a progressbar).
### wtype
#### wtype
Type: Vicious widget or `function`:
@ -66,7 +69,7 @@ Type: Vicious widget or `function`:
* function: custom function from your own *Awesome* configuration can be
registered as widget types (see [Custom widget types](#custom-widget)).
### format
#### format
Type: `string` or `function`:
@ -77,17 +80,15 @@ Type: `string` or `function`:
* `function (widget, args)` can be used to manipulate data returned by the
widget type (see [Format functions](#format-func)).
### interval
#### interval
Number of seconds between updates of the widget (default: 2). Read section
[Power and Caching](#power) for more information.
### warg
#### warg
Some widget types require an argument to be passed, for example the battery ID.
## Other functions
`vicious.register` alone is not much different from
[awful.widget.watch](https://awesomewm.org/doc/api/classes/awful.widget.watch.html),
which has been added to Awesome since version 4.0. However, Vicious offers more
@ -131,6 +132,7 @@ Enable caching of values returned by a widget type.
Fetch data from `wtype` to use it outside from the wibox
([example](#call-example)).
## <a name="widgets"></a>Widget types
Widget types consist of worker functions that take two arguments `format` and
@ -373,9 +375,11 @@ Supported platforms: platform independent (required tools: `curl`).
* Argument: an array including password, hostname and port in that order. `nil`
fields will be fallen back to default (`localhost:6600` without password).
* Returns a table with string keys: `${volume}`, `${bitrate}`, `${elapsed}` (in seconds),
`${duration}` (in seconds), `${Elapsed}` (formatted as [hh:]mm:ss), `${Duration}` (formatted as [hh:]mm:ss),
`${Progress}` (in percentage), ${random}`, `${repeat}`, `${state}`, `${Artist}`, `${Title}`, `${Album}`,
* Returns a table with string keys: `${volume}`, `${bitrate}`,
`${elapsed}` (in seconds), `${duration}` (in seconds),
`${Elapsed}` (formatted as [hh:]mm:ss),
`${Duration}` (formatted as [hh:]mm:ss), `${Progress}` (in percentage),
`${random}`, `${repeat}`, `${state}`, `${Artist}`, `${Title}`, `${Album}`,
`${Genre}` and optionally `${Name}` and `${file}`.
### vicious.widgets.net
@ -560,6 +564,7 @@ Supported platforms: GNU/Linux.
`${rate}` (Mb/s), `${freq}` (MHz), `${linp}` (link quality in percent),
`${txpw}` (transmission power, in dBm) and `${sign}` (signal level, in dBm)
## <a name="custom-widget"></a>Custom widget types
Use any of the existing widget types as a starting point for your
@ -645,6 +650,7 @@ Users of GnuPG (and its agent) could consider encrypting the netrc
file with their GPG key. Trough the GPG Passphrase Agent they could
then decrypt the file transparently while their session is active.
## Usage examples
Start with a simple widget, like `date`. Then build your setup from
@ -733,6 +739,7 @@ cpuwidget:set_color{type = "linear", from = {0, 0}, to = {50, 0},
vicious.register(cpuwidget, vicious.widgets.cpu, "$1", 3)
```
## <a name="format-func"></a>Format functions
You can use a function instead of a string as the format parameter.
@ -863,6 +870,7 @@ mybattery:buttons(awful.util.table.join(
end)))
```
## See also
* Manual pages: [awesome(1)](https://awesomewm.org/doc/manpages/awesome),
@ -872,6 +880,15 @@ mybattery:buttons(awful.util.table.join(
(outdated)
* [My first awesome](https://awesomewm.org/doc/api/documentation/07-my-first-awesome.md.html)
## Contributing
For details, see CONTRIBUTING.md. Vicious is licensed under GNU GPLv2+,
which require all code within the package to be released under
a compatible license. All contributors retain their copyright to their code,
so please make sure you add your name to the header of every file you touch.
## Authors
Wicked was written by:
@ -889,15 +906,63 @@ Current maintainers:
* Daniel Hahler (blueyed) \<github thequod.de\>
* Nguyễn Gia Phong (McSinyx) \<vn.mcsinyx gmail.com\>
Vicious major contributors:
Contributors, listed in alphabetic order:
* Benedikt Sauer \<filmor gmail.com\>
* Greg D. \<jabbas jabbas.pl\>
* Henning Glawe \<glaweh debian.org\>
* Rémy C. \<shikamaru mandriva.org\>
* Hiltjo Posthuma \<hiltjo codemadness.org\>
* Hagen Schink \<troja84 googlemail.com\>
* 0x5b \<dragen15051 gmail.com\>
* Adam Lee \<adam8157 gmail.com\>
* Alexander Koch \<lynix47 gmail.com\>
* Amir Mohammad Saied \<amirsaied gmail.com\>
* Andrea Scarpino \<me andreascarpino.it\>
* Andreas Geisenhainer \<psycorama datenhalde.de\>
* Andrew Merenbach \<andrew merenbach.com\>
* Andrzej Bieniek \<andyhelp gmail.com\>
* Arthur Axel 'fREW' Schmidt \<git frew.co\>
* Arvydas Sidorenko \<asido4 gmail.com\>
* Benedikt Sauer \<filmor gmail.com\>
* Beniamin Kalinowski \<beniamin.kalinowski gmail.com\>
* Benoît Zugmeyer \<bzugmeyer gmail.com\>
* blastmaster \<blastmaster tuxcode.org\>
* Brandon Hartshorn \<brandonhartshorn gmail.com\>
* crondog \<patches crondog.com\>
* David Udelson \<dru5 cornell.edu\>
* Dodo The Last \<dodo.the.last gmail.com\>
* …
* Consult git log for a complete list of contributors
* Elric Milon \<whirm gmx.com\>
* Enric Morales \<me enric.me\>
* getzze \<getzze gmail.com\>
* Greg D. \<jabbas jabbas.pl\>
* Hagen Schink \<troja84 googlemail.com\>
* Henning Glawe \<glaweh debian.org\>
* Hiltjo Posthuma \<hiltjo codemadness.org\>
* [James Reed](https://github.com/supplantr)
* Jay Kamat \<jaygkamat gmail.com\>
* Jeremy \<jeremy.sainvil gmaill.com\>
* jinleileiking \<jinleileiking gmail.com\>
* joe di castro \<joe joedicastro.com\>
* Joerg Jaspert \<joerg debian.org\>
* Jonathan McCrohan \<jmccrohan gmail.com\>
* [Juan Carlos Menonita](https://github.com/JuanKman94)
* Juergen Descher \<jhdl gmx.net\>
* Julian Volodia \<julianvolodia gmail.com\>
* Keith Hughitt \<keith.hughitt gmail.com\>
* Lorenzo Gaggini \<lg lgaggini.net\>
* Lyderic Lefever \<lyderic.lefever gmail.com\>
* Martin Striz \<striz raynet.cz\>
* Martin Ueding \<dev martin-ueding.de\>
* Mellich \<mellich gmx.net\>
* Michael Kressibucher \<mkressibucher hotmail.com\>
* Michael Unterkalmsteiner \<miciu gmx.de\>
* niko \<nikomomo gmail.com\>
* Noah Tilton \<code tilton.co\>
* Normal Ra \<normalrawr gmail.com\>
* Perry Hargrave \<perry.hargrave gmail.com\>
* Rémy CLOUARD \<shikamaru shikamaru.fr\>
* [Roberto](https://github.com/empijei)
* Sébastien Luttringer \<seblu seblu.net\>
* Shadowmourne G \<s10e live.com\>
* starenka \<starenka0 gmail.com\>
* Suseika \<wlasowegor gmail.com\>
* Uli Schlachter \<psychon znc.in\>
* Wtfcoder \<matt mattfreeman.co.uk\>
* Xaver Hellauer \<xaver hellauer.bayern\>
* zhrtz \<apaterson scramble.io\>
* And many others

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2012, jinleileiking <jinleileiking@gmail.com>
---------------------------------------------------
-- contrib/ac_linux.lua
-- Copyright (C) 2012 jinleileiking <jinleileiking@gmail.com>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2013, NormalRa <normalrawr gmail com>
---------------------------------------------------
-- contrib/ati_linux.lua
-- Copyright (C) 2013 NormalRa <normalrawr gmail com>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- contrib/batpmu_linux.lua
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- contrib/batproc_linux.lua
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber

View File

@ -1,7 +1,22 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2017, 0x5b <dragen15051@gmail.com>
---------------------------------------------------
-- contrib/btc_all.lua
-- Copyright (C) 2017 0x5b <dragen15051@gmail.com>
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local pcall = pcall

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2012, Andrzje Bieniek <andyhelp@gmail.com>
---------------------------------------------------
-- contrib/buildbot_all.lua
-- Copyright (C) 2012 Andrzje Bieniek <andyhelp@gmail.com>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local setmetatable = setmetatable

View File

@ -1,7 +1,20 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
---------------------------------------------------
-- * (c) 2010, Jörg. T <jthalheim@mail.com>
-- contrib/countfiles_all.lua
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local io = { popen = io.popen }

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- contrib/dio_linux.lua
-- Copyright (C) 2010, Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local ipairs = ipairs

View File

@ -1,9 +1,22 @@
---------------------------------------------------
-- Vicious widgets for the awesome window manager
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- contrib/init.lua
-- Copyright (C) 2010-2012 Adrian C. (anrxc) <anrxc@sysphere.org>
-- Copyright (C) 2011 Joerg T. (Mic92) <jthalheim@gmail.com>
-- Copyright (C) 2012 Arvydas Sidorenko <asido4@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Setup environment
local setmetatable = setmetatable

View File

@ -1,8 +1,23 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- contrib/mpc_all.lua
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
-- Copyright (C) 2018 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local type = type

View File

@ -1,9 +1,24 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Henning Glawe <glaweh@debian.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- contrib/net_linux.lua
-- Copyright (C) 2009 Henning Glawe <glaweh@debian.org>
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
-- Copyright (C) 2017 Roberto <empijei@users.noreply.github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local pairs = pairs

View File

@ -1,7 +1,22 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Radu A. <admiral0@tuxfamily.org>
---------------------------------------------------
-- contrib/netcfg.lua
-- Copyright (C) 2010 Radu A. <admiral0@tuxfamily.org>
-- Copyright (C) 2010 Adrian C. (anrxc) <anrxc@sysphere.org>
-- Copyright (C) 2012 Arvydas Sidorenko <asido4@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local io = { popen = io.popen }

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2015, Ziyuan Guo <s10e.cn@gmail.com>
---------------------------------------------------
-- contrib/nvinf_all.lua
-- Copyright (C) 2015 Ziyuan Guo <s10e.cn@gmail.com>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2014, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- contrib/nvsmi_all.lua
-- Copyright (C) 2014 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2013, NormalRa <normalrawr gmail com>
---------------------------------------------------
-- contrib/openweather_all.lua
-- Copyright (C) 2013 NormalRa <normalrawr gmail com>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- contrib/ossvol_linux.lua
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber

View File

@ -1,7 +1,23 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Boris Bolgradov <>
-- contrib/pop_all.lua
-- Copyright (c) 2010 Boris Bolgradov
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
---------------------------------------------------
-- This widget type depends on luasocket.
--
-- Widget arguments are host, port, username and

View File

@ -1,8 +1,22 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, MrMagne <mr.magne@yahoo.fr>
-- * (c) 2010, Mic92 <jthalheim@gmail.com>
---------------------------------------------------
-- contrib/pulse_all.lua
-- Copyright (C) 2010 MrMagne <mr.magne@yahoo.fr>
-- Copyright (C) 2010,2017 Jörg Thalheim <joerg@higgsboson.tk>
-- Copyright (C) 2017 Jonathan McCrohan <jmccrohan@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local type = type

View File

@ -1,7 +1,23 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2009, olcc
-- contrib/rss_all.lua
-- Copyright (C) 2009 olcc
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
---------------------------------------------------
-- This is now a standalone RSS reader for awesome:
-- * http://github.com/olcc/aware
---------------------------------------------------

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Greg D. <jabbas@jabbas.pl>
---------------------------------------------------
-- contrib/sensors_linux.lua
-- Copyright (C) 2010 Greg D. <jabbas@jabbas.pl>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber

View File

@ -1,7 +1,21 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2012, jinleileiking. <jinleileiking@gmail.com>
---------------------------------------------------
-- contrib/wpa_all.lua
-- Copyright (C) 2012 jinleileiking <jinleileiking@gmail.com>
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber

100
headergen Executable file
View File

@ -0,0 +1,100 @@
#!/usr/bin/env lua
-- copyright header generator
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
local ipairs = ipairs
local pairs = pairs
local tonumber = tonumber
local io = { open = io.open, popen = io.popen }
local os = { exit = os.exit }
local table = {
concat = table.concat,
insert = table.insert,
sort = table.sort
}
local HEADER = [[-- %s
%s
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
%s]]
local COMMAND = "git log --date=format:%Y --format='%ad %an <%ae>' "
if #arg == 0 then
print'usage: headergen lua-source-files'
os.exit(1)
end
for _, filename in ipairs(arg) do
local fi = io.open(filename)
local content = fi:read'*a'
fi:close()
local holders = {}
local output = io.popen(COMMAND .. filename)
for line in output:lines() do
local year, author = line:match'(%d+)%s+(.+)'
if holders[author] == nil then holders[author] = {} end
holders[author][year] = true
end
output:close()
local copyrights = {}
for author, years in pairs(holders) do
local time = {}
for year, _ in pairs(years) do table.insert(time, tonumber(year)) end
table.sort(time)
local copyright = { 'Copyright (C) ' }
for _, current in ipairs(time) do
local prev = tonumber(copyright[#copyright])
if prev == nil then
table.insert(copyright, current)
elseif current - 1 ~= prev then
table.insert(copyright, ',')
table.insert(copyright, current)
elseif copyright[#copyright - 1] == '-' then
copyright[#copyright] = current
else
table.insert(copyright, '-')
table.insert(copyright, current)
end
end
table.insert(copyrights,
('-- %s %s'):format(table.concat(copyright), author))
end
local fo = io.open(filename, 'w')
table.sort(copyrights)
fo:write(HEADER:format(filename, table.concat(copyrights, '\n'), content))
fo:close()
end

View File

@ -1,12 +1,34 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2019, Enric Morales <me@enric.me>
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Rémy C. <shikamaru@mandriva.org>
-- * (c) 2009, Benedikt Sauer <filmor@gmail.com>
-- * (c) 2009, Henning Glawe <glaweh@debian.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- helper functions
-- Copyright (C) 2009 Benedikt Sauer <filmor@gmail.com>
-- Copyright (C) 2009 Henning Glawe <glaweh@debian.org>
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (C) 2009 Rémy C. <shikamaru@mandriva.org>
-- Copyright (C) 2009-2012 Adrian C. (anrxc) <anrxc@sysphere.org>
-- Copyright (C) 2011 Joerg T. (Mic92) <jthalheim@gmail.com>
-- Copyright (C) 2012 Arvydas Sidorenko <asido4@gmail.com>
-- Copyright (C) 2012 Jörg Thalheim <jthalheim@gmail.com>
-- Copyright (C) 2014-2015 Jörg Thalheim <joerg@higgsboson.tk>
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2017-2018 Jörg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2018-2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
-- Copyright (C) 2019 Alexander Koch <lynix47@gmail.com>
-- Copyright (C) 2019 Enric Morales <me@enric.me>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local ipairs = ipairs
@ -101,6 +123,13 @@ function helpers.wrequire(collection, key)
end
-- }}}
-- {{{ Set widget type's __call metamethod to given worker function
function helpers.setcall(worker)
return setmetatable(
{}, { __call = function(_, ...) return worker(...) end })
end
-- }}}
-- {{{ Set __call metamethod to widget type table having async key
function helpers.setasyncall(wtype)
local function worker(format, warg)
@ -277,5 +306,4 @@ end
-- }}}
return helpers
-- }}}

View File

@ -1,16 +1,41 @@
---------------------------------------------------
-- Vicious widgets for the awesome window manager
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- Vicious module initialization
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (C) 2009-2013 Adrian C. (anrxc) <anrxc@sysphere.org>
-- Copyright (C) 2011 Joerg T. (Mic92) <jthalheim@gmail.com>
-- Copyright (C) 2012 Arvydas Sidorenko <asido4@gmail.com>
-- Copyright (C) 2012 Jörg Thalheim <jthalheim@gmail.com>
-- Copyright (C) 2013 Dodo <dodo.the.last@gmail.com>
-- Copyright (C) 2013-2014,2017 Jörg Thalheim <joerg@higgsboson.tk>
-- Copyright (C) 2014 blastmaster <blastmaster@tuxcode.org>
-- Copyright (C) 2015 Daniel Hahler <git@thequod.de>
-- Copyright (C) 2017 James Reed <supplantr@users.noreply.github.com>
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2017 getzze <getzze@gmail.com>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2018 Beniamin Kalinowski <beniamin.kalinowski@gmail.com>
-- Copyright (C) 2018 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
-- Copyright (C) 2019 Daniel Hahler <github@thequod.de>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Setup environment
local type = type
local pairs = pairs
local tonumber = tonumber
local timer = (type(timer) == 'table' and timer or require("gears.timer"))
local timer = type(timer) == "table" and timer or require("gears.timer")
local os = { time = os.time }
local table = {
insert = table.insert,
@ -69,20 +94,22 @@ local function update(widget, reg, disablecache)
return ret or data
end
local function topercent(e) return tonumber(e) and tonumber(e) / 100 end
local function update_value(data)
local fmtd_data = format_data(data)
if widget.add_value ~= nil then
if widget.get_stack ~= nil and widget:get_stack() then
for idx, _ in ipairs(widget:get_stack_colors()) do
if fmtd_data[idx] then
widget:add_value(tonumber(fmtd_data[idx]) and tonumber(fmtd_data[idx]/100), idx)
widget:add_value(topercent(fmtd_data[idx]), idx)
end
end
else
widget:add_value(tonumber(fmtd_data) and tonumber(fmtd_data)/100)
widget:add_value(topercent(fmtd_data))
end
elseif widget.set_value ~= nil then
widget:set_value(tonumber(fmtd_data) and tonumber(fmtd_data)/100)
widget:set_value(topercent(fmtd_data))
elseif widget.set_markup ~= nil then
widget:set_markup(fmtd_data)
else

View File

@ -1,5 +1,5 @@
-- spawn.lua - wrapper around Awesome awful.spawn with fallback
-- Copyright (C) 2019 Nguyễn Gia Phong
-- wrapper around Awesome awful.spawn with fallback
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
@ -11,9 +11,9 @@
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Affero General Public License for more details.
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU Affero General Public License
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
local status, awful = pcall(require, "awful")

48
templates/README.md Normal file
View File

@ -0,0 +1,48 @@
# Widget type templates
Before writing a new widget type, make sure to ask yourself if anyone is going
to need the feature. Only widget types that you (or an incapacitated friend
you can personally talk to) require would be merged. Do not file PRs because
they seem like a good idea. If they're really useful, they'll be requested
in the issue tracker.
Additionally, too simple widget types (e.g. an one-liner) and those that
are not modular enough are very unlikely to be merged. By *modular*, we mean
> constructed with standardized units or dimensions
> allowing flexibility and variety in use
If all the above conditions are met, you can start from one of the templates
in this directory:
* `sync.lua`: synchronous widget type that does not fork
* `async.lua`: asynchronous widget type for fetching informations using
a command-line utility. As a rule of thumb, if your widget type uses
`io.popen`, you would need to refactor it to use async facilities.
Your widget types should be placed in `widgets`: the `contrib` directory
exists only for historical reasons and is barely maintained anymore.
The filenames should be of the form `<name>_<platform>.lua`, whereas
* `<name>` is a single (alphanumeric) word, preferably in lowercase
* `<platform>` is the OS that the widget type works on.
At the time of writing these are supported:
- `freebsd`: FreeBSD
- `openbsd`: OpenBSD
- `bsd`: all \*BSDs listed above
- `linux`: GNU/Linux
- `all`: all of the above
Please be aware of `luacheck`, which may help you during the progress.
From `widgets`, run
luacheck --config .luacheckrc ..
After finishing the widget type, you should document its usage in the project's
`README.md`. Try to provide at least
* A brief description
* The list of supported platforms
* Type and structures of the arguments that the widget type passes
(`format` and `warg`), with unused parameters omitted
* Type and structure of the return value

28
templates/async.lua Normal file
View File

@ -0,0 +1,28 @@
-- template for asynchronous widet types
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
local helpers = require"vicious.helpers"
return helpers.setasyncall{
async = function (format, warg, callback)
-- In here there should be some asynchronous function
-- from vicious.spawn or helpers.sysctl_async
-- that call callback on the result.
end }
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

25
templates/sync.lua Normal file
View File

@ -0,0 +1,25 @@
-- template for synchronous widet types
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
local helpers = require"vicious.helpers"
return helpers.setcall(function (format, warg)
-- Do the processing and return a table here.
end)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -1,3 +1,22 @@
-- battery widget type for FreeBSD
-- Copyright (C) 2017-2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
local math = { floor = math.floor }

View File

@ -1,28 +1,38 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2013, NormalRa <normalrawr@gmail.com>
---------------------------------------------------
-- battery widget type for GNU/Linux
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2013 NormalRa <normalrawr@gmail.com>
-- Copyright (C) 2017 David Udelson <dru5@cornell.edu>
-- Copyright (C) 2017 Roberto <empijei@users.noreply.github.com>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
local setmetatable = setmetatable
local string = { format = string.format }
local helpers = require("vicious.helpers")
local math = {
min = math.min,
floor = math.floor
}
local helpers = require"vicious.helpers"
-- }}}
-- Bat: provides state, charge, remaining time, and wear for a requested battery
-- vicious.widgets.bat
local bat_linux = {}
-- {{{ Battery widget type
local function worker(format, warg)
return helpers.setcall(function (format, warg)
if not warg then return end
local battery = helpers.pathtotable("/sys/class/power_supply/"..warg)
@ -45,11 +55,11 @@ local function worker(format, warg)
return {battery_state["Unknown\n"], 0, "N/A", 0, curpower}
end
-- Get state information
local state = battery_state[battery.status] or battery_state["Unknown\n"]
-- Get capacity information
local remaining, capacity, capacity_design
if battery.charge_now then
remaining, capacity = battery.charge_now, battery.charge_full
capacity_design = battery.charge_full_design or capacity
@ -64,8 +74,8 @@ local function worker(format, warg)
local percent = math.min(math.floor(remaining / capacity * 100), 100)
local wear = math.floor(100 - capacity / capacity_design * 100)
-- Get charge information
local rate
if battery.current_now then
rate = tonumber(battery.current_now)
elseif battery.power_now then
@ -78,8 +88,9 @@ local function worker(format, warg)
local time = "N/A"
if rate ~= nil and rate ~= 0 then
local timeleft
if state == "+" then
timeleft = (tonumber(capacity) - tonumber(remaining)) / tonumber(rate)
timeleft = (tonumber(capacity)-tonumber(remaining)) / tonumber(rate)
elseif state == "-" then
timeleft = tonumber(remaining) / tonumber(rate)
else
@ -94,7 +105,5 @@ local function worker(format, warg)
end
return {state, percent, time, wear, curpower}
end
end)
-- }}}
return setmetatable(bat_linux, { __call = function(_, ...) return worker(...) end })

View File

@ -1,6 +1,6 @@
-- bat_openbsd.lua - provide battery information on OpenBSD
-- Copyright (C) 2019 Enric Morales
-- Copyright (C) 2019 Nguyễn Gia Phong
-- battery widget type for OpenBSD
-- Copyright (C) 2019 Enric Morales <me@enric.me>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
@ -12,9 +12,9 @@
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Affero General Public License for more details.
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU Affero General Public License
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment

View File

@ -1,7 +1,22 @@
-----------------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2017, JuanKman94 <juan.carlos.menonita@gmail.com>
-----------------------------------------------------------
-- cmus music player widget type
-- Copyright (C) 2017 JuanKman94 <juan.carlos.menonita@gmail.com>
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2018-2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local type = type

View File

@ -1,3 +1,22 @@
-- CPU usage widget type for FreeBSD
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local math = { floor = math.floor }
local string = { gmatch = string.gmatch }
@ -5,7 +24,6 @@ local string = { gmatch = string.gmatch }
local helpers = require("vicious.helpers")
-- }}}
-- Cpu: provides CPU usage for all available CPUs/cores
-- vicious.widgets.cpu_freebsd
local cpu_freebsd = {}

View File

@ -1,35 +1,44 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2011, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
-- * (c) 2011, Jörg Thalheim <jthalheim@gmail.com>
---------------------------------------------------
-- CPU usage widget type for GNU/Linux
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (C) 2011 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2011 Jörg Thalheim <jthalheim@gmail.com>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local ipairs = ipairs
local io = { open = io.open }
local setmetatable = setmetatable
local math = { floor = math.floor }
local table = { insert = table.insert }
local string = {
sub = string.sub,
gmatch = string.gmatch
}
local helpers = require"vicious.helpers"
-- }}}
-- Cpu: provides CPU usage for all available CPUs/cores
-- vicious.widgets.cpu
local cpu_linux = {}
-- Initialize function tables
local cpu_usage = {}
local cpu_total = {}
local cpu_active = {}
-- {{{ CPU widget type
local function worker(format)
return helpers.setcall(function ()
local cpu_lines = {}
-- Get CPU stats
@ -52,7 +61,6 @@ local function worker(format)
cpu_active[i] = 0
end
for i, v in ipairs(cpu_lines) do
-- Calculate totals
local total_new = 0
@ -74,7 +82,5 @@ local function worker(format)
end
return cpu_usage
end
end)
-- }}}
return setmetatable(cpu_linux, { __call = function(_, ...) return worker(...) end })

View File

@ -1,14 +1,31 @@
-- CPU frequency widget type for FreeBSD
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
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
function cpufreq_freebsd.async(format, warg, callback)
if not warg then return callback({}) end

View File

@ -1,33 +1,41 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- CPU frequency widget type for GNU/Linux
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
local setmetatable = setmetatable
local string = { match = string.match }
local helpers = require("vicious.helpers")
-- }}}
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
-- vicious.widgets.cpufreq
local cpufreq_linux = {}
local GOVERNOR_STATE = {
["ondemand\n"] = "",
["powersave\n"] = "",
["userspace\n"] = "¤",
["performance\n"] = "",
["conservative\n"] = ""
}
-- {{{ CPU frequency widget type
local function worker(format, warg)
return helpers.setcall(function (format, warg)
if not warg then return end
local _cpufreq = helpers.pathtotable("/sys/devices/system/cpu/"..warg.."/cpufreq")
local governor_state = {
["ondemand\n"] = "",
["powersave\n"] = "",
["userspace\n"] = "¤",
["performance\n"] = "",
["conservative\n"] = ""
}
local _cpufreq = helpers.pathtotable(
("/sys/devices/system/cpu/%s/cpufreq"):format(warg))
-- Default frequency and voltage values
local freqv = {
["mhz"] = "N/A", ["ghz"] = "N/A",
@ -43,7 +51,8 @@ local function worker(format, warg)
-- Get the current voltage
if _cpufreq.scaling_voltages then
freqv.mv = tonumber(string.match(_cpufreq.scaling_voltages, freq.."[%s]([%d]+)"))
freqv.mv = tonumber(
_cpufreq.scaling_voltages:match(freq .. "[%s]([%d]+)"))
-- Calculate voltage from mV
freqv.v = freqv.mv / 1000
end
@ -52,10 +61,8 @@ local function worker(format, warg)
-- Get the current governor
local governor = _cpufreq.scaling_governor
-- Represent the governor as a symbol
governor = governor_state[governor] or governor or "N/A"
governor = GOVERNOR_STATE[governor] or governor or "N/A"
return {freqv.mhz, freqv.ghz, freqv.mv, freqv.v, governor}
end
end)
-- }}}
return setmetatable(cpufreq_linux, { __call = function(_, ...) return worker(...) end })

View File

@ -1,23 +1,31 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- CPU information widget type for GNU/Linux
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
local io = { lines = io.lines }
local setmetatable = setmetatable
local string = { gmatch = string.gmatch }
local helpers = require"vicious.helpers"
-- }}}
-- Cpuinf: provides speed and cache information for all available CPUs/cores
-- vicious.widgets.cpuinf
local cpuinf_linux = {}
-- {{{ CPU Information widget type
local function worker(format)
return helpers.setcall(function ()
local id = nil
local cpu_info = {} -- Get CPU info
@ -38,7 +46,5 @@ local function worker(format)
end
return cpu_info
end
end)
-- }}}
return setmetatable(cpuinf_linux, { __call = function(_, ...) return worker(...) end })

View File

@ -1,27 +1,29 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- date and time widget type using os.date with optional time formatting
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local setmetatable = setmetatable
local os = {
date = os.date,
time = os.time
}
local os = { date = os.date, time = os.time }
local helpers = require"vicious.helpers"
-- }}}
-- Date: provides access to os.date with optional time formatting
-- vicious.widgets.date
local date_all = {}
-- {{{ Date widget type
local function worker(format, warg)
return helpers.setcall(function (format, warg)
return os.date(format or nil, warg and os.time()+warg or nil)
end
-- }}}
return setmetatable(date_all, { __call = function(_, ...) return worker(...) end })
end)

View File

@ -1,26 +1,31 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2011, Jörg T. <jthalheim@gmail.com>
---------------------------------------------------
-- disk I/O widget type for GNU/Linux
-- Copyright (C) 2011 Jörg T. <jthalheim@gmail.com>
-- Copyright (C) 2017 Elric Milon <whirm@gmx.com>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local pairs = pairs
local io = { lines = io.lines }
local setmetatable = setmetatable
local string = { match = string.match }
local helpers = require("vicious.helpers")
local os = {
time = os.time,
difftime = os.difftime
}
local os = { time = os.time, difftime = os.difftime }
local helpers = require"vicious.helpers"
-- }}}
-- Disk I/O: provides I/O statistics for requested storage devices
-- vicious.widgets.dio
local dio_linux = {}
-- Initialize function tables
local disk_usage = {}
local disk_stats = {}
@ -30,13 +35,13 @@ local unit = { ["s"] = 1, ["kb"] = 2, ["mb"] = 2048 }
local time_unit = { ["ms"] = 1, ["s"] = 1000 }
-- {{{ Disk I/O widget type
local function worker(format)
return helpers.setcall(function ()
local disk_lines = {}
for line in io.lines("/proc/diskstats") do
local device, read, write, iotime =
-- Linux kernel documentation: Documentation/iostats.txt
string.match(line, "([^%s]+) %d+ %d+ (%d+) %d+ %d+ %d+ (%d+) %d+ %d+ (%d+)")
line:match"([^%s]+) %d+ %d+ (%d+) %d+ %d+ %d+ (%d+) %d+ %d+ (%d+)"
disk_lines[device] = { read, write, iotime }
end
@ -50,7 +55,7 @@ local function worker(format)
-- Check for overflows and counter resets (> 2^32)
if stats[1] < last_stats[1] or stats[2] < last_stats[2] then
last_stats[1], last_stats[2], last_stats[3] = stats[1], stats[2], stats[3]
for i = 1,3 do last_stats[i] = stats[i] end
end
-- Diskstats are absolute, substract our last reading
@ -70,7 +75,5 @@ local function worker(format)
disk_stats = disk_lines
return disk_usage
end
end)
-- }}}
return setmetatable(dio_linux, { __call = function(_, ...) return worker(...) end })

View File

@ -1,3 +1,22 @@
-- fan speed widget type for FreeBSD
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
local type = type
@ -5,7 +24,6 @@ local type = type
local helpers = require("vicious.helpers")
-- }}}
-- fanspeed: provides speed level of fans
-- vicious.widgets.fanspeed
--

View File

@ -1,8 +1,24 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- filesystem widget type
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber

View File

@ -1,7 +1,23 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- new e-mails count and last e-mail subject on Gmail
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2017 starenka <starenka0@gmail.com>
-- Copyright (C) 2018-2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local type = type
@ -12,7 +28,6 @@ local helpers = require("vicious.helpers")
local spawn = require("vicious.spawn")
-- }}}
-- Gmail: provides count of new and subject of last e-mail on Gmail
-- vicious.widgets.gmail
local gmail_all = {}

View File

@ -1,7 +1,22 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- hard drive temperatures widget type using hddtemp daemon
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
@ -10,7 +25,6 @@ local helpers = require"vicious.helpers"
local spawn = require"vicious.spawn"
-- }}}
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
-- vicious.widgets.hddtemp
return helpers.setasyncall{

View File

@ -1,7 +1,21 @@
----------------------------------------------------------------
-- Licensed under the GNU General Public License v2
-- (C) 2019, Alexander Koch <lynix47@gmail.com>
----------------------------------------------------------------
-- widget type providing name-indexed temperatures from /sys/class/hwmon
-- Copyright (C) 2019 Alexander Koch <lynix47@gmail.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- environment
local type = type

View File

@ -1,5 +1,24 @@
-- widget types initialization
-- Copyright (C) 2010 Adrian C. (anrxc) <anrxc@sysphere.org>
-- Copyright (C) 2011,2012 Jörg Thalheim <jthalheim@gmail.com>
-- Copyright (C) 2012 Arvydas Sidorenko <asido4@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
local setmetatable = setmetatable
local wrequire = require("vicious.helpers").wrequire
widgets = { _NAME = "vicious.widgets" }
return setmetatable(widgets, {__index = wrequire})
return setmetatable({ _NAME = "vicious.widgets" }, { __index = wrequire })

View File

@ -1,41 +1,45 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- widget type providing the subject of last e-mail in a mbox file
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2018 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local type = type
local io = { open = io.open }
local setmetatable = setmetatable
local string = { gfind = string.gfind }
local helpers = require("vicious.helpers")
-- }}}
-- Mbox: provides the subject of last e-mail in a mbox file
-- vicious.widgets.mbox
local mbox_all = {}
-- Initialize variables
local subject = "N/A"
-- {{{ Mailbox widget type
local function worker(format, warg)
return helpers.setcall(function (format, warg)
if not warg then return end
-- mbox could be huge, get a 30kb chunk from EOF
if type(warg) ~= "table" then _mbox = warg end
-- * attachment could be much bigger than 30kb
local f = io.open(_mbox or warg[1])
local f = io.open(type(warg) == "table" and warg[1] or warg)
f:seek("end", -30720)
-- mbox could be huge, get a 30kb chunk from EOF
-- * attachment could be much bigger than 30kb
local txt = f:read("*all")
f:close()
-- Find all Subject lines
for i in string.gfind(txt, "Subject: ([^\n]*)") do
subject = i
end
for i in txt:gmatch"Subject: ([^\n]*)" do subject = i end
-- Check if we should scroll, or maybe truncate
if type(warg) == "table" then
@ -46,8 +50,6 @@ local function worker(format, warg)
end
end
return {subject}
end
return { subject }
end)
-- }}}
return setmetatable(mbox_all, { __call = function(_, ...) return worker(...) end })

View File

@ -1,22 +1,29 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- widget type providing the count of total, old and new messages in mbox files
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local io = { open = io.open }
local setmetatable = setmetatable
local string = { find = string.find }
local helpers = require"vicious.helpers"
-- }}}
-- Mboxc: provides the count of total, old and new messages in mbox files
-- vicious.widgets.mboxc
local mboxc_all = {}
-- {{{ Mbox count widget type
local function worker(format, warg)
return helpers.setcall(function (format, warg)
if not warg then return end
-- Initialize counters
@ -34,15 +41,15 @@ local function worker(format, warg)
-- Find all messages
-- * http://www.jwz.org/doc/content-length.html
local _, from = string.find(lines, "^From[%s]")
local _, from = lines:find"^From[%s]"
if from ~= nil then count.total = count.total + 1 end
-- Read messages have the Status header
local _, status = string.find(lines, "^Status:[%s]RO$")
local _, status = lines:find"^Status:[%s]RO$"
if status ~= nil then count.old = count.old + 1 end
-- Skip the folder internal data
local _, int = string.find(lines, "^Subject:[%s].*FOLDER[%s]INTERNAL[%s]DATA")
local _, int = lines:find"^Subject:[%s].*FOLDER[%s]INTERNAL[%s]DATA"
if int ~= nil then count.total = count.total - 1 end
end
f:close()
@ -52,7 +59,5 @@ local function worker(format, warg)
count.new = count.total - count.old
return {count.total, count.old, count.new}
end
end)
-- }}}
return setmetatable(mboxc_all, { __call = function(_, ...) return worker(...) end })

View File

@ -1,8 +1,23 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) Maildir Biff Widget, Fredrik Ax
---------------------------------------------------
-- widget type providing number of new and unread Maildir messages
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2010 Fredrik Ax
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local type = type
@ -11,12 +26,9 @@ local helpers = require"vicious.helpers"
local spawn = require"vicious.spawn"
-- }}}
-- Mdir: provides the number of new and unread messages in Maildir structures/dirs
-- vicious.widgets.mdir
local mdir_all = {}
-- {{{ Maildir widget type
function mdir_all.async(format, warg, callback)
if type(warg) ~= "table" then return callback{} end

View File

@ -1,3 +1,23 @@
-- RAM and swap usage widget type for FreeBSD
-- Copyright (C) 2017-2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2018 Andreas Geisenhainer <psycorama@datenhalde.de>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
local math = { floor = math.floor }

View File

@ -1,24 +1,33 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- RAM and swap usage widget type for GNU/Linux
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2018 Jay Kamat <jaygkamat@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local io = { lines = io.lines }
local setmetatable = setmetatable
local math = { floor = math.floor }
local string = { gmatch = string.gmatch }
local helpers = require"vicious.helpers"
-- }}}
-- Mem: provides RAM and Swap usage statistics
-- vicious.widgets.mem
local mem_linux = {}
-- {{{ Memory widget type
local function worker(format)
return helpers.setcall(function ()
local _mem = { buf = {}, swp = {} }
-- Get MEM info
@ -47,7 +56,5 @@ local function worker(format)
return {_mem.usep, _mem.inuse, _mem.total, _mem.free,
_mem.swp.usep, _mem.swp.inuse, _mem.swp.t, _mem.swp.f,
_mem.bcuse }
end
end)
-- }}}
return setmetatable(mem_linux, { __call = function(_, ...) return worker(...) end })

View File

@ -1,7 +1,25 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- Music Player Daemon widget type
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2018 Jörg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2018-2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
-- Copyright (C) 2019 Juan Carlos Menonita <JuanKman94@users.noreply.github.com>
-- Copyright (C) 2019 Lorenzo Gaggini <lg@lgaggini.net>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
@ -12,7 +30,6 @@ local helpers = require"vicious.helpers"
local spawn = require"vicious.spawn"
-- }}}
-- Mpd: provides Music Player Daemon information
-- vicious.widgets.mpd
local mpd_all = {}

View File

@ -1,3 +1,22 @@
-- network status and usage widget type for FreeBSD
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
local os = { time = os.time }

View File

@ -1,24 +1,31 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- network status and usage widget type for GNU/Linux
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
local os = { time = os.time }
local io = { lines = io.lines }
local setmetatable = setmetatable
local string = { match = string.match }
local helpers = require("vicious.helpers")
-- }}}
-- Net: provides state and usage statistics of all network interfaces
-- vicious.widgets.net
local net_linux = {}
-- Initialize function tables
local nets = {}
-- Variable definitions
@ -27,7 +34,7 @@ local unit = { ["b"] = 1, ["kb"] = 1024,
}
-- {{{ Net widget type
local function worker(format)
return helpers.setcall(function ()
local args = {}
-- Get NET stats
@ -74,7 +81,5 @@ local function worker(format)
end
return args
end
end)
-- }}}
return setmetatable(net_linux, { __call = function(_, ...) return worker(...) end })

View File

@ -1,62 +1,65 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) org-awesome, Damien Leone
---------------------------------------------------
-- widget type providing agenda from Emacs org-mode
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2010 org-awesome, Damien Leone
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local io = { lines = io.lines }
local setmetatable = setmetatable
local string = { find = string.find }
local os = {
time = os.time,
date = os.date
}
local os = { time = os.time, date = os.date }
local helpers = require"vicious.helpers"
-- }}}
-- Org: provides agenda statistics for Emacs org-mode
-- vicious.widgets.org
local org_all = {}
-- {{{ OrgMode widget type
local function worker(format, warg)
return helpers.setcall(function (format, warg)
if not warg then return end
-- Compute delays
local today = os.time{ year=os.date("%Y"), month=os.date("%m"), day=os.date("%d") }
local soon = today + 24 * 3600 * 3 -- 3 days ahead is close
local future = today + 24 * 3600 * 7 -- 7 days ahead is maximum
local today = os.time{ year = os.date("%Y"), month = os.date("%m"),
day = os.date("%d") }
local soon = today + 24*3600*3 -- 3 days ahead is close
local future = today + 24*3600*7 -- 7 days ahead is maximum
-- Initialize counters
local count = { past = 0, today = 0, soon = 0, future = 0 }
-- Get data from agenda files
for i=1, #warg do
for line in io.lines(warg[i]) do
local scheduled = string.find(line, "SCHEDULED:")
local closed = string.find(line, "CLOSED:")
local deadline = string.find(line, "DEADLINE:")
for i = 1,#warg do
for line in io.lines(warg[i]) do
local scheduled = line:find"SCHEDULED:"
local deadline = line:find"DEADLINE:"
local closed = line:find"CLOSED:"
local b, _, y, m, d = line:find"(%d%d%d%d)-(%d%d)-(%d%d)"
if (scheduled and not closed) or (deadline and not closed) then
local b, e, y, m, d = string.find(line, "(%d%d%d%d)-(%d%d)-(%d%d)")
if b then
local t = os.time{ year = y, month = m, day = d }
if t < today then count.past = count.past + 1
elseif t == today then count.today = count.today + 1
elseif t <= soon then count.soon = count.soon + 1
elseif t <= future then count.future = count.future + 1
if (scheduled or deadline) and not closed and b then
local t = os.time{ year = y, month = m, day = d }
if t < today then
count.past = count.past + 1
elseif t == today then
count.today = count.today + 1
elseif t <= soon then
count.soon = count.soon + 1
elseif t <= future then
count.future = count.future + 1
end
end
end
end
end
end
end
return {count.past, count.today, count.soon, count.future}
end
return { count.past, count.today, count.soon, count.future }
end)
-- }}}
return setmetatable(org_all, { __call = function(_, ...) return worker(...) end })

View File

@ -1,7 +1,20 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- operating system widget type for *BSD
-- Copyright (C) 2019 mutlusun <mutlusun@users.noreply.github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local los = { getenv = os.getenv }
@ -10,12 +23,10 @@ local helpers = require("vicious.helpers")
local spawn = require("vicious.spawn")
-- }}}
-- OS: provides operating system information
-- vicious.widgets.os
local os_bsd = {}
-- {{{ Operating system widget type
local function parse(stdout, stderr, exitreason, exitcode)
local system = {

View File

@ -1,27 +1,35 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- operating system widget type for GNU/Linux
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
-- Copyright (C) 2019 mutlusun <mutlusun@users.noreply.github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local pairs = pairs
local tonumber = tonumber
local math = { ceil = math.ceil }
local los = { getenv = os.getenv }
local setmetatable = setmetatable
local string = { gsub = string.gsub }
local helpers = require"vicious.helpers"
-- }}}
-- OS: provides operating system information
-- vicious.widgets.os
local os_linux = {}
-- {{{ Operating system widget type
local function worker(format)
return helpers.setcall(function ()
local system = {
["ostype"] = "N/A",
["hostname"] = "N/A",
@ -54,8 +62,5 @@ local function worker(format)
return {system["ostype"], system["osrelease"], system["username"],
system["hostname"], system["entropy"], system["entropy_p"]}
end
end)
-- }}}
return setmetatable(os_linux,
{ __call = function(_, ...) return worker(...) end })

View File

@ -1,14 +1,30 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- widget type providing number of pending updates
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2017 getzze <getzze@gmail.com>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local spawn = require("vicious.spawn")
local helpers = require("vicious.helpers")
-- }}}
-- Pkg: provides number of pending updates on UNIX systems
-- vicious.widgets.pkg
local pkg_all = {}

View File

@ -1,30 +1,39 @@
-----------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Hagen Schink <troja84@googlemail.com>
-----------------------------------------------------
-- widget type providing RAID array information on GNU/Linux
-- Copyright (C) 2010 Hagen Schink <troja84@googlemail.com>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local io = { open = io.open }
local setmetatable = setmetatable
local string = {
len = string.len,
sub = string.sub,
match = string.match,
gmatch = string.gmatch
}
local helpers = require"vicious.helpers"
-- }}}
-- Raid: provides state information for a requested RAID array
-- vicious.widgets.raid
local raid_linux = {}
-- Initialize function tables
local mddev = {}
-- {{{ RAID widget type
local function worker(format, warg)
return helpers.setcall(function (format, warg)
if not warg then return end
mddev[warg] = {
["found"] = false,
@ -38,7 +47,7 @@ local function worker(format, warg)
if mddev[warg]["found"] then
local updev = string.match(line, "%[[_U]+%]")
for i in string.gmatch(updev, "U") do
for _ in string.gmatch(updev, "U") do
mddev[warg]["active"] = mddev[warg]["active"] + 1
end
@ -46,7 +55,7 @@ local function worker(format, warg)
elseif string.sub(line, 1, string.len(warg)) == warg then
mddev[warg]["found"] = true
for i in string.gmatch(line, "%[[%d]%]") do
for _ in string.gmatch(line, "%[[%d]%]") do
mddev[warg]["assigned"] = mddev[warg]["assigned"] + 1
end
end
@ -54,7 +63,5 @@ local function worker(format, warg)
f:close()
return {mddev[warg]["assigned"], mddev[warg]["active"]}
end
end)
-- }}}
return setmetatable(raid_linux, { __call = function(_, ...) return worker(...) end })

View File

@ -1,3 +1,22 @@
-- temperature widget type for FreeBSD
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local string = { match = string.match }
local type = type
@ -5,7 +24,6 @@ local type = type
local helpers = require("vicious.helpers")
-- }}}
-- Thermal: provides temperature levels of ACPI and coretemp thermal zones
-- vicious.widgets.thermal
local thermal_freebsd = {}

View File

@ -1,25 +1,32 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- temperature widget type for GNU/Linux
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local type = type
local tonumber = tonumber
local setmetatable = setmetatable
local string = { match = string.match }
local helpers = require("vicious.helpers")
local math = { floor = math.floor }
local helpers = require("vicious.helpers")
-- }}}
-- Thermal: provides temperature levels of ACPI and coretemp thermal zones
-- vicious.widgets.thermal
local thermal_linux = {}
-- {{{ Thermal widget type
local function worker(format, warg)
return helpers.setcall(function (format, warg)
if not warg then return end
local zone = { -- Known temperature data sources
@ -43,7 +50,5 @@ local function worker(format, warg)
end
return {0}
end
end)
-- }}}
return setmetatable(thermal_linux, { __call = function(_, ...) return worker(...) end })

View File

@ -1,3 +1,22 @@
-- uptime widget type for FreeBSD
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
local math = { floor = math.floor }
@ -6,12 +25,10 @@ local os = { time = os.time }
local helpers = require("vicious.helpers")
-- }}}
-- Uptime: provides system uptime and load information
-- vicious.widgets.uptime
local uptime_freebsd = {}
-- {{{ Uptime widget type
function uptime_freebsd.async(format, warg, callback)
helpers.sysctl_async(

View File

@ -1,24 +1,31 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- uptime widget type for GNU/Linux
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local setmetatable = setmetatable
local math = { floor = math.floor }
local string = { match = string.match }
local helpers = require("vicious.helpers")
-- }}}
-- Uptime: provides system uptime and load information
-- vicious.widgets.uptime
local uptime_linux = {}
-- {{{ Uptime widget type
local function worker(format)
return helpers.setcall(function ()
local proc = helpers.pathtotable("/proc")
-- Get system uptime
@ -28,9 +35,7 @@ local function worker(format)
local up_m = math.floor(((up_t % (3600 * 24)) % 3600) / 60)
local l1, l5, l15 = -- Get load averages for past 1, 5 and 15 minutes
string.match(proc.loadavg, "([%d%.]+)[%s]([%d%.]+)[%s]([%d%.]+)")
string.match(proc.loadavg, "([%d%.]+)[%s]([%d%.]+)[%s]([%d%.]+)")
return {up_d, up_h, up_m, l1, l5, l15}
end
end)
-- }}}
return setmetatable(uptime_linux, { __call = function(_, ...) return worker(...) end })

View File

@ -1,3 +1,22 @@
-- volume widget type for FreeBSD
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
local string = { match = string.match }
@ -5,12 +24,10 @@ local helpers = require("vicious.helpers")
local spawn = require("vicious.spawn")
-- }}}
-- Volume: provides volume levels and state of requested mixer
-- vicious.widgets.volume_freebsd
local volume_freebsd = {}
-- {{{ Volume widget type
local STATE = { on = '🔉', off = '🔈' }

View File

@ -1,7 +1,23 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- volume widget type for GNU/Linux
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Brandon Hartshorn <brandonhartshorn@gmail.com>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local type = type
@ -13,7 +29,6 @@ local helpers = require("vicious.helpers")
local spawn = require("vicious.spawn")
-- }}}
-- Volume: provides volume levels and state of requested ALSA mixers
-- vicious.widgets.volume
local volume_linux = {}

View File

@ -1,19 +1,34 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- weather widget type fetching from from US NOAA
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Arthur Axel 'fREW' Schmidt <git@frew.co>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local tonumber = tonumber
local math = { ceil = math.ceil }
local os = { date = os.date, difftime = os.difftime, time = os.time }
local string = { match = string.match }
local string = { format = string.format }
local spawn = require"vicious.spawn"
local helpers = require"vicious.helpers"
-- }}}
-- Weather: provides weather information for a requested station
-- vicious.widgets.weather
local weather_all = {}
@ -27,7 +42,6 @@ local function get_timezone_offset()
return os.difftime(os.time(localdate), os.time(utcdate))
end
-- {{{ Weather widget type
local function parse(stdout, stderr, exitreason, exitcode)
-- Initialize function tables
@ -51,55 +65,59 @@ local function parse(stdout, stderr, exitreason, exitcode)
if stdout == '' then return _weather end
_weather["{city}"] = -- City and/or area
string.match(stdout, "^(.+)%,.*%([%u]+%)") or _weather["{city}"]
stdout:match"^(.+)%,.*%([%u]+%)"
or _weather["{city}"]
_weather["{wind}"] = -- Wind direction and degrees if available
string.match(stdout, "Wind:[%s][%a]+[%s][%a]+[%s](.+)[%s]at.+$") or _weather["{wind}"]
stdout:match"Wind:[%s][%a]+[%s][%a]+[%s](.+)[%s]at.+$"
or _weather["{wind}"]
_weather["{windmph}"] = -- Wind speed in MPH if available
string.match(stdout, "Wind:[%s].+[%s]at[%s]([%d]+)[%s]MPH") or _weather["{windmph}"]
stdout:match"Wind:[%s].+[%s]at[%s]([%d]+)[%s]MPH"
or _weather["{windmph}"]
_weather["{sky}"] = -- Sky conditions if available
string.match(stdout, "Sky[%s]conditions:[%s](.-)[%c]") or _weather["{sky}"]
stdout:match"Sky[%s]conditions:[%s](.-)[%c]"
or _weather["{sky}"]
_weather["{weather}"] = -- Weather conditions if available
string.match(stdout, "Weather:[%s](.-)[%c]") or _weather["{weather}"]
stdout:match"Weather:[%s](.-)[%c]"
or _weather["{weather}"]
_weather["{tempf}"] = -- Temperature in fahrenheit
string.match(stdout, "Temperature:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{tempf}"]
stdout:match"Temperature:[%s]([%-]?[%d%.]+).*[%c]"
or _weather["{tempf}"]
_weather["{dewf}"] = -- Dew Point in fahrenheit
string.match(stdout, "Dew[%s]Point:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{dewf}"]
stdout:match"Dew[%s]Point:[%s]([%-]?[%d%.]+).*[%c]"
or _weather["{dewf}"]
_weather["{humid}"] = -- Relative humidity in percent
string.match(stdout, "Relative[%s]Humidity:[%s]([%d]+)%%") or _weather["{humid}"]
stdout:match"Relative[%s]Humidity:[%s]([%d]+)%%"
or _weather["{humid}"]
_weather["{press}"] = -- Pressure in hPa
string.match(stdout, "Pressure[%s].+%((.+)[%s]hPa%)") or _weather["{press}"]
stdout:match"Pressure[%s].+%((.+)[%s]hPa%)"
or _weather["{press}"]
local year, month, day, hour, min =
string.match(stdout, "(%d%d%d%d).(%d%d).(%d%d) (%d%d)(%d%d) UTC")
stdout:match"(%d%d%d%d).(%d%d).(%d%d) (%d%d)(%d%d) UTC"
if year ~= nil then
local utctable = {
year = year,
month = month,
day = day,
hour = hour,
min = min,
}
_weather["{when}"] = os.time(utctable) + get_timezone_offset()
local utctable = { year = year, month = month, day = day,
hour = hour, min = min }
_weather["{when}"] = os.time(utctable) + get_timezone_offset()
end
-- Wind speed in km/h if MPH was available
if _weather["{windmph}"] ~= "N/A" then
_weather["{windmph}"] = tonumber(_weather["{windmph}"])
_weather["{windkmh}"] = math.ceil(_weather["{windmph}"] * 1.6)
_weather["{windmph}"] = tonumber(_weather["{windmph}"])
_weather["{windkmh}"] = math.ceil(_weather["{windmph}"] * 1.6)
end -- Temperature in °C if °F was available
if _weather["{tempf}"] ~= "N/A" then
_weather["{tempf}"] = tonumber(_weather["{tempf}"])
_weather["{tempc}"] = math.ceil((_weather["{tempf}"] - 32) * 5/9)
_weather["{tempf}"] = tonumber(_weather["{tempf}"])
_weather["{tempc}"] = math.ceil((_weather["{tempf}"] - 32) * 5/9)
end -- Dew Point in °C if °F was available
if _weather["{dewf}"] ~= "N/A" then
_weather["{dewf}"] = tonumber(_weather["{dewf}"])
_weather["{dewc}"] = math.ceil((_weather["{dewf}"] - 32) * 5/9)
_weather["{dewf}"] = tonumber(_weather["{dewf}"])
_weather["{dewc}"] = math.ceil((_weather["{dewf}"] - 32) * 5/9)
end -- Capitalize some stats so they don't look so out of place
if _weather["{sky}"] ~= "N/A" then
_weather["{sky}"] = helpers.capitalize(_weather["{sky}"])
_weather["{sky}"] = helpers.capitalize(_weather["{sky}"])
end
if _weather["{weather}"] ~= "N/A" then
_weather["{weather}"] = helpers.capitalize(_weather["{weather}"])
_weather["{weather}"] = helpers.capitalize(_weather["{weather}"])
end
return _weather
@ -110,7 +128,9 @@ function weather_all.async(format, warg, callback)
-- Get weather forceast by the station ICAO code, from:
-- * US National Oceanic and Atmospheric Administration
local url = ("https://tgftp.nws.noaa.gov/data/observations/metar/decoded/%s.TXT"):format(warg)
local url = string.format(
"https://tgftp.nws.noaa.gov/data/observations/metar/decoded/%s.TXT",
warg)
spawn.easy_async("curl -fs " .. url,
function (...) callback(parse(...)) end)
end

View File

@ -1,7 +1,22 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- Wi-Fi widget type for GNU/Linux using iwconfig
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2018-2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local type = type
@ -12,7 +27,6 @@ local helpers = require"vicious.helpers"
local spawn = require"vicious.spawn"
-- }}}
-- Wifi: provides wireless information for a requested interface using iwconfig
-- vicious.widgets.wifi
local wifi_linux = {}

View File

@ -1,7 +1,23 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2016, Marius M. <mellich@gmx.net>
---------------------------------------------------
-- Wi-Fi widget type for GNU/Linux using iw
-- Copyright (C) 2016 Marius M. <mellich@gmx.net>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
-- Copyright (C) 2019 Xaver Hellauer <xaver@hellauer.bayern>
--
-- This file is part of Vicious.
--
-- Vicious is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 2 of the
-- License, or (at your option) any later version.
--
-- Vicious is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
-- {{{ Grab environment
local type = type
@ -11,7 +27,6 @@ local helpers = require("vicious.helpers")
local spawn = require("vicious.spawn")
-- }}}
-- Wifiiw: provides wireless information for a requested interface
-- using iw instead of deprecated iwconfig
-- vicious.widgets.wifiiw