Awesome
Positron Bar
Getting started
This will be streamlined in the near future, but for now:
Install the dependencies
npm install
External deps
-
wmctrl
To query the dekstops, it useswmctrl
. Make sure it's installed on your system. Your WM should support EWMH in order for it to work (you can verify by checking whetherwmctrl -d
outputs your desktosp). -
upower
For battery info. -
amixer
For master volume info.
... build the js modules:
npm run-script build
... and run it:
npm start
Configuration
You configure the bar by modifying the javascript in src/config/**
.
In src/config/Bar.js
you can modify the fields that appear in your bar by modifying what gets returned from it's render()
method.
In src/config/providers.js
you can modify the data providers. E.g. if you don't use spotify, remove it from there and the bar won't try to subscribe to dbus events from spotify.
How it works
The bar is essentially just a browser window (powered by electron.js).
Electron apps consist of 2 processes: the main process which creates the window and the renderer process that runs inside the browser.
We'll focus on the renderer process here, which runs src/app.js
.
View Components & the Redux Store
Because we're running a browser, the elements of the view are just html components, styled with CSS. The html i rendered by React.
The components of course need some data to display. This data is aggregated in a global redux store. Every component is accompanied by a function that selects data from that store. This selection is then injected into the component, which in turn just renders it. Everytime the store updates, the components update through the magic that is React.
Filling the Store
To fill the store with data, src/app.js
runs "providers" in an interval.
These providers just gather some data and then fire some receive-action.
These actions are picked up by so-called "reducers", which update the store.
This design is the react-redux way of doing things and you can read more about it in their docs.