mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-09 16:10:34 -04:00
Some basic structure.
Added some structures, enums, etc. to hold the data we will need. Added an initialize_apis that only looks for config files so far. TODO: Use zbus to create our service, register the name, etc. to start. Decide on a config file format (maybe after getting some zbus details fleshed out and knowing better what will fit well) Add error messages and don't fail on errors, just log them.
This commit is contained in:
parent
5fc50f4ac9
commit
666ac09607
3 changed files with 70 additions and 0 deletions
|
@ -6,3 +6,5 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.188", features = ["derive"] }
|
||||
zbus = "3.14.1"
|
||||
|
|
57
src/lib.rs
Normal file
57
src/lib.rs
Normal file
|
@ -0,0 +1,57 @@
|
|||
use std::fs;
|
||||
use std::{error::Error, future::pending};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use zbus::{ConnectionBuilder, dbus_interface};
|
||||
|
||||
// We use s(teamos)m(anager) prefix on all types to help avoid conflicts
|
||||
|
||||
// Types of api we support, so far only dbus and script.
|
||||
// For dbus type we call into other dbus apis specified.
|
||||
// For script type we run a script and provide stdout, stderr, and exitcode back.
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum SmApiType {
|
||||
DBusType = 0,
|
||||
ScriptType = 1,
|
||||
}
|
||||
|
||||
// SmDBusApi represents a dbus api to be called
|
||||
// TODO: This may change to better match what zbus needs.
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SmDbusApi {
|
||||
bus_name: String,
|
||||
object_path: String,
|
||||
method_name: String,
|
||||
// parameters: Vec
|
||||
}
|
||||
|
||||
// SmScript represents a script to be executed
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SmScript {
|
||||
path: String
|
||||
}
|
||||
// An SmOperation is what happens when an incoming dbus method is called.
|
||||
// If the SmEntry type is DBusType this should be a DBusApi with the data neede.
|
||||
// Otherwise it should be a script with the path to execute
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum SmOperation {
|
||||
SmScript(String),
|
||||
SmDbusApi(String, String, String)
|
||||
}
|
||||
|
||||
// Each api config file contains one or more entries.
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct SmEntry {
|
||||
api_type: SmApiType,
|
||||
incoming: SmDbusApi, // TBD: The incoming zbus method for this entry
|
||||
outgoing: SmOperation, // TBD: Either the outgoing zbus method or a script to run
|
||||
}
|
||||
|
||||
pub fn initialize_apis(path: String) -> Vec::<SmEntry>
|
||||
{
|
||||
let mut res = Vec::<SmEntry>::new();
|
||||
for file in fs::read_dir(path).unwrap() {
|
||||
// Deserialize the file and add all entries to res
|
||||
|
||||
}
|
||||
return res;
|
||||
}
|
11
src/main.rs
Normal file
11
src/main.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
use steamos_manager::{self, SmEntry, initialize_apis};
|
||||
|
||||
fn main() {
|
||||
// This daemon is responsible for creating a dbus api that steam client can use to do various OS
|
||||
// level things (change brightness, etc.) In order to do that it reads a folder of dbus api
|
||||
// configuration files and exposes each configuration with the api in the config file. In order
|
||||
// to know what to do with each it gets the information from the same config file about whether
|
||||
// to run a script or call some other dbus api.
|
||||
|
||||
let mut manager_apis: Vec<SmEntry> = initialize_apis("/usr/share/steamos-manager".to_string());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue