mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-07 07:00:27 -04:00
Implement a few more apis.
Also updated run_script to take argv as parameter instead of a single string.
This commit is contained in:
parent
e2cc4c2b38
commit
abb0520e67
4 changed files with 35 additions and 4 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -318,6 +318,12 @@ dependencies = [
|
||||||
"crypto-common",
|
"crypto-common",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dyn"
|
||||||
|
version = "0.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd5d33be9d461be19ff7168302689ed4ca466300600546c93795e845d5fa3faf"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "enumflags2"
|
name = "enumflags2"
|
||||||
version = "0.7.8"
|
version = "0.7.8"
|
||||||
|
@ -874,6 +880,7 @@ name = "steamos-manager"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
|
"dyn",
|
||||||
"serde",
|
"serde",
|
||||||
"subprocess",
|
"subprocess",
|
||||||
"zbus",
|
"zbus",
|
||||||
|
|
|
@ -7,6 +7,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-std = { version = "1.12.0", features = ["attributes"] }
|
async-std = { version = "1.12.0", features = ["attributes"] }
|
||||||
|
dyn = "0.0.0"
|
||||||
serde = { version = "1.0.188", features = ["derive"] }
|
serde = { version = "1.0.188", features = ["derive"] }
|
||||||
subprocess = "0.2.9"
|
subprocess = "0.2.9"
|
||||||
zbus = "3.14.1"
|
zbus = "3.14.1"
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
Disable wifi chip's powermanagement.
|
Disable wifi chip's powermanagement.
|
||||||
-->
|
-->
|
||||||
<method name="DisableWifiPowerManagement">
|
<method name="DisableWifiPowerManagement">
|
||||||
|
<arg type="b" name="success" direction="out"/>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
@ -70,6 +71,7 @@
|
||||||
-->
|
-->
|
||||||
<method name="EnableFanControl">
|
<method name="EnableFanControl">
|
||||||
<arg type="b" name="enable" direction="in"/>
|
<arg type="b" name="enable" direction="in"/>
|
||||||
|
<arg type="b" name="success" direction="out"/>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
|
|
|
@ -23,18 +23,19 @@
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use std::ffi::OsStr;
|
||||||
use subprocess::{ExitStatus::Exited, Popen, PopenConfig, Redirection};
|
use subprocess::{ExitStatus::Exited, Popen, PopenConfig, Redirection};
|
||||||
use zbus_macros::dbus_interface;
|
use zbus_macros::dbus_interface;
|
||||||
use zbus::{ObjectServer, SignalContext, MessageHeader};
|
use zbus::{ObjectServer, SignalContext, MessageHeader};
|
||||||
pub struct SMManager {
|
pub struct SMManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_script(script: String) -> bool {
|
fn run_script(argv: &[impl AsRef<OsStr>]) -> bool {
|
||||||
// Run given script and return true on success
|
// Run given script and return true on success
|
||||||
let mut process = Popen::create(&[script], PopenConfig {
|
let mut process = Popen::create(argv, PopenConfig {
|
||||||
stdout: Redirection::Pipe, ..Default::default()
|
stdout: Redirection::Pipe, ..Default::default()
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
let (out, err) = process.communicate(None).unwrap();
|
let (_out, _err) = process.communicate(None).unwrap();
|
||||||
if let Some(exit_status) = process.poll() {
|
if let Some(exit_status) = process.poll() {
|
||||||
return exit_status == Exited(0);
|
return exit_status == Exited(0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,7 +54,27 @@ impl SMManager {
|
||||||
|
|
||||||
async fn factory_reset(&self) -> bool {
|
async fn factory_reset(&self) -> bool {
|
||||||
// Run steamos factory reset script and return true on success
|
// Run steamos factory reset script and return true on success
|
||||||
return run_script("steamos-factory-reset".to_string());
|
return run_script(&["steamos-factory-reset-config"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn disable_wifi_power_management(&self) -> bool {
|
||||||
|
// Run what steamos-polkit-helpers/steamos-disable-wifi-power-management does
|
||||||
|
return run_script(&["iwconfig", "wlan0", "power", "off"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn enable_fan_control(&self, enable: bool) -> bool {
|
||||||
|
// Run what steamos-polkit-helpers/jupiter-fan-control does
|
||||||
|
if enable {
|
||||||
|
return run_script(&["systemctl", "start", "jupiter-fan-control.service"]);
|
||||||
|
} else {
|
||||||
|
return run_script(&["systemctl", "stop", "jupiter-fan-control.service"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn hardware_check_support(&self) -> bool {
|
||||||
|
// Run jupiter-check-support note this script does exit 1 for "Support: No" case
|
||||||
|
// so no need to parse output, etc.
|
||||||
|
return run_script(&["jupiter-check-support"])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A version property.
|
/// A version property.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue