first version with basic fan monitor

This commit is contained in:
marc barbier
2021-08-25 11:47:05 +02:00
parent 0f1d1d329c
commit 185a181f59
3 changed files with 72 additions and 1 deletions
+9 -1
View File
@@ -1,2 +1,10 @@
# Faustus-Gnome-Monitor # Faustus-Gnome-Monitor
a fan monitor for the asus tuf faustus driver @hackbnw/faustus a fan monitor for the asus tuf faustus driver https://github.com/hackbnw/faustus
this simple gnome extension will only display if your laptop support /sys/devices/platform/faustus/throttle_thermal_policy
you can check this by simply doing ```ls /sys/devices/platform/faustus/throttle_thermal_policy``` if there is no error then you are fine.
# Installation
```
mkdir -p ~/.local/share/gnome-shell/extensions/fan_status@Marc-Pierre-Barbier.github.com
git clone https://github.com/Marc-Pierre-Barbier/Faustus-Gnome-Monitor ~/.local/share/gnome-shell/extensions/fan_status@Marc-Pierre-Barbier.github.com
```
+52
View File
@@ -0,0 +1,52 @@
// Example #1
const {St, Clutter, GLib} = imports.gi
const Main = imports.ui.main
const Mainloop = imports.mainloop
const ByteArray = imports.byteArray
let panelButton;
const statuses = ["auto","fast","silent"]
function init () {
// Create a Button with "Hello World" text
panelButton = new St.Bin({
style_class : "panel-button",
});
//Gio.monitor doesn't trigger. maybe it considier throttle_thermal_policy as a device ?
Mainloop.timeout_add(300, function () {
update()
return true
});
update()
}
function readFile() {
const array = GLib.file_get_contents("/sys/devices/platform/faustus/throttle_thermal_policy")[1]
const status = parseInt(ByteArray.toString(array))
GLib.free(array)
return status
}
function update() {
const status = readFile();
let panelButtonText = new St.Label({
text : statuses[status],
y_align: Clutter.ActorAlign.CENTER,
});
panelButton.set_child(panelButtonText);
}
function enable () {
// Add the button to the panel
Main.panel._rightBox.insert_child_at_index(panelButton, 0);
}
function disable () {
// Remove the added button from panel
Main.panel._rightBox.remove_child(panelButton);
}
+11
View File
@@ -0,0 +1,11 @@
{
"name" : "fan_status",
"description" : "Tuf fan monitor",
"shell-version" : [
"3.36",
"40"
],
"url" : "",
"uuid" : "fan_status@Marc-Pierre-Barbier.github.com",
"version" : 1.1
}