@aminnairi/i3status
Version:
Library to create your own i3 status bar in Node.js using the Flux architecture
145 lines (104 loc) • 4.95 kB
Markdown
# @aminnairi/i3status
[](https://www.npmjs.com/package/@aminnairi/i3status/v/1.1.0) [](https://bundlephobia.com/package/@aminnairi/i3status@1.1.0) [](https://bundlephobia.com/package/@aminnairi/i3status@1.1.0) 
Library to create your own i3 status bar in Node.js using the Flux architecture

## Why
- Because it is inspired by The Elm Architecture, Redux, and the Flux architecture.
- Because it is written using modern ECMAScript syntax.
- Because it is written using modern ECMAScript Modules.
- Because it is written with functional programming in mind.
- Because it is well documented with many examples (and many to come).
- Because it is tested from integration to end-to-end.
- Because it is powered by the Node.js platform and all of its operating system's API and ecosystem.
- Because it allows you to build complex, dynamic status bars with ease.
- Because it does not require any global installation (but you can if you want).
- Because it does not require any yaml, env files, and is just plain JavaScript, nothing else.
- Because it has full support for asynchronous updates through dispatches.
- Because it has full support for i3wm click events (buttons, modfiiers, coordinates, ...).
- Because it has full supports for i3wm blocks configuration (color, padding, separator, ...).
- Because it has no external dependencies.
- Because it has been made with love.
## Instructions
### Recommended
#### Requirements
- [JavaScript](https://developer.mozilla.org/fr/docs/Web/JavaScript)
- [GNU/Linux](https://en.wikipedia.org/wiki/Linux)
- [Terminal emulator](https://en.wikipedia.org/wiki/Terminal_emulator)
- [Text editor](https://en.wikipedia.org/wiki/Text_editor)
- [Node](https://nodejs.org/en/)
- [NPM](https://www.npmjs.com/)
- [i3wm](https://i3wm.org/)
#### Installation
Open a new terminal emulator and type the following commands.
```bash
mkdir ~/my-i3status
cd ~/my-i3status
touch index.mjs
npm install --save-exact --save @aminnairi/i3status
```
Open the created file `index.mjs` and copy/paste the following block of code into it.
```javascript
import {createInterface} from "readline/promises";
import {stdin as input, stdout as output} from "process";
import {createRenderer} from "@aminnairi/i3status";
const render = createRenderer({
createInterface,
input,
output
});
render({
initialBlocks: [
{
full_text: "Hello, world!"
}
]
});
```
Open the file `~/.config/i3/config` and replace the following option `status_command` if it already exists, or add it to the `bar` block.
```
bar {
status_command node ~/my-i3status/index.mjs
}
```
In the same terminal emulator you just opened, type the following command.
```bash
i3-msg reload
```
### Manual
#### Requirements
- [JavaScript](https://developer.mozilla.org/fr/docs/Web/JavaScript)
- [GNU/Linux](https://en.wikipedia.org/wiki/Linux)
- [Terminal emulator](https://en.wikipedia.org/wiki/Terminal_emulator)
- [Text editor](https://en.wikipedia.org/wiki/Text_editor)
- [Docker](https://www.docker.com/)
- [Docker Compose](https://docs.docker.com/compose/)
- [i3wm](https://i3wm.org/)
#### Installation
Open a new terminal emulator and type the following commands
```bash
git clone https://github.com/aminnairi/i3status ~/my-i3status
cd ~/my-i3status
docker-compose run --rm npm install
docker-compose run --rm npm test
docker-compose run --rm npm run build
```
Choose one of the example script (for instance, [`simple.mjs`](https://github.com/aminnairi/i3status/tree/production/examples/simple.mjs)) in the [`examples`](https://github.com/aminnairi/i3status/tree/production/examples) folder and replace the import path `@aminnairi/i3status` to `../build/index.mjs`. Then open the file `~/.config/i3/config` and replace the following option `status_command` if it already exists, or add it to the `bar` block.
```
bar {
status_command node ~/my-i3status/example/simple.mjs
}
```
In the same terminal emulator you just opened, type the following command.
```bash
i3-msg reload
```
## Examples
See [`examples`](https://github.com/aminnairi/i3status/tree/production/examples).
## Changelog
See [`CHANGELOG.md`](https://github.com/aminnairi/i3status/tree/production/CHANGELOG.md).
## Contributing
See [`CONTRIBUTING.md`](https://github.com/aminnairi/i3status/tree/production/CONTRIBUTING.md).
## Code of conduct
See [`CODE_OF_CONDUCT.md`](https://github.com/aminnairi/i3status/tree/production/CODE_OF_CONDUCT.md).
## License
See [`LICENSE`](https://github.com/aminnairi/i3status/tree/production/LICENSE).