Skip to content
/ pilibre Public

Hardware monitoring with LibreHardwareMonitor, Rich, and a Raspberry Pi.

License

Notifications You must be signed in to change notification settings

acbuie/pilibre

Repository files navigation

PiLibre


A small Python script for displaying hardware metrics. Metrics are pulled from LibreHardwareMonitor, and requires it to be installed on your PC and in server mode. It is designed to be run on a small computer with a small display. I intend to use a Raspberry Pi, but you could likely use something else.


Installation

PiLibre relies on rich and httpx on the display machine, and LibreHardwareMonitor on the machine from which you want to see metrics.

  • rich: For terminal display of the hardware metrics
  • httpx: To pull the JSON data served by LibreHardwareMonitor
  • LibreHardwareMonitor: For getting the hardware metrics of your computer.

Host Machine Setup

The host machine only needs to have LibreHardwareMonitor installed. The project can be found here: https://github.com/LibreHardwareMonitor/LibreHardwareMonitor and downloaded from here: https://github.com/LibreHardwareMonitor/LibreHardwareMonitor/releases.

Once installed:

  • Open the HTTP server via Options -> HTTP Server.
  • Take note of the IP address. This is the IP address of the local machine.
  • If you'd like to change the default port, do so here.

Display Machine Setup

The machine you want to display metrics on needs to have the PiLibre application installed. The easiest way is to use pipx, but manual instructions are also included.

Via pipx

pipx is recommended for the simplest installation. This will install PiLibre into its own virtual environment, along with any dependencies.

Install pipx from here: https://github.com/pypa/pipx#install-pipx.

pipx install pilibre

# Or, via the repository on github
pipx install git+https://github.com/acbuie/pilibre.git

Via pip

You can also install manually via pip.

First, create a folder for the project.

mkdir pilibre
cd pilibre

Then, create and activate virtual environment for the project. A very basic setup is shown below.

You can read about virtual environments here: https://docs.python.org/3/tutorial/venv.html.

# Create virtual env with installed python
python -m venv .venv

# Activate
# On Mac/Linux:
source .venv/bin/activate

# On Windows:
venv/Scripts/activate.bat

# Then, install
python -m pip install pilibre

Via git

You can also install the package via Git. As always, a virtual environment is recommended, so the requirements don't get installed into the system python. Runtime dependencies can be installed with python -m pip install requirements.txt.

First, clone the project into a new directory.

mkdir pilibre
cd pilibre
git clone https://github.com/acbuie/pilibre.git

Once installed, create and activate a python virtual environment.

python -m venv .venv
source .venv/bin/activate

Then, install the dependencies.

python -m pip install requirements.txt

Usage

Usage is very simple. Once the HTTP server is running on the host machine, simply specify the IP address and port in the config file and run the project.

Running the program depends on how it was installed.

  • With pipx: pilibre
    • This works because pipx installs its programs onto the system PATH. These programs can be invoked from any directory in the shell.
  • With pip or git: python -m pilibre
    • This requires you to run the above command in the directory in which you installed the project.

Configuration

Theming

Colors

Colors can also be defined in the config. Rich is used to parse the colors, so any string that can be parsed by Color.parse() is valid.

Valid colors formats are like so:

  • rgb: "rgb(0, 0, 0)"
  • hex: "#ffffff"
  • ansi: "white"
  • 16 or 255: "color(0)"

A note about non-truecolor definitions In order to support a variety of color definitions, each color type is converted into RGB. RGB colors are defined as TRUECOLOR when passed back into Rich, even if the RGB directly corresponds to a standard terminal 255 color. If you use Rich.Color.parse in your own projects, you may realize that it respects your terminal theme when passed ANSI or a standard-255 color. PiLibre is unable to do this, because it needs colors in the RGB format for color blending (which get turned into TRUECOLOR). This means, if you'd like to define colors in a non RGB or hex format, but want to respect the terminal theme, you'll have to manually define your terminal theme in pilibre.toml. Sorry!

Terminal Theme

This only needs to be set if you define your colors with ANSI or a standard-255 color definition, as these will not respect your terminal theme (they will in Rich, but won't in PiLibre). You can read why above, in Colors.

The definition is simple, and has 4 parts: background, foreground, normal, and bright. They are all defined with TRUECOLOR from Rich, so RGB or hex color definitions are necessary here.

Layouts

About

Hardware monitoring with LibreHardwareMonitor, Rich, and a Raspberry Pi.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages