Directly disable jupiter-fan-control service to fix #10
This commit is contained in:
parent
2286e0f43a
commit
b3de3fcd7e
6 changed files with 63 additions and 13 deletions
2
backend-rs/Cargo.lock
generated
2
backend-rs/Cargo.lock
generated
|
@ -106,7 +106,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fantastic-rs"
|
name = "fantastic-rs"
|
||||||
version = "0.3.3"
|
version = "0.3.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "fantastic-rs"
|
name = "fantastic-rs"
|
||||||
version = "0.3.3"
|
version = "0.3.5"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
cross build --release
|
#cargo build --release --target x86_64-unknown-linux-musl
|
||||||
mkdir ../bin
|
cargo build --target x86_64-unknown-linux-musl
|
||||||
cp ./target/release/fantastic-rs ../bin/backend
|
#cross build --release
|
||||||
|
|
||||||
|
mkdir -p ../bin
|
||||||
|
#cp ./target/x86_64-unknown-linux-musl/release/fantastic-rs ../bin/backend
|
||||||
|
cp ./target/x86_64-unknown-linux-musl/debug/fantastic-rs ../bin/backend
|
||||||
|
#cp ./target/release/fantastic-rs ../bin/backend
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ use std::time::{Duration, Instant};
|
||||||
use super::datastructs::{Settings, State, GraphPoint};
|
use super::datastructs::{Settings, State, GraphPoint};
|
||||||
use super::json::SettingsJson;
|
use super::json::SettingsJson;
|
||||||
|
|
||||||
|
const VALVE_FAN_SERVICE: &str = "jupiter-fan-control.service";
|
||||||
|
|
||||||
pub struct ControlRuntime {
|
pub struct ControlRuntime {
|
||||||
settings: Arc<RwLock<Settings>>,
|
settings: Arc<RwLock<Settings>>,
|
||||||
state: Arc<RwLock<State>>,
|
state: Arc<RwLock<State>>,
|
||||||
|
@ -104,6 +106,7 @@ impl ControlRuntime {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if settings.enable {
|
if settings.enable {
|
||||||
|
Self::enforce_jupiter_status(true);
|
||||||
Self::do_fan_control(&settings);
|
Self::do_fan_control(&settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +116,8 @@ impl ControlRuntime {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_set_enable(settings: &Settings, _state: &State) {
|
fn on_set_enable(settings: &Settings, _state: &State) {
|
||||||
// TODO stop/start jupiter fan control (or maybe let the UI handle that?)
|
// stop/start jupiter fan control (since the client-side way of doing this was removed :( )
|
||||||
|
Self::enforce_jupiter_status(settings.enable);
|
||||||
if let Err(e) = crate::sys::write_fan_recalc(settings.enable) {
|
if let Err(e) = crate::sys::write_fan_recalc(settings.enable) {
|
||||||
log::error!("runtime failed to write to fan recalculate file: {}", e);
|
log::error!("runtime failed to write to fan recalculate file: {}", e);
|
||||||
}
|
}
|
||||||
|
@ -222,6 +226,51 @@ impl ControlRuntime {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn enforce_jupiter_status(enabled: bool) {
|
||||||
|
// enabled refers to whether this plugin's functionality is enabled,
|
||||||
|
// not the jupiter fan control service
|
||||||
|
let service_status = Self::detect_jupiter_fan_service();
|
||||||
|
log::debug!("fan control service is enabled? {}", service_status);
|
||||||
|
if enabled == service_status {
|
||||||
|
// do not run Valve's fan service along with Fantastic, since they fight
|
||||||
|
if enabled {
|
||||||
|
Self::stop_fan_service();
|
||||||
|
} else {
|
||||||
|
Self::start_fan_service();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn detect_jupiter_fan_service() -> bool {
|
||||||
|
match std::process::Command::new("systemctl")
|
||||||
|
.args(["is-active", VALVE_FAN_SERVICE])
|
||||||
|
.output() {
|
||||||
|
Ok(cmd) => String::from_utf8_lossy(&cmd.stdout).trim() == "active",
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("`systemctl is-active {}` err: {}", VALVE_FAN_SERVICE, e);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn start_fan_service() {
|
||||||
|
match std::process::Command::new("systemctl")
|
||||||
|
.args(["start", VALVE_FAN_SERVICE])
|
||||||
|
.output() {
|
||||||
|
Err(e) => log::error!("`systemctl start {}` err: {}", VALVE_FAN_SERVICE, e),
|
||||||
|
Ok(out) => log::debug!("started `{}`:\nstdout:{}\nstderr:{}", VALVE_FAN_SERVICE, String::from_utf8_lossy(&out.stdout), String::from_utf8_lossy(&out.stderr)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stop_fan_service() {
|
||||||
|
match std::process::Command::new("systemctl")
|
||||||
|
.args(["stop", VALVE_FAN_SERVICE])
|
||||||
|
.output() {
|
||||||
|
Err(e) => log::error!("`systemctl stop {}` err: {}", VALVE_FAN_SERVICE, e),
|
||||||
|
Ok(out) => log::debug!("stopped `{}`:\nstdout:{}\nstderr:{}", VALVE_FAN_SERVICE, String::from_utf8_lossy(&out.stdout), String::from_utf8_lossy(&out.stderr)),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn settings_path<P: AsRef<std::path::Path>>(home: P) -> std::path::PathBuf {
|
fn settings_path<P: AsRef<std::path::Path>>(home: P) -> std::path::PathBuf {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "Fantastic",
|
"name": "Fantastic",
|
||||||
"version": "0.3.4",
|
"version": "0.3.5",
|
||||||
"description": "A template to quickly create decky plugins from scratch, based on TypeScript and webpack",
|
"description": "A template to quickly create decky plugins from scratch, based on TypeScript and webpack",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "shx rm -rf dist && rollup -c",
|
"build": "shx rm -rf dist && rollup -c",
|
||||||
|
|
|
@ -55,8 +55,6 @@ const Content: VFC<{ serverAPI: ServerAPI }> = ({serverAPI}) => {
|
||||||
|
|
||||||
function setEnable(enable: boolean) {
|
function setEnable(enable: boolean) {
|
||||||
setEnableInternal(enable);
|
setEnableInternal(enable);
|
||||||
//@ts-ignore
|
|
||||||
SteamClient.System.SetBetaFanControl(!enable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClickCanvas(e: any) {
|
function onClickCanvas(e: any) {
|
||||||
|
@ -290,10 +288,7 @@ export default definePlugin((serverApi: ServerAPI) => {
|
||||||
(async function(){
|
(async function(){
|
||||||
await backend.initBackend();
|
await backend.initBackend();
|
||||||
usdplReady = true;
|
usdplReady = true;
|
||||||
backend.getEnabled().then((enabled: boolean) => {
|
backend.getEnabled();
|
||||||
//@ts-ignore
|
|
||||||
SteamClient.System.SetBetaFanControl(!enabled);
|
|
||||||
});
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
let ico = <FaFan />;
|
let ico = <FaFan />;
|
||||||
|
|
Loading…
Reference in a new issue