mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-10 00:20:29 -04:00
user: Clean up init
This commit is contained in:
parent
9e0338e189
commit
2977731fca
1 changed files with 7 additions and 12 deletions
19
src/user.rs
19
src/user.rs
|
@ -15,17 +15,20 @@ use zbus::ConnectionBuilder;
|
|||
use crate::daemon::Daemon;
|
||||
use crate::user_manager::SteamOSManagerUser;
|
||||
|
||||
async fn create_connection(system_conn: &Connection) -> Result<Connection> {
|
||||
async fn create_connections() -> Result<(Connection, Connection)> {
|
||||
let system = Connection::system().await?;
|
||||
let connection = ConnectionBuilder::session()?
|
||||
.name("com.steampowered.SteamOSManager1")?
|
||||
.build()
|
||||
.await?;
|
||||
let manager = SteamOSManagerUser::new(connection.clone(), system_conn).await?;
|
||||
|
||||
let manager = SteamOSManagerUser::new(connection.clone(), &system).await?;
|
||||
connection
|
||||
.object_server()
|
||||
.at("/com/steampowered/SteamOSManager1", manager)
|
||||
.await?;
|
||||
Ok(connection)
|
||||
|
||||
Ok((connection, system))
|
||||
}
|
||||
|
||||
pub async fn daemon() -> Result<()> {
|
||||
|
@ -35,15 +38,7 @@ pub async fn daemon() -> Result<()> {
|
|||
let stdout_log = fmt::layer();
|
||||
let subscriber = Registry::default().with(stdout_log);
|
||||
|
||||
let system = match Connection::system().await {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
let _guard = tracing::subscriber::set_default(subscriber);
|
||||
error!("Error connecting to DBus: {}", e);
|
||||
bail!(e);
|
||||
}
|
||||
};
|
||||
let _session = match create_connection(&system).await {
|
||||
let (_session, system) = match create_connections().await {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
let _guard = tracing::subscriber::set_default(subscriber);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue