mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Add missing gfx dbus signal
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -29,7 +29,7 @@ checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asus-nb"
|
name = "asus-nb"
|
||||||
version = "2.0.0"
|
version = "2.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ctrl-gfx",
|
"ctrl-gfx",
|
||||||
"dbus",
|
"dbus",
|
||||||
@@ -46,7 +46,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asus-nb-ctrl"
|
name = "asus-nb-ctrl"
|
||||||
version = "2.0.0"
|
version = "2.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"asus-nb",
|
"asus-nb",
|
||||||
"ctrl-gfx",
|
"ctrl-gfx",
|
||||||
@@ -69,7 +69,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asus-notify"
|
name = "asus-notify"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"asus-nb",
|
"asus-nb",
|
||||||
"asus-nb-ctrl",
|
"asus-nb-ctrl",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "asus-nb-ctrl"
|
name = "asus-nb-ctrl"
|
||||||
version = "2.0.0"
|
version = "2.0.1"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = ["Luke <luke@ljones.dev>"]
|
authors = ["Luke <luke@ljones.dev>"]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use config::Config;
|
|||||||
use crate::error::RogError;
|
use crate::error::RogError;
|
||||||
use zbus::ObjectServer;
|
use zbus::ObjectServer;
|
||||||
|
|
||||||
pub static VERSION: &str = "2.0.0";
|
pub static VERSION: &str = "2.0.1";
|
||||||
|
|
||||||
pub trait Reloadable {
|
pub trait Reloadable {
|
||||||
fn reload(&mut self) -> Result<(), RogError>;
|
fn reload(&mut self) -> Result<(), RogError>;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "asus-nb"
|
name = "asus-nb"
|
||||||
version = "2.0.0"
|
version = "2.0.1"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = ["Luke <luke@ljones.dev>"]
|
authors = ["Luke <luke@ljones.dev>"]
|
||||||
|
|||||||
@@ -11,14 +11,15 @@ use std::sync::{
|
|||||||
};
|
};
|
||||||
use std::{thread, time::Duration};
|
use std::{thread, time::Duration};
|
||||||
|
|
||||||
use crate::dbus_gfx::OrgAsuslinuxDaemonNotifyGfx;
|
use crate::dbus_gfx::{OrgAsuslinuxDaemonNotifyGfx, OrgAsuslinuxDaemonNotifyAction};
|
||||||
use crate::dbus_ledmode::OrgAsuslinuxDaemonNotifyLed;
|
use crate::dbus_ledmode::OrgAsuslinuxDaemonNotifyLed;
|
||||||
use crate::dbus_profile::OrgAsuslinuxDaemonNotifyProfile;
|
use crate::dbus_profile::OrgAsuslinuxDaemonNotifyProfile;
|
||||||
use crate::dbus_charge::OrgAsuslinuxDaemonNotifyCharge;
|
use crate::dbus_charge::OrgAsuslinuxDaemonNotifyCharge;
|
||||||
|
|
||||||
// Signals separated out
|
// Signals separated out
|
||||||
pub struct CtrlSignals {
|
pub struct CtrlSignals {
|
||||||
pub gfx_signal: Arc<Mutex<Option<String>>>,
|
pub gfx_vendor_signal: Arc<Mutex<Option<String>>>,
|
||||||
|
pub gfx_action_signal: Arc<Mutex<Option<String>>>,
|
||||||
pub profile_signal: Arc<Mutex<Option<String>>>,
|
pub profile_signal: Arc<Mutex<Option<String>>>,
|
||||||
pub ledmode_signal: Arc<Mutex<Option<AuraModes>>>,
|
pub ledmode_signal: Arc<Mutex<Option<AuraModes>>>,
|
||||||
pub charge_signal: Arc<Mutex<Option<u8>>>,
|
pub charge_signal: Arc<Mutex<Option<u8>>>,
|
||||||
@@ -33,8 +34,8 @@ impl CtrlSignals {
|
|||||||
Duration::from_millis(5000),
|
Duration::from_millis(5000),
|
||||||
);
|
);
|
||||||
|
|
||||||
let gfx_signal = Arc::new(Mutex::new(None));
|
let gfx_vendor_signal = Arc::new(Mutex::new(None));
|
||||||
let gfx_res1 = gfx_signal.clone();
|
let gfx_res1 = gfx_vendor_signal.clone();
|
||||||
|
|
||||||
let _x = proxy.match_signal(
|
let _x = proxy.match_signal(
|
||||||
move |sig: OrgAsuslinuxDaemonNotifyGfx, _: &Connection, _: &Message| {
|
move |sig: OrgAsuslinuxDaemonNotifyGfx, _: &Connection, _: &Message| {
|
||||||
@@ -45,6 +46,18 @@ impl CtrlSignals {
|
|||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
let gfx_action_signal = Arc::new(Mutex::new(None));
|
||||||
|
let gfx_res1 = gfx_action_signal.clone();
|
||||||
|
|
||||||
|
let _x = proxy.match_signal(
|
||||||
|
move |sig: OrgAsuslinuxDaemonNotifyAction, _: &Connection, _: &Message| {
|
||||||
|
if let Ok(mut lock) = gfx_res1.lock() {
|
||||||
|
*lock = Some(sig.action);
|
||||||
|
}
|
||||||
|
true
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
//
|
//
|
||||||
let proxy = connection.with_proxy(
|
let proxy = connection.with_proxy(
|
||||||
"org.asuslinux.Daemon",
|
"org.asuslinux.Daemon",
|
||||||
@@ -105,7 +118,8 @@ impl CtrlSignals {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(CtrlSignals {
|
Ok(CtrlSignals {
|
||||||
gfx_signal,
|
gfx_vendor_signal,
|
||||||
|
gfx_action_signal,
|
||||||
profile_signal,
|
profile_signal,
|
||||||
ledmode_signal,
|
ledmode_signal,
|
||||||
charge_signal,
|
charge_signal,
|
||||||
@@ -149,7 +163,7 @@ impl AuraDbusClient {
|
|||||||
pub fn wait_gfx_changed(&self) -> Result<String, Box<dyn Error>> {
|
pub fn wait_gfx_changed(&self) -> Result<String, Box<dyn Error>> {
|
||||||
loop {
|
loop {
|
||||||
self.connection.process(Duration::from_micros(500))?;
|
self.connection.process(Duration::from_micros(500))?;
|
||||||
if let Ok(lock) = self.signals.gfx_signal.lock() {
|
if let Ok(lock) = self.signals.gfx_action_signal.lock() {
|
||||||
if let Some(stuff) = lock.as_ref() {
|
if let Some(stuff) = lock.as_ref() {
|
||||||
return Ok(stuff.to_string());
|
return Ok(stuff.to_string());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// This code was autogenerated with `dbus-codegen-rust -s -d org.asuslinux.Daemon -p /org/asuslinux/Gfx -m None -f org.asuslinux.Daemon -c blocking`, see https://github.com/diwic/dbus-rs
|
// This code was autogenerated with `dbus-codegen-rust -s -d org.asuslinux.Daemon -p /org/asuslinux/Gfx -m None -f org.asuslinux.Daemon -c blocking`, see https://github.com/diwic/dbus-rs
|
||||||
use dbus;
|
use dbus as dbus;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use dbus::arg;
|
use dbus::arg;
|
||||||
use dbus::blocking;
|
use dbus::blocking;
|
||||||
@@ -8,11 +8,10 @@ pub trait OrgAsuslinuxDaemon {
|
|||||||
fn set_vendor(&self, vendor: &str) -> Result<(), dbus::Error>;
|
fn set_vendor(&self, vendor: &str) -> Result<(), dbus::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target = T>> OrgAsuslinuxDaemon
|
impl<'a, T: blocking::BlockingSender, C: ::std::ops::Deref<Target=T>> OrgAsuslinuxDaemon for blocking::Proxy<'a, C> {
|
||||||
for blocking::Proxy<'a, C>
|
|
||||||
{
|
|
||||||
fn set_vendor(&self, vendor: &str) -> Result<(), dbus::Error> {
|
fn set_vendor(&self, vendor: &str) -> Result<(), dbus::Error> {
|
||||||
self.method_call("org.asuslinux.Daemon", "SetVendor", (vendor,))
|
self.method_call("org.asuslinux.Daemon", "SetVendor", (vendor, ))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +28,9 @@ impl arg::AppendAll for OrgAsuslinuxDaemonNotifyGfx {
|
|||||||
|
|
||||||
impl arg::ReadAll for OrgAsuslinuxDaemonNotifyGfx {
|
impl arg::ReadAll for OrgAsuslinuxDaemonNotifyGfx {
|
||||||
fn read(i: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
|
fn read(i: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
|
||||||
Ok(OrgAsuslinuxDaemonNotifyGfx { vendor: i.read()? })
|
Ok(OrgAsuslinuxDaemonNotifyGfx {
|
||||||
|
vendor: i.read()?,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,3 +38,27 @@ impl dbus::message::SignalArgs for OrgAsuslinuxDaemonNotifyGfx {
|
|||||||
const NAME: &'static str = "NotifyGfx";
|
const NAME: &'static str = "NotifyGfx";
|
||||||
const INTERFACE: &'static str = "org.asuslinux.Daemon";
|
const INTERFACE: &'static str = "org.asuslinux.Daemon";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct OrgAsuslinuxDaemonNotifyAction {
|
||||||
|
pub action: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl arg::AppendAll for OrgAsuslinuxDaemonNotifyAction {
|
||||||
|
fn append(&self, i: &mut arg::IterAppend) {
|
||||||
|
arg::RefArg::append(&self.action, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl arg::ReadAll for OrgAsuslinuxDaemonNotifyAction {
|
||||||
|
fn read(i: &mut arg::Iter) -> Result<Self, arg::TypeMismatchError> {
|
||||||
|
Ok(OrgAsuslinuxDaemonNotifyAction {
|
||||||
|
action: i.read()?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl dbus::message::SignalArgs for OrgAsuslinuxDaemonNotifyAction {
|
||||||
|
const NAME: &'static str = "NotifyAction";
|
||||||
|
const INTERFACE: &'static str = "org.asuslinux.Daemon";
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "asus-notify"
|
name = "asus-notify"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
authors = ["Luke D Jones <luke@ljones.dev>"]
|
authors = ["Luke D Jones <luke@ljones.dev>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
std::thread::sleep(Duration::from_millis(100));
|
std::thread::sleep(Duration::from_millis(100));
|
||||||
connection.process(std::time::Duration::from_millis(200))?;
|
connection.process(std::time::Duration::from_millis(200))?;
|
||||||
|
|
||||||
if let Ok(mut lock) = signals.gfx_signal.lock() {
|
if let Ok(mut lock) = signals.gfx_vendor_signal.lock() {
|
||||||
if let Some(vendor) = lock.take() {
|
if let Some(vendor) = lock.take() {
|
||||||
if let Some(notif) = last_gfx_notif.take() {
|
if let Some(notif) = last_gfx_notif.take() {
|
||||||
notif.close();
|
notif.close();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ pub struct CtrlGraphics {
|
|||||||
trait Dbus {
|
trait Dbus {
|
||||||
fn set_vendor(&mut self, vendor: String);
|
fn set_vendor(&mut self, vendor: String);
|
||||||
fn notify_gfx(&self, vendor: &str) -> zbus::Result<()>;
|
fn notify_gfx(&self, vendor: &str) -> zbus::Result<()>;
|
||||||
|
fn notify_action(&self, action: &str) -> zbus::Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "use-zbus")]
|
#[cfg(feature = "use-zbus")]
|
||||||
@@ -35,17 +36,22 @@ use std::convert::TryInto;
|
|||||||
impl Dbus for CtrlGraphics {
|
impl Dbus for CtrlGraphics {
|
||||||
fn set_vendor(&mut self, vendor: String) {
|
fn set_vendor(&mut self, vendor: String) {
|
||||||
if let Ok(tmp) = GfxVendors::from_str(&vendor) {
|
if let Ok(tmp) = GfxVendors::from_str(&vendor) {
|
||||||
self.set(tmp).unwrap_or_else(|err| {
|
let action = self.set(tmp).unwrap_or_else(|err| {
|
||||||
warn!("{}", err);
|
warn!("{}", err);
|
||||||
format!("Failed: {}", err.to_string())
|
format!("Failed: {}", err.to_string())
|
||||||
});
|
});
|
||||||
self.notify_gfx(&vendor)
|
self.notify_gfx(&vendor)
|
||||||
.unwrap_or_else(|err| warn!("{}", err));
|
.unwrap_or_else(|err| warn!("{}", err));
|
||||||
|
self.notify_action(&action)
|
||||||
|
.unwrap_or_else(|err| warn!("{}", err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[dbus_interface(signal)]
|
#[dbus_interface(signal)]
|
||||||
fn notify_gfx(&self, vendor: &str) -> zbus::Result<()>;
|
fn notify_gfx(&self, vendor: &str) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
#[dbus_interface(signal)]
|
||||||
|
fn notify_action(&self, action: &str) -> zbus::Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CtrlGraphics {
|
impl CtrlGraphics {
|
||||||
|
|||||||
@@ -55,4 +55,4 @@ static PRIMARY_GPU_NVIDIA: &[u8] = br#"
|
|||||||
Option "PrimaryGPU" "true""#;
|
Option "PrimaryGPU" "true""#;
|
||||||
|
|
||||||
static PRIMARY_GPU_END: &[u8] = br#"
|
static PRIMARY_GPU_END: &[u8] = br#"
|
||||||
EndSection"#;
|
EndSection"#;
|
||||||
Reference in New Issue
Block a user