add --no-autostart arg

This commit is contained in:
galister 2026-04-22 17:36:04 +09:00
parent 1238808d87
commit 244822ffb3
5 changed files with 29 additions and 6 deletions

View File

@ -58,7 +58,11 @@ pub fn openvr_uninstall() {
}
#[allow(clippy::too_many_lines, clippy::cognitive_complexity)]
pub fn openvr_run(show_by_default: bool, headless: bool) -> Result<(), BackendError> {
pub fn openvr_run(
show_by_default: bool,
headless: bool,
no_autostart: bool,
) -> Result<(), BackendError> {
let app_type = EVRApplicationType::VRApplication_Overlay;
let Ok(context) = ovr_overlay::Context::init(app_type) else {
log::warn!("Will not use OpenVR: Context init failed");
@ -91,6 +95,8 @@ pub fn openvr_run(show_by_default: bool, headless: bool) -> Result<(), BackendEr
AppState::from_graphics(gfx, gfx_extras, XrBackend::OpenVR)?
};
app.session.no_autostart = no_autostart;
if show_by_default {
app.tasks.enqueue_at(
TaskType::Overlay(OverlayTask::ShowHide),

View File

@ -53,7 +53,11 @@ struct XrState {
}
#[allow(clippy::too_many_lines, clippy::cognitive_complexity)]
pub fn openxr_run(show_by_default: bool, headless: bool) -> Result<(), BackendError> {
pub fn openxr_run(
show_by_default: bool,
headless: bool,
no_autostart: bool,
) -> Result<(), BackendError> {
let (xr_instance, system) = match helpers::init_xr() {
Ok((xr_instance, system)) => (xr_instance, system),
Err(e) => {
@ -67,6 +71,8 @@ pub fn openxr_run(show_by_default: bool, headless: bool) -> Result<(), BackendEr
AppState::from_graphics(gfx, gfx_extras, XrBackend::OpenXR)?
};
app.session.no_autostart = no_autostart;
let modes = xr_instance.enumerate_environment_blend_modes(system, VIEW_TYPE)?;
if show_by_default {

View File

@ -84,6 +84,10 @@ struct Args {
#[arg(long)]
headless: bool,
/// Do not auto-start registered apps
#[arg(long)]
no_autostart: bool,
/// Path to write logs to
#[arg(short, long, value_name = "FILE_PATH")]
log_to: Option<String>,
@ -150,7 +154,7 @@ fn auto_run(args: Args, used_backend: &mut Option<XrBackend>) {
if !args_get_openvr(&args) {
use crate::backend::{BackendError, openxr::openxr_run};
tried_xr = true;
match openxr_run(args.show, args.headless) {
match openxr_run(args.show, args.headless, args.no_autostart) {
Ok(()) => {
used_backend.replace(XrBackend::OpenXR);
return;
@ -168,7 +172,7 @@ fn auto_run(args: Args, used_backend: &mut Option<XrBackend>) {
if !args_get_openxr(&args) {
use crate::backend::{BackendError, openvr::openvr_run};
tried_vr = true;
match openvr_run(args.show, args.headless) {
match openvr_run(args.show, args.headless, args.no_autostart) {
Ok(()) => {
used_backend.replace(XrBackend::OpenVR);
return;

View File

@ -73,8 +73,12 @@ impl DashFrontend {
fn new(app: &mut AppState) -> anyhow::Result<Self> {
let mut interface = DashInterfaceLive::new();
for p in app.session.config.autostart_apps.clone() {
let _ = interface.process_launch(app, false, p);
if app.session.no_autostart {
log::info!("Not starting apps due to --no-autostart")
} else {
for p in app.session.config.autostart_apps.clone() {
let _ = interface.process_launch(app, false, p);
}
}
let frontend = frontend::Frontend::new(frontend::InitParams {

View File

@ -218,6 +218,8 @@ pub struct AppSession {
pub config: GeneralConfig,
pub config_dirty: bool,
pub no_autostart: bool,
pub toast_topics: IdMap<ToastTopic, ToastDisplayMethod>,
}
@ -240,6 +242,7 @@ impl AppSession {
Self {
config,
toast_topics,
no_autostart: false,
config_dirty: false,
}
}