-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from Video-Nomad/feat/libre-hardware-monitor-w…
…idget feat(widget): Libre Hardware Monitor Widget
- Loading branch information
Showing
8 changed files
with
516 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Libre Hardware Monitor Widget Configuration | ||
|
||
| Option | Type | Default | Description | | ||
|-------------------------|---------|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------| | ||
| `label` | string | `"<span>\udb82\udcae </span> {info[value]}{info[unit]}"` | The primary label format. | | ||
| `label_alt` | string | `"<span>\uf4bc </span>{info[histogram]} {info[value]} ({info[min]}/{info[max]}) {info[unit]}"` | Histograms. The alternative label format. | | ||
| `sensor_id` | string | `"/amdcpu/0/load/0"` | Libre Hardware Monitor SensorId from http://localhost:8085/data.json | | ||
| `class_name` | string | `"libre-monitor-widget"` | CSS class name for styling of different widget instances. | | ||
| `update_interval` | integer | `1000` | The interval in milliseconds to update the widget. | | ||
| `precision` | integer | `1` | Floating point precision of the info[value]. | | ||
| `history_size` | integer | `60` | The size of the min/max history. | | ||
| `histogram_num_columns` | integer | `10` | The number of columns in the histogram. | | ||
| `histogram_fixed_min` | integer | `None` | Histogram minimum value. If None - set as history minimum value. | | ||
| `histogram_fixed_max` | integer | `None` | Histogram maximum value. If None - set as history maximum value. | | ||
| `server_host` | string | `"localhost"` | Libre Hardware Monitor server host. | | ||
| `server_port` | integer | `8085` | Libre Hardware Monitor server port. | | ||
| `server_username` | string | `""` | Libre Hardware Monitor username. Only needed if auth is enabled. | | ||
| `server_password` | string | `""` | Libre Hardware Monitor password. Only needed if auth is enabled. | | ||
| `histogram_icons` | list | `['\u2581', '\u2581', '\u2582', '\u2583', '\u2584', '\u2585', '\u2586', '\u2587', '\u2588']` | Icons representing CPU usage histograms. | | ||
| `callbacks` | dict | `{'on_left': 'toggle_label', 'on_middle': 'do_nothing', 'on_right': 'do_nothing'}` | Callback functions for different mouse button actions. | | ||
|
||
## Example Configuration (GPU Temperature) | ||
|
||
```yaml | ||
libre_gpu: | ||
type: "yasb.libre_monitor.LibreHardwareMonitorWidget" | ||
options: | ||
label: "<span>\udb82\udcae </span> {info[value]}{info[unit]}" | ||
label_alt: "<span>\uf437 </span>{info[histogram]} {info[value]} ({info[min]}/{info[max]}) {info[unit]}" | ||
sensor_id: "/gpu-nvidia/0/temperature/0" | ||
update_interval: 1000 | ||
precision: 1 | ||
histogram_num_columns: 10 | ||
class_name: "libre-monitor-widget" | ||
|
||
history_size: 60 | ||
histogram_icons: | ||
- '\u2581' # 0% | ||
- '\u2581' # 10% | ||
- '\u2582' # 20% | ||
- '\u2583' # 30% | ||
- '\u2584' # 40% | ||
- '\u2585' # 50% | ||
- '\u2586' # 60% | ||
- '\u2587' # 70% | ||
- '\u2588' # 80%+ | ||
|
||
# histogram_fixed_min: 0.0 | ||
# histogram_fixed_max: 100.0 | ||
|
||
# server_host: "localhost" | ||
# server_port: 8085 | ||
# server_username: "admin" | ||
# server_password: "password" | ||
|
||
callbacks: | ||
on_left: "toggle_label" | ||
on_middle: "do_nothing" | ||
on_right: "do_nothing" | ||
``` | ||
## Set up instructions | ||
1. Install Libre Hardware Monitor https://github.com/LibreHardwareMonitor/LibreHardwareMonitor | ||
2. Run Libre Hardware Monitor. | ||
3. Start the Remote Web Server (Options -> Remote Web Server -> Run). | ||
4. Find the required SensorId in the http://localhost:8085/data.json. | ||
5. Update the widget configuration with the required SensorId. | ||
**Note**: Libre Hardware Monitor and its web server must be running in the background for the widget to work. Autostart is recommended. | ||
## Description of Options | ||
- **label**: The format string for the Libre Monitor label. You can use placeholders like `{info[value]} {info[unit]}` to dynamically insert required information. | ||
- **label_alt**: The alternative format string for the Libre Monitor label. Useful for displaying additional details like histogram `{info[histogram]}` or min/max values `{info[min]} {info[max]}`. | ||
- **class_name**: Custom CSS class name for the widget instance. Useful when having multiple widgets with different styling. | ||
- **sensor_id**: The sensor ID of the Libre Hardware Monitor server. All the SensorIds can be found in the http://localhost:8085/data.json when the server is running (Options->Remote Web Server->Run). | ||
- **update_interval**: The interval in milliseconds at which the widget updates its information. Limited by the Libre Hardware Monitor update interval. | ||
- **precision**: Floating point precision of the `{info[value]}`. | ||
- **history_size**: The size of the min/max history. The history is reset when the widget/yasb is reloaded. | ||
- **histogram_fixed_min**: Set the fixed minimum value of the histogram. Actual sensor min value from the history is not changed. If not set manually it will be set as history minimum value. | ||
- **histogram_fixed_max**: Set the fixed maximum value of the histogram. Actual sensor max value from the history is not changed. If not set manually it will be set as history maximum value. | ||
- **histogram_icons**: A list of icons representing different values of the histogram. | ||
- **histogram_num_columns**: The number of columns to display in the histogram. | ||
- **server_host**: The host of the Libre Hardware Monitor server. | ||
- **server_port**: The port of the Libre Hardware Monitor server. | ||
- **server_username**: The username of the Libre Hardware Monitor server. Required if auth is enabled. | ||
- **server_password**: The password of the Libre Hardware Monitor server. Required if auth is enabled. | ||
- **callbacks**: A dictionary specifying the callbacks for mouse events. The keys are `on_left`, `on_middle`, and `on_right`, and the values are the names of the callback functions. | ||
|
||
## Example Style | ||
```css | ||
.libre-monitor-widget {} | ||
.libre-monitor-widget .widget-container {} | ||
.libre-monitor-widget .widget-container .label {} | ||
.libre-monitor-widget .widget-container .label.alt {} | ||
.libre-monitor-widget .widget-container .icon {} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
DEFAULTS = { | ||
'class_name': 'libre-monitor-widget', | ||
'label': '<span>\udb82\udcae </span> {info[value]}{info[unit]}', | ||
'label_alt': '<span>\uf437 </span>{info[histogram]} {info[value]} ({info[min]}/{info[max]}) {info[unit]}', | ||
'update_interval': 1000, | ||
'sensor_id': '/amdcpu/0/load/0', | ||
'histogram_icons': [ | ||
r'\u2581', | ||
r'\u2581', | ||
r'\u2582', | ||
r'\u2583', | ||
r'\u2584', | ||
r'\u2585', | ||
r'\u2586', | ||
r'\u2587', | ||
r'\u2588' | ||
], | ||
'histogram_num_columns': 10, | ||
'precision': 2, | ||
'history_size': 60, | ||
'histogram_fixed_min': None, | ||
'histogram_fixed_max': None, | ||
'server_host': 'localhost', | ||
'server_port': 8085, | ||
'server_username': '', | ||
'server_password': '', | ||
'callbacks': { | ||
'on_left': 'toggle_label', | ||
'on_middle': 'do_nothing', | ||
'on_right': 'do_nothing' | ||
}, | ||
} | ||
|
||
VALIDATION_SCHEMA = { | ||
'class_name': { | ||
'type': 'string', | ||
'default': DEFAULTS['class_name'], | ||
'required': False, | ||
}, | ||
'label': { | ||
'type': 'string', | ||
'default': DEFAULTS['label'] | ||
}, | ||
'label_alt': { | ||
'type': 'string', | ||
'default': DEFAULTS['label_alt'] | ||
}, | ||
'update_interval': { | ||
'type': 'integer', | ||
'default': DEFAULTS['update_interval'], | ||
'min': 0, | ||
'max': 60000 | ||
}, | ||
'sensor_id': { | ||
'type': 'string', | ||
'default': DEFAULTS['sensor_id'], | ||
}, | ||
'histogram_icons': { | ||
'type': 'list', | ||
'default': DEFAULTS['histogram_icons'], | ||
'minlength': 9, | ||
'maxlength': 9, | ||
"schema": { | ||
'type': 'string' | ||
} | ||
}, | ||
'histogram_num_columns': { | ||
'type': 'integer', | ||
'default': DEFAULTS['histogram_num_columns'], | ||
'min': 0, | ||
'max': 128 | ||
}, | ||
'precision': { | ||
'type': 'integer', | ||
'default': DEFAULTS['precision'], | ||
'min': 0, | ||
'max': 30, | ||
'required': False, | ||
}, | ||
'history_size': { | ||
'type': 'integer', | ||
'default': DEFAULTS['history_size'], | ||
'min': DEFAULTS["histogram_num_columns"], | ||
'max': 50000, | ||
'required': False, | ||
}, | ||
'histogram_fixed_min': { | ||
'type': 'float', | ||
'default': DEFAULTS['histogram_fixed_min'], | ||
'min': -10000.0, | ||
'max': 10000.0, | ||
'required': False, | ||
'nullable': True | ||
}, | ||
'histogram_fixed_max': { | ||
'type': 'float', | ||
'default': DEFAULTS['histogram_fixed_max'], | ||
'min': -10000.0, | ||
'max': 10000.0, | ||
'required': False, | ||
'nullable': True | ||
}, | ||
'server_host': { | ||
'type': 'string', | ||
'default': DEFAULTS['server_host'], | ||
'required': False, | ||
}, | ||
'server_port': { | ||
'type': 'integer', | ||
'default': DEFAULTS['server_port'], | ||
'min': 0, | ||
'max': 65535, | ||
'required': False, | ||
}, | ||
'server_username': { | ||
'type': 'string', | ||
'default': DEFAULTS['server_username'], | ||
'required': False, | ||
}, | ||
'server_password': { | ||
'type': 'string', | ||
'default': DEFAULTS['server_password'], | ||
'required': False, | ||
}, | ||
'callbacks': { | ||
'type': 'dict', | ||
'schema': { | ||
'on_left': { | ||
'type': 'string', | ||
'default': DEFAULTS['callbacks']['on_left'], | ||
}, | ||
'on_middle': { | ||
'type': 'string', | ||
'default': DEFAULTS['callbacks']['on_middle'], | ||
}, | ||
'on_right': { | ||
'type': 'string', | ||
'default': DEFAULTS['callbacks']['on_right'], | ||
} | ||
}, | ||
'default': DEFAULTS['callbacks'] | ||
} | ||
} |
Oops, something went wrong.