This will be streamlined in the near future, but for now:
Install the dependencies
wmctrlTo query the dekstops, it uses
wmctrl. Make sure it's installed on your system. Your WM should support EWMH in order for it to work (you can verify by checking whether
wmctrl -doutputs your desktosp).
upowerFor battery info.
amixerFor master volume info.
... build the js modules:
npm run-script build
... and run it:
src/config/Bar.js you can modify the fields that appear in your bar by modifying what gets returned from it's
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
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.