Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
749 changes: 125 additions & 624 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ dbus = "*"
pciutils = "*"

[dependencies]
log = "0.4.20"
simple_logger = "4.2.0"
tokio = { version = "*", features = ["full"] }
zbus = { version = "3.14.1", default-features = false, features = ["tokio"] }
zbus_macros = "3.14.1"
log = "0.4.27"
simple_logger = "5.0.0"
tokio = { version = "1.45.1", features = ["full"] }
zbus = { version = "5.7.1", default-features = false, features = ["tokio"] }
zbus_macros = "5.7.1"
rog_platform = { git = "https://gitlab.com/asus-linux/asusctl.git", default-features = true }
xdg = "2.5.2"
toml = "0.7.8"
serde = { version = "1.0", features = ["derive"] }
xdg = "3.0.0"
toml = "0.8.23"
serde = { version = "1.0.219", features = ["derive"] }
udev = { version = "0.9.3", features = ["send", "sync"] }

[target.'cfg(target_arch = "x86_64")'.dependencies]
Expand Down
12 changes: 6 additions & 6 deletions src/performance/cpu/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};
use tokio::io::AsyncWriteExt;
use zbus::fdo;
use zbus_macros::dbus_interface;
use zbus_macros::interface;

// Instance of a single CPU core
#[derive(Debug)]
Expand Down Expand Up @@ -42,17 +42,17 @@ impl CPUCore {
}
}

#[dbus_interface(name = "org.shadowblip.CPU.Core")]
#[interface(name = "org.shadowblip.CPU.Core")]
impl CPUCore {
// Returns the core number of the CPU core
#[dbus_interface(property)]
#[zbus(property)]
pub fn number(&self) -> u32 {
self.number
}

// Returns the core ID of the CPU core. This ID will be identical for
// hyperthread cores.
#[dbus_interface(property)]
#[zbus(property)]
pub fn core_id(&self) -> fdo::Result<u32> {
let path = format!("{0}/topology/core_id", self.path);
let result = fs::read_to_string(path);
Expand All @@ -72,7 +72,7 @@ impl CPUCore {
}

// Returns true if the given core is online
#[dbus_interface(property)]
#[zbus(property)]
pub fn online(&self) -> fdo::Result<bool> {
if self.number == 0 {
return Ok(true);
Expand All @@ -89,7 +89,7 @@ impl CPUCore {
}

// Sets the given core to online
#[dbus_interface(property)]
#[zbus(property)]
pub fn set_online(&mut self, enabled: bool) -> fdo::Result<()> {
let enabled_str = if enabled { "enabled" } else { "disabled" };
log::info!("Setting core {} to {}", self.number, enabled_str);
Expand Down
20 changes: 10 additions & 10 deletions src/performance/cpu/cpu_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{fs::OpenOptions, io::Write};
use tokio::fs;
use zbus::fdo;
use zbus::zvariant::ObjectPath;
use zbus_macros::dbus_interface;
use zbus_macros::interface;

use crate::constants::CPU_PATH;
use crate::performance::cpu::core::CPUCore;
Expand Down Expand Up @@ -57,10 +57,10 @@ impl Cpu {
}
}

#[dbus_interface(name = "org.shadowblip.CPU")]
#[interface(name = "org.shadowblip.CPU")]
impl Cpu {
// Returns whether or not boost is enabled
#[dbus_interface(property)]
#[zbus(property)]
pub async fn boost_enabled(&self) -> fdo::Result<bool> {
if !has_feature("cpb".to_string()).await? {
return Ok(false);
Expand All @@ -77,7 +77,7 @@ impl Cpu {
}

// Set whether or not boost is enabled
#[dbus_interface(property)]
#[zbus(property)]
pub async fn set_boost_enabled(&mut self, enabled: bool) -> fdo::Result<()> {
log::info!("Setting boost enabled to {}", enabled);
let status = if enabled { "1" } else { "0" };
Expand All @@ -97,7 +97,7 @@ impl Cpu {
}

// Returns whether or not SMT is currently enabled
#[dbus_interface(property)]
#[zbus(property)]
pub async fn smt_enabled(&self) -> fdo::Result<bool> {
if !has_feature("ht".to_string()).await? {
return Ok(false);
Expand All @@ -114,7 +114,7 @@ impl Cpu {
}

// Set whether or not SMT is enabled
#[dbus_interface(property)]
#[zbus(property)]
pub async fn set_smt_enabled(&mut self, enabled: bool) -> fdo::Result<()> {
log::info!("Setting smt enabled to {}", enabled);
let status = if enabled { "on" } else { "off" };
Expand All @@ -134,18 +134,18 @@ impl Cpu {
}

// Returns a list of features that the CPU supports
#[dbus_interface(property)]
#[zbus(property)]
pub async fn features(&self) -> fdo::Result<Vec<String>> {
get_features().await
}

/// Returns the total number of CPU cores detected
#[dbus_interface(property)]
#[zbus(property)]
pub async fn cores_count(&self) -> fdo::Result<u32> {
Ok(self.core_count)
}

#[dbus_interface(property)]
#[zbus(property)]
pub async fn cores_enabled(&self) -> fdo::Result<u32> {
let mut count = 0;
for core_list in self.core_map.values() {
Expand All @@ -159,7 +159,7 @@ impl Cpu {
Ok(count)
}

#[dbus_interface(property)]
#[zbus(property)]
pub async fn set_cores_enabled(&mut self, num: u32) -> fdo::Result<()> {
log::info!("Setting core count to {}", num);
if num < 1 {
Expand Down
18 changes: 9 additions & 9 deletions src/performance/gpu/connector.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
use std::fs;
use zbus::fdo;
use zbus_macros::dbus_interface;
use zbus_macros::interface;

/// Represents the data contained in /sys/class/drm/cardX-YYYY
pub struct Connector {
pub name: String,
pub path: String,
}

#[dbus_interface(name = "org.shadowblip.GPU.Card.Connector")]
#[interface(name = "org.shadowblip.GPU.Card.Connector")]
impl Connector {
#[dbus_interface(property)]
#[zbus(property)]
fn name(&self) -> String {
self.name.clone()
}

#[dbus_interface(property)]
#[zbus(property)]
fn path(&self) -> String {
self.path.clone()
}

#[dbus_interface(property)]
#[zbus(property)]
fn id(&self) -> fdo::Result<u32> {
let path = format!("{0}/{1}", self.path(), "connector_id");
let result = fs::read_to_string(path);
Expand All @@ -38,7 +38,7 @@ impl Connector {
Ok(id)
}

#[dbus_interface(property)]
#[zbus(property)]
fn enabled(&self) -> fdo::Result<bool> {
let path = format!("{0}/{1}", self.path(), "enabled");
let result = fs::read_to_string(path);
Expand All @@ -51,7 +51,7 @@ impl Connector {
Ok(status == "enabled")
}

#[dbus_interface(property)]
#[zbus(property)]
fn modes(&self) -> fdo::Result<Vec<String>> {
let mut modes: Vec<String> = Vec::new();
let path = format!("{0}/{1}", self.path(), "modes");
Expand All @@ -71,7 +71,7 @@ impl Connector {
Ok(modes)
}

#[dbus_interface(property)]
#[zbus(property)]
fn status(&self) -> fdo::Result<String> {
let path = format!("{0}/{1}", self.path(), "status");
let result = fs::read_to_string(path);
Expand All @@ -84,7 +84,7 @@ impl Connector {
Ok(status)
}

#[dbus_interface(property, name = "DPMS")]
#[zbus(property, name = "DPMS")]
fn dpms(&self) -> fdo::Result<bool> {
let path = format!("{0}/{1}", self.path(), "dpms");
let result = fs::read_to_string(path);
Expand Down
1 change: 1 addition & 0 deletions src/performance/gpu/dbus/devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::performance::gpu::{
tdp::{TDPDevice, TDPResult},
};

#[allow(clippy::large_enum_variant)]
pub enum TDPDevices {
Amd(amd::tdp::Tdp),
Intel(intel::tdp::Tdp),
Expand Down
Loading