Merge pull request #94 from vicious-widgets/copyright
Add copyright notices and contributing guidelines
This commit is contained in:
commit
eca31413bd
|
@ -6,6 +6,12 @@ read_globals = {
|
||||||
"timer", -- deprecated, but used in older versions.
|
"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
|
-- Warnings to be ignored
|
||||||
ignore = {
|
ignore = {
|
||||||
"212", -- Unused argument.
|
"212", -- Unused argument.
|
||||||
|
|
|
@ -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.
|
|
@ -1,4 +1,4 @@
|
||||||
# Changes in 2.4.0 (WIP)
|
# Changes in 2.4.0
|
||||||
|
|
||||||
IMPORTANT:
|
IMPORTANT:
|
||||||
|
|
||||||
|
@ -16,6 +16,11 @@ Added:
|
||||||
- `helpers.setasyncall` to avoid writing redundant workers for asynchronous
|
- `helpers.setasyncall` to avoid writing redundant workers for asynchronous
|
||||||
widget types. Note that these workers are only needed in case Vicious is used
|
widget types. Note that these workers are only needed in case Vicious is used
|
||||||
as a stand-alone library.
|
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:
|
Fixed:
|
||||||
|
|
||||||
|
@ -26,10 +31,12 @@ Fixed:
|
||||||
* bat_openbsd
|
* bat_openbsd
|
||||||
* volume, gmail, mdir, mpd, fs
|
* volume, gmail, mdir, mpd, fs
|
||||||
- [mpd] Lua 5.3 compatibility (for real this time); also correct a typo
|
- [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,weather,contrib/btc] Allow function call without Awesome
|
||||||
- [pkg] Use more updated front-ends for Debian/Ubuntu (apt) and Fedora (dnf)
|
- [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)
|
- [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
|
- Tweak `.luacheckrc` to suit functional style and soft-limit text width to 80
|
||||||
|
- Update copyright headers for libraries and widget types
|
||||||
|
|
||||||
Removed:
|
Removed:
|
||||||
|
|
||||||
|
|
111
README.md
111
README.md
|
@ -3,9 +3,7 @@
|
||||||
Vicious is a modular widget library for window managers, but mostly
|
Vicious is a modular widget library for window managers, but mostly
|
||||||
catering to users of the *awesome* window manager. It was derived from
|
catering to users of the *awesome* window manager. It was derived from
|
||||||
the old *Wicked* widget library, and has some of the old *Wicked* widget
|
the old *Wicked* widget library, and has some of the old *Wicked* widget
|
||||||
types, a few of them rewritten, and a good number of new ones:
|
types, a few of them rewritten, and a good number of new ones.
|
||||||
|
|
||||||
* https://github.com/vicious-widgets/vicious
|
|
||||||
|
|
||||||
Vicious widget types are a framework for creating your own
|
Vicious widget types are a framework for creating your own
|
||||||
widgets. Vicious contains modules that gather data about your system,
|
widgets. Vicious contains modules that gather data about your system,
|
||||||
|
@ -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
|
Lua libraries, but may depend on additional system utilities (see widget
|
||||||
description).
|
description).
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
When provided by an operating system package, or installed from source
|
When provided by an operating system package, or installed from source
|
||||||
into the Lua library path Vicious can be used as a regular Lua
|
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
|
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
|
```lua
|
||||||
> widgets = require("vicious.widgets.init")
|
> 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
|
100
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Usage within Awesome
|
## Usage within Awesome
|
||||||
|
|
||||||
To use Vicious with Awesome, install the package from your operating
|
To use Vicious with Awesome, install the package from your operating
|
||||||
|
@ -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`):
|
awesome configuration directory in `$XDG_CONFIG_HOME` (usually `~/.config`):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
$ git clone https://github.com/vicious-widgets/vicious.git
|
||||||
$ mv vicious $XDG_CONFIG_HOME/awesome/
|
$ 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")
|
local vicious = require("vicious")
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Register a widget
|
||||||
|
|
||||||
Once you create a widget (a textbox, graph or a progressbar) call
|
Once you create a widget (a textbox, graph or a progressbar) call
|
||||||
`vicious.register()` to register it with Vicious:
|
`vicious.register()` to register it with Vicious:
|
||||||
|
|
||||||
vicious.register(widget, wtype, format, interval, warg)
|
vicious.register(widget, wtype, format, interval, warg)
|
||||||
|
|
||||||
### widget
|
#### widget
|
||||||
|
|
||||||
*Awesome* widget created with `widget()` or `awful.widget()` (in case of a
|
*Awesome* widget created with `widget()` or `awful.widget()` (in case of a
|
||||||
graph or a progressbar).
|
graph or a progressbar).
|
||||||
|
|
||||||
### wtype
|
#### wtype
|
||||||
|
|
||||||
Type: Vicious widget or `function`:
|
Type: Vicious widget or `function`:
|
||||||
|
|
||||||
|
@ -66,7 +69,7 @@ Type: Vicious widget or `function`:
|
||||||
* function: custom function from your own *Awesome* configuration can be
|
* function: custom function from your own *Awesome* configuration can be
|
||||||
registered as widget types (see [Custom widget types](#custom-widget)).
|
registered as widget types (see [Custom widget types](#custom-widget)).
|
||||||
|
|
||||||
### format
|
#### format
|
||||||
|
|
||||||
Type: `string` or `function`:
|
Type: `string` or `function`:
|
||||||
|
|
||||||
|
@ -77,17 +80,15 @@ Type: `string` or `function`:
|
||||||
* `function (widget, args)` can be used to manipulate data returned by the
|
* `function (widget, args)` can be used to manipulate data returned by the
|
||||||
widget type (see [Format functions](#format-func)).
|
widget type (see [Format functions](#format-func)).
|
||||||
|
|
||||||
### interval
|
#### interval
|
||||||
|
|
||||||
Number of seconds between updates of the widget (default: 2). Read section
|
Number of seconds between updates of the widget (default: 2). Read section
|
||||||
[Power and Caching](#power) for more information.
|
[Power and Caching](#power) for more information.
|
||||||
|
|
||||||
### warg
|
#### warg
|
||||||
|
|
||||||
Some widget types require an argument to be passed, for example the battery ID.
|
Some widget types require an argument to be passed, for example the battery ID.
|
||||||
|
|
||||||
## Other functions
|
|
||||||
|
|
||||||
`vicious.register` alone is not much different from
|
`vicious.register` alone is not much different from
|
||||||
[awful.widget.watch](https://awesomewm.org/doc/api/classes/awful.widget.watch.html),
|
[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
|
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
|
Fetch data from `wtype` to use it outside from the wibox
|
||||||
([example](#call-example)).
|
([example](#call-example)).
|
||||||
|
|
||||||
|
|
||||||
## <a name="widgets"></a>Widget types
|
## <a name="widgets"></a>Widget types
|
||||||
|
|
||||||
Widget types consist of worker functions that take two arguments `format` and
|
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`
|
* Argument: an array including password, hostname and port in that order. `nil`
|
||||||
fields will be fallen back to default (`localhost:6600` without password).
|
fields will be fallen back to default (`localhost:6600` without password).
|
||||||
* Returns a table with string keys: `${volume}`, `${bitrate}`, `${elapsed}` (in seconds),
|
* Returns a table with string keys: `${volume}`, `${bitrate}`,
|
||||||
`${duration}` (in seconds), `${Elapsed}` (formatted as [hh:]mm:ss), `${Duration}` (formatted as [hh:]mm:ss),
|
`${elapsed}` (in seconds), `${duration}` (in seconds),
|
||||||
`${Progress}` (in percentage), ${random}`, `${repeat}`, `${state}`, `${Artist}`, `${Title}`, `${Album}`,
|
`${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}`.
|
`${Genre}` and optionally `${Name}` and `${file}`.
|
||||||
|
|
||||||
### vicious.widgets.net
|
### vicious.widgets.net
|
||||||
|
@ -560,6 +564,7 @@ Supported platforms: GNU/Linux.
|
||||||
`${rate}` (Mb/s), `${freq}` (MHz), `${linp}` (link quality in percent),
|
`${rate}` (Mb/s), `${freq}` (MHz), `${linp}` (link quality in percent),
|
||||||
`${txpw}` (transmission power, in dBm) and `${sign}` (signal level, in dBm)
|
`${txpw}` (transmission power, in dBm) and `${sign}` (signal level, in dBm)
|
||||||
|
|
||||||
|
|
||||||
## <a name="custom-widget"></a>Custom widget types
|
## <a name="custom-widget"></a>Custom widget types
|
||||||
|
|
||||||
Use any of the existing widget types as a starting point for your
|
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
|
file with their GPG key. Trough the GPG Passphrase Agent they could
|
||||||
then decrypt the file transparently while their session is active.
|
then decrypt the file transparently while their session is active.
|
||||||
|
|
||||||
|
|
||||||
## Usage examples
|
## Usage examples
|
||||||
|
|
||||||
Start with a simple widget, like `date`. Then build your setup from
|
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)
|
vicious.register(cpuwidget, vicious.widgets.cpu, "$1", 3)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## <a name="format-func"></a>Format functions
|
## <a name="format-func"></a>Format functions
|
||||||
|
|
||||||
You can use a function instead of a string as the format parameter.
|
You can use a function instead of a string as the format parameter.
|
||||||
|
@ -863,6 +870,7 @@ mybattery:buttons(awful.util.table.join(
|
||||||
end)))
|
end)))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
* Manual pages: [awesome(1)](https://awesomewm.org/doc/manpages/awesome),
|
* Manual pages: [awesome(1)](https://awesomewm.org/doc/manpages/awesome),
|
||||||
|
@ -872,6 +880,15 @@ mybattery:buttons(awful.util.table.join(
|
||||||
(outdated)
|
(outdated)
|
||||||
* [My first awesome](https://awesomewm.org/doc/api/documentation/07-my-first-awesome.md.html)
|
* [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
|
## Authors
|
||||||
|
|
||||||
Wicked was written by:
|
Wicked was written by:
|
||||||
|
@ -889,15 +906,63 @@ Current maintainers:
|
||||||
* Daniel Hahler (blueyed) \<github thequod.de\>
|
* Daniel Hahler (blueyed) \<github thequod.de\>
|
||||||
* Nguyễn Gia Phong (McSinyx) \<vn.mcsinyx gmail.com\>
|
* Nguyễn Gia Phong (McSinyx) \<vn.mcsinyx gmail.com\>
|
||||||
|
|
||||||
Vicious major contributors:
|
Contributors, listed in alphabetic order:
|
||||||
|
|
||||||
* Benedikt Sauer \<filmor gmail.com\>
|
* 0x5b \<dragen15051 gmail.com\>
|
||||||
* Greg D. \<jabbas jabbas.pl\>
|
* Adam Lee \<adam8157 gmail.com\>
|
||||||
* Henning Glawe \<glaweh debian.org\>
|
* Alexander Koch \<lynix47 gmail.com\>
|
||||||
* Rémy C. \<shikamaru mandriva.org\>
|
* Amir Mohammad Saied \<amirsaied gmail.com\>
|
||||||
* Hiltjo Posthuma \<hiltjo codemadness.org\>
|
* Andrea Scarpino \<me andreascarpino.it\>
|
||||||
* Hagen Schink \<troja84 googlemail.com\>
|
* 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\>
|
* 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\>
|
* Dodo The Last \<dodo.the.last gmail.com\>
|
||||||
* …
|
* Elric Milon \<whirm gmx.com\>
|
||||||
* Consult git log for a complete list of contributors
|
* 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
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/ac_linux.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2012 jinleileiking <jinleileiking@gmail.com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/ati_linux.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2013 NormalRa <normalrawr gmail com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/batpmu_linux.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/batproc_linux.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
---------------------------------------------------
|
-- contrib/btc_all.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2017 0x5b <dragen15051@gmail.com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local pcall = pcall
|
local pcall = pcall
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/buildbot_all.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2012 Andrzje Bieniek <andyhelp@gmail.com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
|
|
@ -1,7 +1,20 @@
|
||||||
---------------------------------------------------
|
-- contrib/countfiles_all.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||||
---------------------------------------------------
|
--
|
||||||
-- * (c) 2010, Jörg. T <jthalheim@mail.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
|
-- {{{ Grab environment
|
||||||
local io = { popen = io.popen }
|
local io = { popen = io.popen }
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/dio_linux.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010, Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
|
|
|
@ -1,9 +1,22 @@
|
||||||
---------------------------------------------------
|
-- contrib/init.lua
|
||||||
-- Vicious widgets for the awesome window manager
|
-- Copyright (C) 2010-2012 Adrian C. (anrxc) <anrxc@sysphere.org>
|
||||||
---------------------------------------------------
|
-- Copyright (C) 2011 Joerg T. (Mic92) <jthalheim@gmail.com>
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2012 Arvydas Sidorenko <asido4@gmail.com>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
--
|
||||||
---------------------------------------------------
|
-- 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
|
-- {{{ Setup environment
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
|
|
@ -1,8 +1,23 @@
|
||||||
---------------------------------------------------
|
-- contrib/mpc_all.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
|
-- 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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
|
|
|
@ -1,9 +1,24 @@
|
||||||
---------------------------------------------------
|
-- contrib/net_linux.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 Henning Glawe <glaweh@debian.org>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (c) 2009, Henning Glawe <glaweh@debian.org>
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
|
-- 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
|
-- {{{ Grab environment
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
---------------------------------------------------
|
-- contrib/netcfg.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Radu A. <admiral0@tuxfamily.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local io = { popen = io.popen }
|
local io = { popen = io.popen }
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/nvinf_all.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2015 Ziyuan Guo <s10e.cn@gmail.com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/nvsmi_all.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2014 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/openweather_all.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2013 NormalRa <normalrawr gmail com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/ossvol_linux.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -1,7 +1,23 @@
|
||||||
---------------------------------------------------
|
-- contrib/pop_all.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (c) 2010 Boris Bolgradov
|
||||||
-- * (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.
|
-- This widget type depends on luasocket.
|
||||||
--
|
--
|
||||||
-- Widget arguments are host, port, username and
|
-- Widget arguments are host, port, username and
|
||||||
|
|
|
@ -1,8 +1,22 @@
|
||||||
---------------------------------------------------
|
-- contrib/pulse_all.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 MrMagne <mr.magne@yahoo.fr>
|
||||||
-- * (c) 2010, MrMagne <mr.magne@yahoo.fr>
|
-- Copyright (C) 2010,2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||||
-- * (c) 2010, Mic92 <jthalheim@gmail.com>
|
-- 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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
|
|
|
@ -1,7 +1,23 @@
|
||||||
---------------------------------------------------
|
-- contrib/rss_all.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 olcc
|
||||||
-- * (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:
|
-- This is now a standalone RSS reader for awesome:
|
||||||
-- * http://github.com/olcc/aware
|
-- * http://github.com/olcc/aware
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/sensors_linux.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Greg D. <jabbas@jabbas.pl>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
---------------------------------------------------
|
-- contrib/wpa_all.lua
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2012 jinleileiking <jinleileiking@gmail.com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -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
|
48
helpers.lua
48
helpers.lua
|
@ -1,12 +1,34 @@
|
||||||
---------------------------------------------------
|
-- helper functions
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 Benedikt Sauer <filmor@gmail.com>
|
||||||
-- * (c) 2019, Enric Morales <me@enric.me>
|
-- Copyright (C) 2009 Henning Glawe <glaweh@debian.org>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (c) 2009, Rémy C. <shikamaru@mandriva.org>
|
-- Copyright (C) 2009 Rémy C. <shikamaru@mandriva.org>
|
||||||
-- * (c) 2009, Benedikt Sauer <filmor@gmail.com>
|
-- Copyright (C) 2009-2012 Adrian C. (anrxc) <anrxc@sysphere.org>
|
||||||
-- * (c) 2009, Henning Glawe <glaweh@debian.org>
|
-- Copyright (C) 2011 Joerg T. (Mic92) <jthalheim@gmail.com>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.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
|
-- {{{ Grab environment
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
|
@ -101,6 +123,13 @@ function helpers.wrequire(collection, key)
|
||||||
end
|
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
|
-- {{{ Set __call metamethod to widget type table having async key
|
||||||
function helpers.setasyncall(wtype)
|
function helpers.setasyncall(wtype)
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
|
@ -277,5 +306,4 @@ end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return helpers
|
return helpers
|
||||||
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
49
init.lua
49
init.lua
|
@ -1,16 +1,41 @@
|
||||||
---------------------------------------------------
|
-- Vicious module initialization
|
||||||
-- Vicious widgets for the awesome window manager
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
---------------------------------------------------
|
-- Copyright (C) 2009-2013 Adrian C. (anrxc) <anrxc@sysphere.org>
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2011 Joerg T. (Mic92) <jthalheim@gmail.com>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2012 Arvydas Sidorenko <asido4@gmail.com>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.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
|
-- {{{ Setup environment
|
||||||
local type = type
|
local type = type
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local tonumber = tonumber
|
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 os = { time = os.time }
|
||||||
local table = {
|
local table = {
|
||||||
insert = table.insert,
|
insert = table.insert,
|
||||||
|
@ -69,20 +94,22 @@ local function update(widget, reg, disablecache)
|
||||||
return ret or data
|
return ret or data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function topercent(e) return tonumber(e) and tonumber(e) / 100 end
|
||||||
|
|
||||||
local function update_value(data)
|
local function update_value(data)
|
||||||
local fmtd_data = format_data(data)
|
local fmtd_data = format_data(data)
|
||||||
if widget.add_value ~= nil then
|
if widget.add_value ~= nil then
|
||||||
if widget.get_stack ~= nil and widget:get_stack() then
|
if widget.get_stack ~= nil and widget:get_stack() then
|
||||||
for idx, _ in ipairs(widget:get_stack_colors()) do
|
for idx, _ in ipairs(widget:get_stack_colors()) do
|
||||||
if fmtd_data[idx] then
|
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
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
widget:add_value(tonumber(fmtd_data) and tonumber(fmtd_data)/100)
|
widget:add_value(topercent(fmtd_data))
|
||||||
end
|
end
|
||||||
elseif widget.set_value ~= nil then
|
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
|
elseif widget.set_markup ~= nil then
|
||||||
widget:set_markup(fmtd_data)
|
widget:set_markup(fmtd_data)
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
-- spawn.lua - wrapper around Awesome awful.spawn with fallback
|
-- wrapper around Awesome awful.spawn with fallback
|
||||||
-- Copyright (C) 2019 Nguyễn Gia Phong
|
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
|
||||||
--
|
--
|
||||||
-- This file is part of Vicious.
|
-- This file is part of Vicious.
|
||||||
--
|
--
|
||||||
|
@ -11,9 +11,9 @@
|
||||||
-- Vicious is distributed in the hope that it will be useful,
|
-- Vicious is distributed in the hope that it will be useful,
|
||||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
-- 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/>.
|
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
local status, awful = pcall(require, "awful")
|
local status, awful = pcall(require, "awful")
|
||||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor }
|
||||||
|
|
|
@ -1,28 +1,38 @@
|
||||||
---------------------------------------------------
|
-- battery widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2013 NormalRa <normalrawr@gmail.com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local setmetatable = setmetatable
|
|
||||||
local string = { format = string.format }
|
local string = { format = string.format }
|
||||||
local helpers = require("vicious.helpers")
|
|
||||||
local math = {
|
local math = {
|
||||||
min = math.min,
|
min = math.min,
|
||||||
floor = math.floor
|
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
|
-- {{{ Battery widget type
|
||||||
local function worker(format, warg)
|
return helpers.setcall(function (format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
local battery = helpers.pathtotable("/sys/class/power_supply/"..warg)
|
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}
|
return {battery_state["Unknown\n"], 0, "N/A", 0, curpower}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Get state information
|
-- Get state information
|
||||||
local state = battery_state[battery.status] or battery_state["Unknown\n"]
|
local state = battery_state[battery.status] or battery_state["Unknown\n"]
|
||||||
|
|
||||||
-- Get capacity information
|
-- Get capacity information
|
||||||
|
local remaining, capacity, capacity_design
|
||||||
if battery.charge_now then
|
if battery.charge_now then
|
||||||
remaining, capacity = battery.charge_now, battery.charge_full
|
remaining, capacity = battery.charge_now, battery.charge_full
|
||||||
capacity_design = battery.charge_full_design or capacity
|
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 percent = math.min(math.floor(remaining / capacity * 100), 100)
|
||||||
local wear = math.floor(100 - capacity / capacity_design * 100)
|
local wear = math.floor(100 - capacity / capacity_design * 100)
|
||||||
|
|
||||||
|
|
||||||
-- Get charge information
|
-- Get charge information
|
||||||
|
local rate
|
||||||
if battery.current_now then
|
if battery.current_now then
|
||||||
rate = tonumber(battery.current_now)
|
rate = tonumber(battery.current_now)
|
||||||
elseif battery.power_now then
|
elseif battery.power_now then
|
||||||
|
@ -78,6 +88,7 @@ local function worker(format, warg)
|
||||||
local time = "N/A"
|
local time = "N/A"
|
||||||
|
|
||||||
if rate ~= nil and rate ~= 0 then
|
if rate ~= nil and rate ~= 0 then
|
||||||
|
local timeleft
|
||||||
if state == "+" then
|
if state == "+" then
|
||||||
timeleft = (tonumber(capacity)-tonumber(remaining)) / tonumber(rate)
|
timeleft = (tonumber(capacity)-tonumber(remaining)) / tonumber(rate)
|
||||||
elseif state == "-" then
|
elseif state == "-" then
|
||||||
|
@ -94,7 +105,5 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {state, percent, time, wear, curpower}
|
return {state, percent, time, wear, curpower}
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(bat_linux, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
-- bat_openbsd.lua - provide battery information on OpenBSD
|
-- battery widget type for OpenBSD
|
||||||
-- Copyright (C) 2019 Enric Morales
|
-- Copyright (C) 2019 Enric Morales <me@enric.me>
|
||||||
-- Copyright (C) 2019 Nguyễn Gia Phong
|
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
|
||||||
--
|
--
|
||||||
-- This file is part of Vicious.
|
-- This file is part of Vicious.
|
||||||
--
|
--
|
||||||
|
@ -12,9 +12,9 @@
|
||||||
-- Vicious is distributed in the hope that it will be useful,
|
-- Vicious is distributed in the hope that it will be useful,
|
||||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
-- 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/>.
|
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
-- {{{ Grab environment
|
-- {{{ Grab environment
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
-----------------------------------------------------------
|
-- cmus music player widget type
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2017 JuanKman94 <juan.carlos.menonita@gmail.com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
|
|
|
@ -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
|
-- {{{ Grab environment
|
||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor }
|
||||||
local string = { gmatch = string.gmatch }
|
local string = { gmatch = string.gmatch }
|
||||||
|
@ -5,7 +24,6 @@ local string = { gmatch = string.gmatch }
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Cpu: provides CPU usage for all available CPUs/cores
|
-- Cpu: provides CPU usage for all available CPUs/cores
|
||||||
-- vicious.widgets.cpu_freebsd
|
-- vicious.widgets.cpu_freebsd
|
||||||
local cpu_freebsd = {}
|
local cpu_freebsd = {}
|
||||||
|
|
|
@ -1,35 +1,44 @@
|
||||||
---------------------------------------------------
|
-- CPU usage widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (c) 2011, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2011 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
|
-- Copyright (C) 2011 Jörg Thalheim <jthalheim@gmail.com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local io = { open = io.open }
|
local io = { open = io.open }
|
||||||
local setmetatable = setmetatable
|
|
||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor }
|
||||||
local table = { insert = table.insert }
|
local table = { insert = table.insert }
|
||||||
local string = {
|
local string = {
|
||||||
sub = string.sub,
|
sub = string.sub,
|
||||||
gmatch = string.gmatch
|
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
|
-- Initialize function tables
|
||||||
local cpu_usage = {}
|
local cpu_usage = {}
|
||||||
local cpu_total = {}
|
local cpu_total = {}
|
||||||
local cpu_active = {}
|
local cpu_active = {}
|
||||||
|
|
||||||
-- {{{ CPU widget type
|
-- {{{ CPU widget type
|
||||||
local function worker(format)
|
return helpers.setcall(function ()
|
||||||
local cpu_lines = {}
|
local cpu_lines = {}
|
||||||
|
|
||||||
-- Get CPU stats
|
-- Get CPU stats
|
||||||
|
@ -52,7 +61,6 @@ local function worker(format)
|
||||||
cpu_active[i] = 0
|
cpu_active[i] = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
for i, v in ipairs(cpu_lines) do
|
for i, v in ipairs(cpu_lines) do
|
||||||
-- Calculate totals
|
-- Calculate totals
|
||||||
local total_new = 0
|
local total_new = 0
|
||||||
|
@ -74,7 +82,5 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
|
|
||||||
return cpu_usage
|
return cpu_usage
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(cpu_linux, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
||||||
-- vicious.widgets.cpufreq
|
-- vicious.widgets.cpufreq
|
||||||
local cpufreq_freebsd = {}
|
local cpufreq_freebsd = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ CPU frequency widget type
|
-- {{{ CPU frequency widget type
|
||||||
function cpufreq_freebsd.async(format, warg, callback)
|
function cpufreq_freebsd.async(format, warg, callback)
|
||||||
if not warg then return callback({}) end
|
if not warg then return callback({}) end
|
||||||
|
|
|
@ -1,33 +1,41 @@
|
||||||
---------------------------------------------------
|
-- CPU frequency widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local setmetatable = setmetatable
|
|
||||||
local string = { match = string.match }
|
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
local GOVERNOR_STATE = {
|
||||||
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
|
||||||
-- vicious.widgets.cpufreq
|
|
||||||
local cpufreq_linux = {}
|
|
||||||
|
|
||||||
|
|
||||||
-- {{{ CPU frequency widget type
|
|
||||||
local function worker(format, warg)
|
|
||||||
if not warg then return end
|
|
||||||
|
|
||||||
local _cpufreq = helpers.pathtotable("/sys/devices/system/cpu/"..warg.."/cpufreq")
|
|
||||||
local governor_state = {
|
|
||||||
["ondemand\n"] = "↯",
|
["ondemand\n"] = "↯",
|
||||||
["powersave\n"] = "⌁",
|
["powersave\n"] = "⌁",
|
||||||
["userspace\n"] = "¤",
|
["userspace\n"] = "¤",
|
||||||
["performance\n"] = "⚡",
|
["performance\n"] = "⚡",
|
||||||
["conservative\n"] = "⊚"
|
["conservative\n"] = "⊚"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- {{{ CPU frequency widget type
|
||||||
|
return helpers.setcall(function (format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
|
||||||
|
local _cpufreq = helpers.pathtotable(
|
||||||
|
("/sys/devices/system/cpu/%s/cpufreq"):format(warg))
|
||||||
-- Default frequency and voltage values
|
-- Default frequency and voltage values
|
||||||
local freqv = {
|
local freqv = {
|
||||||
["mhz"] = "N/A", ["ghz"] = "N/A",
|
["mhz"] = "N/A", ["ghz"] = "N/A",
|
||||||
|
@ -43,7 +51,8 @@ local function worker(format, warg)
|
||||||
|
|
||||||
-- Get the current voltage
|
-- Get the current voltage
|
||||||
if _cpufreq.scaling_voltages then
|
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
|
-- Calculate voltage from mV
|
||||||
freqv.v = freqv.mv / 1000
|
freqv.v = freqv.mv / 1000
|
||||||
end
|
end
|
||||||
|
@ -52,10 +61,8 @@ local function worker(format, warg)
|
||||||
-- Get the current governor
|
-- Get the current governor
|
||||||
local governor = _cpufreq.scaling_governor
|
local governor = _cpufreq.scaling_governor
|
||||||
-- Represent the governor as a symbol
|
-- 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}
|
return {freqv.mhz, freqv.ghz, freqv.mv, freqv.v, governor}
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(cpufreq_linux, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -1,23 +1,31 @@
|
||||||
---------------------------------------------------
|
-- CPU information widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local io = { lines = io.lines }
|
local io = { lines = io.lines }
|
||||||
local setmetatable = setmetatable
|
|
||||||
local string = { gmatch = string.gmatch }
|
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
|
-- {{{ CPU Information widget type
|
||||||
local function worker(format)
|
return helpers.setcall(function ()
|
||||||
local id = nil
|
local id = nil
|
||||||
|
|
||||||
local cpu_info = {} -- Get CPU info
|
local cpu_info = {} -- Get CPU info
|
||||||
|
@ -38,7 +46,5 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
|
|
||||||
return cpu_info
|
return cpu_info
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(cpuinf_linux, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -1,27 +1,29 @@
|
||||||
---------------------------------------------------
|
-- date and time widget type using os.date with optional time formatting
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.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
|
-- {{{ Grab environment
|
||||||
local setmetatable = setmetatable
|
local os = { date = os.date, time = os.time }
|
||||||
local os = {
|
local helpers = require"vicious.helpers"
|
||||||
date = os.date,
|
|
||||||
time = os.time
|
|
||||||
}
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
return helpers.setcall(function (format, warg)
|
||||||
-- 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 os.date(format or nil, warg and os.time()+warg or nil)
|
return os.date(format or nil, warg and os.time()+warg or nil)
|
||||||
end
|
end)
|
||||||
-- }}}
|
|
||||||
|
|
||||||
return setmetatable(date_all, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -1,26 +1,31 @@
|
||||||
---------------------------------------------------
|
-- disk I/O widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2011 Jörg T. <jthalheim@gmail.com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local io = { lines = io.lines }
|
local io = { lines = io.lines }
|
||||||
local setmetatable = setmetatable
|
local os = { time = os.time, difftime = os.difftime }
|
||||||
local string = { match = string.match }
|
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require"vicious.helpers"
|
||||||
local os = {
|
|
||||||
time = os.time,
|
|
||||||
difftime = os.difftime
|
|
||||||
}
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Disk I/O: provides I/O statistics for requested storage devices
|
|
||||||
-- vicious.widgets.dio
|
|
||||||
local dio_linux = {}
|
|
||||||
|
|
||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
local disk_usage = {}
|
local disk_usage = {}
|
||||||
local disk_stats = {}
|
local disk_stats = {}
|
||||||
|
@ -30,13 +35,13 @@ local unit = { ["s"] = 1, ["kb"] = 2, ["mb"] = 2048 }
|
||||||
local time_unit = { ["ms"] = 1, ["s"] = 1000 }
|
local time_unit = { ["ms"] = 1, ["s"] = 1000 }
|
||||||
|
|
||||||
-- {{{ Disk I/O widget type
|
-- {{{ Disk I/O widget type
|
||||||
local function worker(format)
|
return helpers.setcall(function ()
|
||||||
local disk_lines = {}
|
local disk_lines = {}
|
||||||
|
|
||||||
for line in io.lines("/proc/diskstats") do
|
for line in io.lines("/proc/diskstats") do
|
||||||
local device, read, write, iotime =
|
local device, read, write, iotime =
|
||||||
-- Linux kernel documentation: Documentation/iostats.txt
|
-- 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 }
|
disk_lines[device] = { read, write, iotime }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,7 +55,7 @@ local function worker(format)
|
||||||
|
|
||||||
-- Check for overflows and counter resets (> 2^32)
|
-- Check for overflows and counter resets (> 2^32)
|
||||||
if stats[1] < last_stats[1] or stats[2] < last_stats[2] then
|
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
|
end
|
||||||
|
|
||||||
-- Diskstats are absolute, substract our last reading
|
-- Diskstats are absolute, substract our last reading
|
||||||
|
@ -70,7 +75,5 @@ local function worker(format)
|
||||||
disk_stats = disk_lines
|
disk_stats = disk_lines
|
||||||
|
|
||||||
return disk_usage
|
return disk_usage
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(dio_linux, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -5,7 +24,6 @@ local type = type
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- fanspeed: provides speed level of fans
|
-- fanspeed: provides speed level of fans
|
||||||
-- vicious.widgets.fanspeed
|
-- vicious.widgets.fanspeed
|
||||||
--
|
--
|
||||||
|
|
|
@ -1,8 +1,24 @@
|
||||||
---------------------------------------------------
|
-- filesystem widget type
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
|
-- 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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -1,7 +1,23 @@
|
||||||
---------------------------------------------------
|
-- new e-mails count and last e-mail subject on Gmail
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -12,7 +28,6 @@ local helpers = require("vicious.helpers")
|
||||||
local spawn = require("vicious.spawn")
|
local spawn = require("vicious.spawn")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Gmail: provides count of new and subject of last e-mail on Gmail
|
-- Gmail: provides count of new and subject of last e-mail on Gmail
|
||||||
-- vicious.widgets.gmail
|
-- vicious.widgets.gmail
|
||||||
local gmail_all = {}
|
local gmail_all = {}
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
---------------------------------------------------
|
-- hard drive temperatures widget type using hddtemp daemon
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
@ -10,7 +25,6 @@ local helpers = require"vicious.helpers"
|
||||||
local spawn = require"vicious.spawn"
|
local spawn = require"vicious.spawn"
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
|
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
|
||||||
-- vicious.widgets.hddtemp
|
-- vicious.widgets.hddtemp
|
||||||
return helpers.setasyncall{
|
return helpers.setasyncall{
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
----------------------------------------------------------------
|
-- widget type providing name-indexed temperatures from /sys/class/hwmon
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2019 Alexander Koch <lynix47@gmail.com>
|
||||||
-- (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
|
-- environment
|
||||||
local type = type
|
local type = type
|
||||||
|
|
|
@ -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
|
local wrequire = require("vicious.helpers").wrequire
|
||||||
widgets = { _NAME = "vicious.widgets" }
|
|
||||||
|
|
||||||
return setmetatable(widgets, {__index = wrequire})
|
return setmetatable({ _NAME = "vicious.widgets" }, { __index = wrequire })
|
||||||
|
|
|
@ -1,41 +1,45 @@
|
||||||
---------------------------------------------------
|
-- widget type providing the subject of last e-mail in a mbox file
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
local io = { open = io.open }
|
local io = { open = io.open }
|
||||||
local setmetatable = setmetatable
|
|
||||||
local string = { gfind = string.gfind }
|
|
||||||
local helpers = require("vicious.helpers")
|
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
|
-- Initialize variables
|
||||||
local subject = "N/A"
|
local subject = "N/A"
|
||||||
|
|
||||||
-- {{{ Mailbox widget type
|
-- {{{ Mailbox widget type
|
||||||
local function worker(format, warg)
|
return helpers.setcall(function (format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
-- mbox could be huge, get a 30kb chunk from EOF
|
local f = io.open(type(warg) == "table" and warg[1] or warg)
|
||||||
if type(warg) ~= "table" then _mbox = warg end
|
|
||||||
-- * attachment could be much bigger than 30kb
|
|
||||||
local f = io.open(_mbox or warg[1])
|
|
||||||
f:seek("end", -30720)
|
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")
|
local txt = f:read("*all")
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
-- Find all Subject lines
|
-- Find all Subject lines
|
||||||
for i in string.gfind(txt, "Subject: ([^\n]*)") do
|
for i in txt:gmatch"Subject: ([^\n]*)" do subject = i end
|
||||||
subject = i
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Check if we should scroll, or maybe truncate
|
-- Check if we should scroll, or maybe truncate
|
||||||
if type(warg) == "table" then
|
if type(warg) == "table" then
|
||||||
|
@ -47,7 +51,5 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
|
|
||||||
return { subject }
|
return { subject }
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(mbox_all, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -1,22 +1,29 @@
|
||||||
---------------------------------------------------
|
-- widget type providing the count of total, old and new messages in mbox files
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local io = { open = io.open }
|
local io = { open = io.open }
|
||||||
local setmetatable = setmetatable
|
local helpers = require"vicious.helpers"
|
||||||
local string = { find = string.find }
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Mboxc: provides the count of total, old and new messages in mbox files
|
|
||||||
-- vicious.widgets.mboxc
|
|
||||||
local mboxc_all = {}
|
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Mbox count widget type
|
-- {{{ Mbox count widget type
|
||||||
local function worker(format, warg)
|
return helpers.setcall(function (format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
-- Initialize counters
|
-- Initialize counters
|
||||||
|
@ -34,15 +41,15 @@ local function worker(format, warg)
|
||||||
|
|
||||||
-- Find all messages
|
-- Find all messages
|
||||||
-- * http://www.jwz.org/doc/content-length.html
|
-- * 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
|
if from ~= nil then count.total = count.total + 1 end
|
||||||
|
|
||||||
-- Read messages have the Status header
|
-- 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
|
if status ~= nil then count.old = count.old + 1 end
|
||||||
|
|
||||||
-- Skip the folder internal data
|
-- 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
|
if int ~= nil then count.total = count.total - 1 end
|
||||||
end
|
end
|
||||||
f:close()
|
f:close()
|
||||||
|
@ -52,7 +59,5 @@ local function worker(format, warg)
|
||||||
count.new = count.total - count.old
|
count.new = count.total - count.old
|
||||||
|
|
||||||
return {count.total, count.old, count.new}
|
return {count.total, count.old, count.new}
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(mboxc_all, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -1,8 +1,23 @@
|
||||||
---------------------------------------------------
|
-- widget type providing number of new and unread Maildir messages
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2010 Fredrik Ax
|
||||||
-- * (c) Maildir Biff Widget, 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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -11,12 +26,9 @@ local helpers = require"vicious.helpers"
|
||||||
local spawn = require"vicious.spawn"
|
local spawn = require"vicious.spawn"
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Mdir: provides the number of new and unread messages in Maildir structures/dirs
|
|
||||||
-- vicious.widgets.mdir
|
-- vicious.widgets.mdir
|
||||||
local mdir_all = {}
|
local mdir_all = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Maildir widget type
|
-- {{{ Maildir widget type
|
||||||
function mdir_all.async(format, warg, callback)
|
function mdir_all.async(format, warg, callback)
|
||||||
if type(warg) ~= "table" then return callback{} end
|
if type(warg) ~= "table" then return callback{} end
|
||||||
|
|
|
@ -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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor }
|
||||||
|
|
|
@ -1,24 +1,33 @@
|
||||||
---------------------------------------------------
|
-- RAM and swap usage widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local io = { lines = io.lines }
|
local io = { lines = io.lines }
|
||||||
local setmetatable = setmetatable
|
|
||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor }
|
||||||
local string = { gmatch = string.gmatch }
|
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
|
-- {{{ Memory widget type
|
||||||
local function worker(format)
|
return helpers.setcall(function ()
|
||||||
local _mem = { buf = {}, swp = {} }
|
local _mem = { buf = {}, swp = {} }
|
||||||
|
|
||||||
-- Get MEM info
|
-- Get MEM info
|
||||||
|
@ -47,7 +56,5 @@ local function worker(format)
|
||||||
return {_mem.usep, _mem.inuse, _mem.total, _mem.free,
|
return {_mem.usep, _mem.inuse, _mem.total, _mem.free,
|
||||||
_mem.swp.usep, _mem.swp.inuse, _mem.swp.t, _mem.swp.f,
|
_mem.swp.usep, _mem.swp.inuse, _mem.swp.t, _mem.swp.f,
|
||||||
_mem.bcuse }
|
_mem.bcuse }
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(mem_linux, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -1,7 +1,25 @@
|
||||||
---------------------------------------------------
|
-- Music Player Daemon widget type
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
@ -12,7 +30,6 @@ local helpers = require"vicious.helpers"
|
||||||
local spawn = require"vicious.spawn"
|
local spawn = require"vicious.spawn"
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Mpd: provides Music Player Daemon information
|
-- Mpd: provides Music Player Daemon information
|
||||||
-- vicious.widgets.mpd
|
-- vicious.widgets.mpd
|
||||||
local mpd_all = {}
|
local mpd_all = {}
|
||||||
|
|
|
@ -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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local os = { time = os.time }
|
local os = { time = os.time }
|
||||||
|
|
|
@ -1,24 +1,31 @@
|
||||||
---------------------------------------------------
|
-- network status and usage widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local os = { time = os.time }
|
local os = { time = os.time }
|
||||||
local io = { lines = io.lines }
|
local io = { lines = io.lines }
|
||||||
local setmetatable = setmetatable
|
|
||||||
local string = { match = string.match }
|
local string = { match = string.match }
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Net: provides state and usage statistics of all network interfaces
|
|
||||||
-- vicious.widgets.net
|
|
||||||
local net_linux = {}
|
|
||||||
|
|
||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
local nets = {}
|
local nets = {}
|
||||||
-- Variable definitions
|
-- Variable definitions
|
||||||
|
@ -27,7 +34,7 @@ local unit = { ["b"] = 1, ["kb"] = 1024,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- {{{ Net widget type
|
-- {{{ Net widget type
|
||||||
local function worker(format)
|
return helpers.setcall(function ()
|
||||||
local args = {}
|
local args = {}
|
||||||
|
|
||||||
-- Get NET stats
|
-- Get NET stats
|
||||||
|
@ -74,7 +81,5 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
|
|
||||||
return args
|
return args
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(net_linux, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -1,31 +1,36 @@
|
||||||
---------------------------------------------------
|
-- widget type providing agenda from Emacs org-mode
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2010 org-awesome, Damien Leone
|
||||||
-- * (c) 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
|
-- {{{ Grab environment
|
||||||
local io = { lines = io.lines }
|
local io = { lines = io.lines }
|
||||||
local setmetatable = setmetatable
|
local os = { time = os.time, date = os.date }
|
||||||
local string = { find = string.find }
|
local helpers = require"vicious.helpers"
|
||||||
local os = {
|
|
||||||
time = os.time,
|
|
||||||
date = os.date
|
|
||||||
}
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Org: provides agenda statistics for Emacs org-mode
|
|
||||||
-- vicious.widgets.org
|
|
||||||
local org_all = {}
|
|
||||||
|
|
||||||
|
|
||||||
-- {{{ OrgMode widget type
|
-- {{{ OrgMode widget type
|
||||||
local function worker(format, warg)
|
return helpers.setcall(function (format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
-- Compute delays
|
-- Compute delays
|
||||||
local today = os.time{ year=os.date("%Y"), month=os.date("%m"), day=os.date("%d") }
|
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 soon = today + 24*3600*3 -- 3 days ahead is close
|
||||||
local future = today + 24*3600*7 -- 7 days ahead is maximum
|
local future = today + 24*3600*7 -- 7 days ahead is maximum
|
||||||
|
|
||||||
|
@ -35,28 +40,26 @@ local function worker(format, warg)
|
||||||
-- Get data from agenda files
|
-- Get data from agenda files
|
||||||
for i = 1,#warg do
|
for i = 1,#warg do
|
||||||
for line in io.lines(warg[i]) do
|
for line in io.lines(warg[i]) do
|
||||||
local scheduled = string.find(line, "SCHEDULED:")
|
local scheduled = line:find"SCHEDULED:"
|
||||||
local closed = string.find(line, "CLOSED:")
|
local deadline = line:find"DEADLINE:"
|
||||||
local deadline = string.find(line, "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
|
if (scheduled or deadline) and not closed and b 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 }
|
local t = os.time{ year = y, month = m, day = d }
|
||||||
|
if t < today then
|
||||||
if t < today then count.past = count.past + 1
|
count.past = count.past + 1
|
||||||
elseif t == today then count.today = count.today + 1
|
elseif t == today then
|
||||||
elseif t <= soon then count.soon = count.soon + 1
|
count.today = count.today + 1
|
||||||
elseif t <= future then count.future = count.future + 1
|
elseif t <= soon then
|
||||||
end
|
count.soon = count.soon + 1
|
||||||
|
elseif t <= future then
|
||||||
|
count.future = count.future + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return { count.past, count.today, count.soon, count.future }
|
return { count.past, count.today, count.soon, count.future }
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(org_all, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -1,7 +1,20 @@
|
||||||
---------------------------------------------------
|
-- operating system widget type for *BSD
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2019 mutlusun <mutlusun@users.noreply.github.com>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
--
|
||||||
---------------------------------------------------
|
-- 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
|
-- {{{ Grab environment
|
||||||
local los = { getenv = os.getenv }
|
local los = { getenv = os.getenv }
|
||||||
|
@ -10,12 +23,10 @@ local helpers = require("vicious.helpers")
|
||||||
local spawn = require("vicious.spawn")
|
local spawn = require("vicious.spawn")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- OS: provides operating system information
|
-- OS: provides operating system information
|
||||||
-- vicious.widgets.os
|
-- vicious.widgets.os
|
||||||
local os_bsd = {}
|
local os_bsd = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Operating system widget type
|
-- {{{ Operating system widget type
|
||||||
local function parse(stdout, stderr, exitreason, exitcode)
|
local function parse(stdout, stderr, exitreason, exitcode)
|
||||||
local system = {
|
local system = {
|
||||||
|
|
|
@ -1,27 +1,35 @@
|
||||||
---------------------------------------------------
|
-- operating system widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local math = { ceil = math.ceil }
|
local math = { ceil = math.ceil }
|
||||||
local los = { getenv = os.getenv }
|
local los = { getenv = os.getenv }
|
||||||
local setmetatable = setmetatable
|
|
||||||
local string = { gsub = string.gsub }
|
local string = { gsub = string.gsub }
|
||||||
|
|
||||||
local helpers = require"vicious.helpers"
|
local helpers = require"vicious.helpers"
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- OS: provides operating system information
|
|
||||||
-- vicious.widgets.os
|
|
||||||
local os_linux = {}
|
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Operating system widget type
|
-- {{{ Operating system widget type
|
||||||
local function worker(format)
|
return helpers.setcall(function ()
|
||||||
local system = {
|
local system = {
|
||||||
["ostype"] = "N/A",
|
["ostype"] = "N/A",
|
||||||
["hostname"] = "N/A",
|
["hostname"] = "N/A",
|
||||||
|
@ -54,8 +62,5 @@ local function worker(format)
|
||||||
|
|
||||||
return {system["ostype"], system["osrelease"], system["username"],
|
return {system["ostype"], system["osrelease"], system["username"],
|
||||||
system["hostname"], system["entropy"], system["entropy_p"]}
|
system["hostname"], system["entropy"], system["entropy_p"]}
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(os_linux,
|
|
||||||
{ __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -1,14 +1,30 @@
|
||||||
---------------------------------------------------
|
-- widget type providing number of pending updates
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local spawn = require("vicious.spawn")
|
local spawn = require("vicious.spawn")
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Pkg: provides number of pending updates on UNIX systems
|
-- Pkg: provides number of pending updates on UNIX systems
|
||||||
-- vicious.widgets.pkg
|
-- vicious.widgets.pkg
|
||||||
local pkg_all = {}
|
local pkg_all = {}
|
||||||
|
|
|
@ -1,30 +1,39 @@
|
||||||
-----------------------------------------------------
|
-- widget type providing RAID array information on GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Hagen Schink <troja84@googlemail.com>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local io = { open = io.open }
|
local io = { open = io.open }
|
||||||
local setmetatable = setmetatable
|
|
||||||
local string = {
|
local string = {
|
||||||
len = string.len,
|
len = string.len,
|
||||||
sub = string.sub,
|
sub = string.sub,
|
||||||
match = string.match,
|
match = string.match,
|
||||||
gmatch = string.gmatch
|
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
|
-- Initialize function tables
|
||||||
local mddev = {}
|
local mddev = {}
|
||||||
|
|
||||||
-- {{{ RAID widget type
|
-- {{{ RAID widget type
|
||||||
local function worker(format, warg)
|
return helpers.setcall(function (format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
mddev[warg] = {
|
mddev[warg] = {
|
||||||
["found"] = false,
|
["found"] = false,
|
||||||
|
@ -38,7 +47,7 @@ local function worker(format, warg)
|
||||||
if mddev[warg]["found"] then
|
if mddev[warg]["found"] then
|
||||||
local updev = string.match(line, "%[[_U]+%]")
|
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
|
mddev[warg]["active"] = mddev[warg]["active"] + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,7 +55,7 @@ local function worker(format, warg)
|
||||||
elseif string.sub(line, 1, string.len(warg)) == warg then
|
elseif string.sub(line, 1, string.len(warg)) == warg then
|
||||||
mddev[warg]["found"] = true
|
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
|
mddev[warg]["assigned"] = mddev[warg]["assigned"] + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -54,7 +63,5 @@ local function worker(format, warg)
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
return {mddev[warg]["assigned"], mddev[warg]["active"]}
|
return {mddev[warg]["assigned"], mddev[warg]["active"]}
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(raid_linux, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -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
|
-- {{{ Grab environment
|
||||||
local string = { match = string.match }
|
local string = { match = string.match }
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -5,7 +24,6 @@ local type = type
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Thermal: provides temperature levels of ACPI and coretemp thermal zones
|
-- Thermal: provides temperature levels of ACPI and coretemp thermal zones
|
||||||
-- vicious.widgets.thermal
|
-- vicious.widgets.thermal
|
||||||
local thermal_freebsd = {}
|
local thermal_freebsd = {}
|
||||||
|
|
|
@ -1,25 +1,32 @@
|
||||||
---------------------------------------------------
|
-- temperature widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local setmetatable = setmetatable
|
|
||||||
local string = { match = string.match }
|
local string = { match = string.match }
|
||||||
local helpers = require("vicious.helpers")
|
|
||||||
local math = { floor = math.floor }
|
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
|
-- {{{ Thermal widget type
|
||||||
local function worker(format, warg)
|
return helpers.setcall(function (format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
|
||||||
local zone = { -- Known temperature data sources
|
local zone = { -- Known temperature data sources
|
||||||
|
@ -43,7 +50,5 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {0}
|
return {0}
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(thermal_linux, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor }
|
||||||
|
@ -6,12 +25,10 @@ local os = { time = os.time }
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Uptime: provides system uptime and load information
|
-- Uptime: provides system uptime and load information
|
||||||
-- vicious.widgets.uptime
|
-- vicious.widgets.uptime
|
||||||
local uptime_freebsd = {}
|
local uptime_freebsd = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Uptime widget type
|
-- {{{ Uptime widget type
|
||||||
function uptime_freebsd.async(format, warg, callback)
|
function uptime_freebsd.async(format, warg, callback)
|
||||||
helpers.sysctl_async(
|
helpers.sysctl_async(
|
||||||
|
|
|
@ -1,24 +1,31 @@
|
||||||
---------------------------------------------------
|
-- uptime widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.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
|
-- {{{ Grab environment
|
||||||
local setmetatable = setmetatable
|
|
||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor }
|
||||||
local string = { match = string.match }
|
local string = { match = string.match }
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Uptime: provides system uptime and load information
|
|
||||||
-- vicious.widgets.uptime
|
|
||||||
local uptime_linux = {}
|
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Uptime widget type
|
-- {{{ Uptime widget type
|
||||||
local function worker(format)
|
return helpers.setcall(function ()
|
||||||
local proc = helpers.pathtotable("/proc")
|
local proc = helpers.pathtotable("/proc")
|
||||||
|
|
||||||
-- Get system uptime
|
-- Get system uptime
|
||||||
|
@ -30,7 +37,5 @@ local function worker(format)
|
||||||
local l1, l5, l15 = -- Get load averages for past 1, 5 and 15 minutes
|
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}
|
return {up_d, up_h, up_m, l1, l5, l15}
|
||||||
end
|
end)
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(uptime_linux, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local string = { match = string.match }
|
local string = { match = string.match }
|
||||||
|
@ -5,12 +24,10 @@ local helpers = require("vicious.helpers")
|
||||||
local spawn = require("vicious.spawn")
|
local spawn = require("vicious.spawn")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Volume: provides volume levels and state of requested mixer
|
-- Volume: provides volume levels and state of requested mixer
|
||||||
-- vicious.widgets.volume_freebsd
|
-- vicious.widgets.volume_freebsd
|
||||||
local volume_freebsd = {}
|
local volume_freebsd = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Volume widget type
|
-- {{{ Volume widget type
|
||||||
local STATE = { on = '🔉', off = '🔈' }
|
local STATE = { on = '🔉', off = '🔈' }
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,23 @@
|
||||||
---------------------------------------------------
|
-- volume widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -13,7 +29,6 @@ local helpers = require("vicious.helpers")
|
||||||
local spawn = require("vicious.spawn")
|
local spawn = require("vicious.spawn")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Volume: provides volume levels and state of requested ALSA mixers
|
-- Volume: provides volume levels and state of requested ALSA mixers
|
||||||
-- vicious.widgets.volume
|
-- vicious.widgets.volume
|
||||||
local volume_linux = {}
|
local volume_linux = {}
|
||||||
|
|
|
@ -1,19 +1,34 @@
|
||||||
---------------------------------------------------
|
-- weather widget type fetching from from US NOAA
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local math = { ceil = math.ceil }
|
local math = { ceil = math.ceil }
|
||||||
local os = { date = os.date, difftime = os.difftime, time = os.time }
|
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 spawn = require"vicious.spawn"
|
||||||
local helpers = require"vicious.helpers"
|
local helpers = require"vicious.helpers"
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Weather: provides weather information for a requested station
|
-- Weather: provides weather information for a requested station
|
||||||
-- vicious.widgets.weather
|
-- vicious.widgets.weather
|
||||||
local weather_all = {}
|
local weather_all = {}
|
||||||
|
@ -27,7 +42,6 @@ local function get_timezone_offset()
|
||||||
return os.difftime(os.time(localdate), os.time(utcdate))
|
return os.difftime(os.time(localdate), os.time(utcdate))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Weather widget type
|
-- {{{ Weather widget type
|
||||||
local function parse(stdout, stderr, exitreason, exitcode)
|
local function parse(stdout, stderr, exitreason, exitcode)
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
|
@ -51,34 +65,38 @@ local function parse(stdout, stderr, exitreason, exitcode)
|
||||||
if stdout == '' then return _weather end
|
if stdout == '' then return _weather end
|
||||||
|
|
||||||
_weather["{city}"] = -- City and/or area
|
_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
|
_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
|
_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
|
_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
|
_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
|
_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
|
_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
|
_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
|
_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 =
|
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
|
if year ~= nil then
|
||||||
local utctable = {
|
local utctable = { year = year, month = month, day = day,
|
||||||
year = year,
|
hour = hour, min = min }
|
||||||
month = month,
|
|
||||||
day = day,
|
|
||||||
hour = hour,
|
|
||||||
min = min,
|
|
||||||
}
|
|
||||||
_weather["{when}"] = os.time(utctable) + get_timezone_offset()
|
_weather["{when}"] = os.time(utctable) + get_timezone_offset()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -110,7 +128,9 @@ function weather_all.async(format, warg, callback)
|
||||||
|
|
||||||
-- Get weather forceast by the station ICAO code, from:
|
-- Get weather forceast by the station ICAO code, from:
|
||||||
-- * US National Oceanic and Atmospheric Administration
|
-- * 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,
|
spawn.easy_async("curl -fs " .. url,
|
||||||
function (...) callback(parse(...)) end)
|
function (...) callback(parse(...)) end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
---------------------------------------------------
|
-- Wi-Fi widget type for GNU/Linux using iwconfig
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -12,7 +27,6 @@ local helpers = require"vicious.helpers"
|
||||||
local spawn = require"vicious.spawn"
|
local spawn = require"vicious.spawn"
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Wifi: provides wireless information for a requested interface using iwconfig
|
-- Wifi: provides wireless information for a requested interface using iwconfig
|
||||||
-- vicious.widgets.wifi
|
-- vicious.widgets.wifi
|
||||||
local wifi_linux = {}
|
local wifi_linux = {}
|
||||||
|
|
|
@ -1,7 +1,23 @@
|
||||||
---------------------------------------------------
|
-- Wi-Fi widget type for GNU/Linux using iw
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2016 Marius M. <mellich@gmx.net>
|
||||||
-- * (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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -11,7 +27,6 @@ local helpers = require("vicious.helpers")
|
||||||
local spawn = require("vicious.spawn")
|
local spawn = require("vicious.spawn")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Wifiiw: provides wireless information for a requested interface
|
-- Wifiiw: provides wireless information for a requested interface
|
||||||
-- using iw instead of deprecated iwconfig
|
-- using iw instead of deprecated iwconfig
|
||||||
-- vicious.widgets.wifiiw
|
-- vicious.widgets.wifiiw
|
||||||
|
|
Loading…
Reference in New Issue