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