Skip to content

Commit

Permalink
Rename dbus. Add asus_armoury client source
Browse files Browse the repository at this point in the history
  • Loading branch information
flukejones committed Dec 26, 2024
1 parent 62aa1fe commit a1a9c70
Show file tree
Hide file tree
Showing 29 changed files with 203 additions and 131 deletions.
40 changes: 19 additions & 21 deletions asusctl/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ where
T: ProxyImpl<'static> + From<zbus::Proxy<'static>>,
{
let conn = zbus::blocking::Connection::system().unwrap();
let f =
zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "org.asuslinux.Daemon", "/").unwrap();
let f = zbus::blocking::fdo::ObjectManagerProxy::new(&conn, "xyz.ljones.Asusd", "/").unwrap();
let interfaces = f.get_managed_objects().unwrap();
let mut paths = Vec::new();
for v in interfaces.iter() {
Expand All @@ -155,7 +154,7 @@ where
ctrl.push(
T::builder(&conn)
.path(path.clone())?
.destination("org.asuslinux.Daemon")?
.destination("xyz.ljones.Asusd")?
.build()?,
);
}
Expand Down Expand Up @@ -201,7 +200,7 @@ fn do_parsed(
println!();
if let Some(cmdlist) = CliStart::command_list() {
let dev_type =
if let Ok(proxy) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") {
if let Ok(proxy) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
// TODO: commands on all?
proxy
.first()
Expand All @@ -214,32 +213,31 @@ fn do_parsed(
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
for command in commands.iter().filter(|command| {
if command.trim().starts_with("fan-curve")
&& !supported_interfaces
.contains(&"org.asuslinux.FanCurves".to_string())
&& !supported_interfaces.contains(&"xyz.ljones.FanCurves".to_string())
{
return false;
}

if command.trim().starts_with("aura")
&& !supported_interfaces.contains(&"org.asuslinux.Aura".to_string())
&& !supported_interfaces.contains(&"xyz.ljones.Aura".to_string())
{
return false;
}

if command.trim().starts_with("anime")
&& !supported_interfaces.contains(&"org.asuslinux.Anime".to_string())
&& !supported_interfaces.contains(&"xyz.ljones.Anime".to_string())
{
return false;
}

if command.trim().starts_with("slash")
&& !supported_interfaces.contains(&"org.asuslinux.Slash".to_string())
&& !supported_interfaces.contains(&"xyz.ljones.Slash".to_string())
{
return false;
}

if command.trim().starts_with("platform")
&& !supported_interfaces.contains(&"org.asuslinux.Platform".to_string())
&& !supported_interfaces.contains(&"xyz.ljones.Platform".to_string())
{
return false;
}
Expand Down Expand Up @@ -267,7 +265,7 @@ fn do_parsed(
}

if let Some(brightness) = &parsed.kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() {
match brightness.level() {
None => {
Expand All @@ -283,7 +281,7 @@ fn do_parsed(
}

if parsed.next_kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() {
let brightness = aura.brightness()?;
aura.set_brightness(brightness.next())?;
Expand All @@ -294,7 +292,7 @@ fn do_parsed(
}

if parsed.prev_kbd_bright {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
for aura in aura.iter() {
let brightness = aura.brightness()?;
aura.set_brightness(brightness.prev())?;
Expand All @@ -310,7 +308,7 @@ fn do_parsed(
"Supported Platform Properties:\n{:#?}",
supported_properties
);
if let Ok(aura) = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura") {
if let Ok(aura) = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura") {
// TODO: multiple RGB check
let bright = aura.first().unwrap().supported_brightness()?;
let modes = aura.first().unwrap().supported_basic_modes()?;
Expand Down Expand Up @@ -363,7 +361,7 @@ fn handle_anime(cmd: &AnimeCommand) -> Result<(), Box<dyn std::error::Error>> {
println!("\n{}", lst);
}
}
let animes = find_iface::<AnimeProxyBlocking>("org.asuslinux.Anime")?;
let animes = find_iface::<AnimeProxyBlocking>("xyz.ljones.Anime")?;
for proxy in animes {
if let Some(enable) = cmd.enable_display {
proxy.set_enable_display(enable)?;
Expand Down Expand Up @@ -556,7 +554,7 @@ fn handle_slash(cmd: &SlashCommand) -> Result<(), Box<dyn std::error::Error>> {
}
}

let slashes = find_iface::<SlashProxyBlocking>("org.asuslinux.Slash")?;
let slashes = find_iface::<SlashProxyBlocking>("xyz.ljones.Slash")?;
for proxy in slashes {
if cmd.enable {
proxy.set_enabled(true)?;
Expand Down Expand Up @@ -594,7 +592,7 @@ fn handle_scsi(cmd: &ScsiCommand) -> Result<(), Box<dyn std::error::Error>> {
}
}

let scsis = find_iface::<ScsiAuraProxyBlocking>("org.asuslinux.ScsiAura")?;
let scsis = find_iface::<ScsiAuraProxyBlocking>("xyz.ljones.ScsiAura")?;

for scsi in scsis {
if let Some(enable) = cmd.enable {
Expand Down Expand Up @@ -668,7 +666,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
if let Some(cmdlist) = LedModeCommand::command_list() {
let commands: Vec<String> = cmdlist.lines().map(|s| s.to_owned()).collect();
// TODO: multiple rgb check
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?;
let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
let modes = aura.first().unwrap().supported_basic_modes()?;
for command in commands.iter().filter(|command| {
for mode in &modes {
Expand Down Expand Up @@ -698,7 +696,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
println!("Please specify either next or previous");
return Ok(());
}
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?;
let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
if mode.next_mode {
for aura in aura {
let mode = aura.led_mode()?;
Expand Down Expand Up @@ -735,7 +733,7 @@ fn handle_led_mode(mode: &LedModeCommand) -> Result<(), Box<dyn std::error::Erro
}

fn handle_led_power1(power: &LedPowerCommand1) -> Result<(), Box<dyn std::error::Error>> {
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?;
let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
for aura in aura {
let dev_type = aura.device_type()?;
if !dev_type.is_old_laptop() && !dev_type.is_tuf_laptop() {
Expand Down Expand Up @@ -795,7 +793,7 @@ fn handle_led_power_1_do_1866(
}

fn handle_led_power2(power: &LedPowerCommand2) -> Result<(), Box<dyn std::error::Error>> {
let aura = find_iface::<AuraProxyBlocking>("org.asuslinux.Aura")?;
let aura = find_iface::<AuraProxyBlocking>("xyz.ljones.Aura")?;
for aura in aura {
let dev_type = aura.device_type()?;
if !dev_type.is_new_laptop() {
Expand Down
7 changes: 2 additions & 5 deletions asusd-user/src/ctrl_anime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,7 @@ impl CtrlAnime<'static> {
pub async fn add_to_server(self, server: &mut zbus::Connection) {
server
.object_server()
.at(
&ObjectPath::from_str_unchecked("/org/asuslinux/Anime"),
self,
)
.at(&ObjectPath::from_str_unchecked("/xyz/ljones/Anime"), self)
.await
.map_err(|err| {
println!("CtrlAnime: add_to_server {}", err);
Expand All @@ -170,7 +167,7 @@ impl CtrlAnime<'static> {
// - Do actions
// - Write config if required
// - Unset inner_early_return
#[interface(name = "org.asuslinux.Daemon")]
#[interface(name = "xyz.ljones.Asusd")]
impl CtrlAnime<'static> {
pub fn insert_asus_gif(
&mut self,
Expand Down
2 changes: 1 addition & 1 deletion asusd-user/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

let early_return = Arc::new(AtomicBool::new(false));
// Set up the anime data and run loop/thread
if supported.contains(&"org.asuslinux.Anime".to_string()) {
if supported.contains(&"xyz.ljones.Anime".to_string()) {
if let Some(cfg) = config.active_anime {
let anime_type = get_anime_type();
let anime_config = ConfigAnime::new().set_name(cfg).load();
Expand Down
11 changes: 4 additions & 7 deletions asusd-user/src/zbus_anime.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! # `DBus` interface proxy for: `org.asuslinux.Daemon`
//! # `DBus` interface proxy for: `xyz.ljones.Asusd`
//!
//! This code was generated by `zbus-xmlgen` `1.0.0` from `DBus` introspection
//! data. Source: `Interface '/org/asuslinux/Anime' from service
//! 'org.asuslinux.Daemon' on session bus`.
//! data. Source: `Interface '/xyz/ljones/Anime' from service
//! 'xyz.ljones.Asusd' on session bus`.
//!
//! You may prefer to adapt it, instead of using it verbatim.
//!
Expand All @@ -23,10 +23,7 @@

use zbus::proxy;

#[proxy(
interface = "org.asuslinux.Daemon",
default_path = "/org/asuslinux/Anime"
)]
#[proxy(interface = "xyz.ljones.Asusd", default_path = "/xyz/ljones/Anime")]
trait Daemon {
/// InsertAsusGif method
fn insert_asus_gif(
Expand Down
11 changes: 5 additions & 6 deletions asusd/src/asus_armoury/attr_enum_int.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use crate::{error::RogError, ASUS_ZBUS_PATH};
use log::error;
use rog_platform::firmware_attributes::{AttrValue, Attribute};
use serde::{Deserialize, Serialize};
use zbus::{
fdo, interface,
zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value},
Connection,
};
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
use zbus::{fdo, interface, Connection};

use crate::error::RogError;
use crate::ASUS_ZBUS_PATH;

const MOD_NAME: &str = "asus_armoury";

Expand Down
22 changes: 8 additions & 14 deletions asusd/src/asus_armoury/attr_enum_str.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use crate::{error::RogError, ASUS_ZBUS_PATH};
use log::error;
use rog_platform::firmware_attributes::{AttrType, AttrValue, Attribute};
use serde::{Deserialize, Serialize};
use zbus::{
fdo, interface,
zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value},
Connection,
};
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
use zbus::{fdo, interface, Connection};

use crate::error::RogError;
use crate::ASUS_ZBUS_PATH;

const MOD_NAME: &str = "asus_armoury";

Expand Down Expand Up @@ -50,15 +49,10 @@ impl AsusArmouryAttribute {
}

#[zbus(property)]
fn attribute_type(&self) -> AttrType {
self.0.attribute_type()
}

#[zbus(property)]
async fn default_value(&self) -> i32 {
async fn default_value(&self) -> String {
match self.0.default_value() {
AttrValue::Integer(i) => *i,
_ => -1,
AttrValue::String(s) => *s,
_ => String::default(),
}
}

Expand Down
14 changes: 7 additions & 7 deletions asusd/src/asus_armoury/attr_int.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use crate::{error::RogError, ASUS_ZBUS_PATH};
use log::error;
use rog_platform::firmware_attributes::{AttrValue, Attribute};
use serde::{Deserialize, Serialize};
use zbus::{
fdo, interface,
zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value},
Connection,
};
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Type, Value};
use zbus::{fdo, interface, Connection};

use crate::error::RogError;
use crate::ASUS_ZBUS_PATH;

const MOD_NAME: &str = "asus_armoury";

Expand Down Expand Up @@ -42,7 +41,8 @@ impl AsusArmouryAttribute {
}
}

/// If return is `-1` on a property then there is avilable value for that property
/// If return is `-1` on a property then there is avilable value for that
/// property
#[interface(name = "org.asuslinux.AsusArmoury")]
impl AsusArmouryAttribute {
#[zbus(property)]
Expand Down
2 changes: 1 addition & 1 deletion asusd/src/aura_anime/trait_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl AniMeZbus {
// None of these calls can be guarnateed to succeed unless we loop until okay
// If the try_lock *does* succeed then any other thread trying to lock will not
// grab it until we finish.
#[interface(name = "org.asuslinux.Anime")]
#[interface(name = "xyz.ljones.Anime")]
impl AniMeZbus {
/// Writes a data stream of length. Will force system thread to exit until
/// it is restarted
Expand Down
6 changes: 3 additions & 3 deletions asusd/src/aura_laptop/trait_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::error::RogError;
use crate::{CtrlTask, Reloadable};

pub const AURA_ZBUS_NAME: &str = "Aura";
pub const AURA_ZBUS_PATH: &str = "/org/asuslinux";
pub const AURA_ZBUS_PATH: &str = "/xyz/ljones";

#[derive(Clone)]
pub struct AuraZbus(Aura);
Expand Down Expand Up @@ -50,7 +50,7 @@ impl AuraZbus {
/// The main interface for changing, reading, or notfying
///
/// LED commands are split between Brightness, Modes, Per-Key
#[interface(name = "org.asuslinux.Aura")]
#[interface(name = "xyz.ljones.Aura")]
impl AuraZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
Expand Down Expand Up @@ -227,7 +227,7 @@ impl AuraZbus {

impl CtrlTask for AuraZbus {
fn zbus_path() -> &'static str {
"/org/asuslinux"
"/xyz/ljones"
}

async fn create_tasks(&self, _: SignalEmitter<'static>) -> Result<(), RogError> {
Expand Down
2 changes: 1 addition & 1 deletion asusd/src/aura_scsi/trait_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl ScsiZbus {
}
}

#[interface(name = "org.asuslinux.ScsiAura")]
#[interface(name = "xyz.ljones.ScsiAura")]
impl ScsiZbus {
/// Return the device type for this Aura keyboard
#[zbus(property)]
Expand Down
2 changes: 1 addition & 1 deletion asusd/src/aura_slash/trait_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl SlashZbus {
}
}

#[interface(name = "org.asuslinux.Slash")]
#[interface(name = "xyz.ljones.Slash")]
impl SlashZbus {
/// Get enabled or not
#[zbus(property)]
Expand Down
4 changes: 2 additions & 2 deletions asusd/src/ctrl_fancurves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::error::RogError;
use crate::{CtrlTask, CONFIG_PATH_BASE};

pub const FAN_CURVE_ZBUS_NAME: &str = "FanCurves";
pub const FAN_CURVE_ZBUS_PATH: &str = "/org/asuslinux";
pub const FAN_CURVE_ZBUS_PATH: &str = "/xyz/ljones";

#[derive(Deserialize, Serialize, Debug, Default)]
pub struct FanCurveConfig {
Expand Down Expand Up @@ -101,7 +101,7 @@ impl CtrlFanCurveZbus {
}
}

#[interface(name = "org.asuslinux.FanCurves")]
#[interface(name = "xyz.ljones.FanCurves")]
impl CtrlFanCurveZbus {
/// Set all fan curves for a profile to enabled status. Will also activate a
/// fan curve if in the same profile mode
Expand Down
4 changes: 2 additions & 2 deletions asusd/src/ctrl_platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::config::Config;
use crate::error::RogError;
use crate::{task_watch_item, task_watch_item_notify, CtrlTask, ReloadAndNotify};

const PLATFORM_ZBUS_PATH: &str = "/org/asuslinux";
const PLATFORM_ZBUS_PATH: &str = "/xyz/ljones";

macro_rules! platform_get_value {
($self:ident, $property:tt, $prop_name:literal) => {
Expand Down Expand Up @@ -302,7 +302,7 @@ impl CtrlPlatform {
}
}

#[interface(name = "org.asuslinux.Platform")]
#[interface(name = "xyz.ljones.Platform")]
impl CtrlPlatform {
#[zbus(property)]
async fn version(&self) -> String {
Expand Down
Loading

0 comments on commit a1a9c70

Please sign in to comment.