From 185a181f592ff75dfd9e895b4c73412bbab0cb52 Mon Sep 17 00:00:00 2001 From: marc barbier Date: Wed, 25 Aug 2021 11:47:05 +0200 Subject: [PATCH] first version with basic fan monitor --- README.md | 10 +++++++++- extension.js | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ metadata.json | 11 +++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 extension.js create mode 100644 metadata.json diff --git a/README.md b/README.md index 29d1ca6..e1600a6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,10 @@ # 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 +``` \ No newline at end of file diff --git a/extension.js b/extension.js new file mode 100644 index 0000000..c4f11ee --- /dev/null +++ b/extension.js @@ -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); +} + diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..b44ba5c --- /dev/null +++ b/metadata.json @@ -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 +}