mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-04 15:18:58 +00:00
feat: stardust config save includes autorun and stardust startup script
This commit is contained in:
parent
6a5f4dda35
commit
deee6a5033
1 changed files with 56 additions and 3 deletions
|
@ -1,8 +1,17 @@
|
||||||
use std::{fs::File, io::BufReader};
|
use std::{
|
||||||
|
fs::File,
|
||||||
|
io::{BufReader, Write},
|
||||||
|
path::Path,
|
||||||
|
};
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{ser::Error, Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{constants::CMD_NAME, file_utils::get_writer, paths::get_config_dir};
|
use crate::{
|
||||||
|
constants::CMD_NAME,
|
||||||
|
file_builders::monado_autorun::{get_monado_autorun_config, MonadoAutorun},
|
||||||
|
file_utils::get_writer,
|
||||||
|
paths::{get_config_dir, get_stardust_prefix},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct StardustExternalClient {
|
pub struct StardustExternalClient {
|
||||||
|
@ -62,6 +71,50 @@ impl StardustConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save(&self) -> Result<(), serde_json::Error> {
|
pub fn save(&self) -> Result<(), serde_json::Error> {
|
||||||
|
// monado autorun
|
||||||
|
{
|
||||||
|
let mut monado_config = get_monado_autorun_config();
|
||||||
|
let exec = get_stardust_prefix() + "/bin/stardust-xr-server";
|
||||||
|
// clear out all the stardust stuff in the autorun
|
||||||
|
monado_config.autoruns = monado_config
|
||||||
|
.autoruns
|
||||||
|
.iter()
|
||||||
|
.filter(|c| !c.exec.ends_with("stardust-xr-server"))
|
||||||
|
.cloned()
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
// and if we have it enabled and can use it, add it back with latest config
|
||||||
|
if self.autostart && Path::new(&exec).is_file() {
|
||||||
|
monado_config.autoruns.push(MonadoAutorun {
|
||||||
|
exec,
|
||||||
|
args: {
|
||||||
|
let mut args = vec![];
|
||||||
|
if self.disable_controller {
|
||||||
|
args.push("--disable-controller".into());
|
||||||
|
}
|
||||||
|
if self.start_as_overlay {
|
||||||
|
args.push("-o".into());
|
||||||
|
args.push(self.overlay_priority.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
args
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// stardust startup script
|
||||||
|
{
|
||||||
|
let startup_script_path = get_stardust_prefix() + "/startup_script";
|
||||||
|
let _ = std::fs::remove_file(&startup_script_path);
|
||||||
|
let mut startup_script =
|
||||||
|
std::fs::File::create(startup_script_path).map_err(serde_json::Error::custom)?;
|
||||||
|
writeln!(startup_script, "#!/bin/sh").map_err(serde_json::Error::custom)?;
|
||||||
|
// if self.flatland_enabled
|
||||||
|
// writeln!(startup_script,).map_err(serde_json::Error::custom)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
// then write the envision stardust config
|
||||||
let writer = get_writer(&Self::file_path());
|
let writer = get_writer(&Self::file_path());
|
||||||
serde_json::to_writer_pretty(writer, self)
|
serde_json::to_writer_pretty(writer, self)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue