Added detaching child process
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -695,6 +695,15 @@ dependencies = [
|
|||||||
"ttf-parser",
|
"ttf-parser",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fork"
|
||||||
|
version = "0.1.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9788ce090af4bf8d6e8f43d3f7d12305c787456387bd2d88856fcda3aa1f0dca"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "freedesktop_entry_parser"
|
name = "freedesktop_entry_parser"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
@@ -1536,6 +1545,7 @@ dependencies = [
|
|||||||
"directories",
|
"directories",
|
||||||
"dirs",
|
"dirs",
|
||||||
"ez-pixmap",
|
"ez-pixmap",
|
||||||
|
"fork",
|
||||||
"glam 0.22.0",
|
"glam 0.22.0",
|
||||||
"image",
|
"image",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ color-eyre = "0.6.2"
|
|||||||
directories = "4.0.1"
|
directories = "4.0.1"
|
||||||
dirs = "4.0.0"
|
dirs = "4.0.0"
|
||||||
ez-pixmap = "0.2.2"
|
ez-pixmap = "0.2.2"
|
||||||
|
fork = "0.1.20"
|
||||||
glam = { version = "0.22.0", features = ["mint"] }
|
glam = { version = "0.22.0", features = ["mint"] }
|
||||||
image = "0.24.5"
|
image = "0.24.5"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ impl Hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_coords(&self) -> [f32; 3]{
|
fn get_coords(&self) -> [f32; 3]{
|
||||||
let x: f32 = 3.0/2.0 * APP_SIZE.to_f32()/2.0 * (-self.q-self.s).to_f32();
|
let x = 3.0/2.0 * APP_SIZE/2.0 * (-self.q-self.s).to_f32();
|
||||||
let y = 3.0_f32.sqrt() * APP_SIZE.to_f32()/2.0 * ( (-self.q-self.s).to_f32()/2.0 + self.s.to_f32());
|
let y = 3.0_f32.sqrt() * APP_SIZE/2.0 * ( (-self.q-self.s).to_f32()/2.0 + self.s.to_f32());
|
||||||
[x,y,0.0]
|
[x,y,0.0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,20 +2,26 @@ use crate::xdg::{DesktopFile, Icon, IconType};
|
|||||||
use color_eyre::eyre::{eyre, Result};
|
use color_eyre::eyre::{eyre, Result};
|
||||||
use glam::Quat;
|
use glam::Quat;
|
||||||
use mint::Vector3;
|
use mint::Vector3;
|
||||||
use nix::unistd::{execv, fork};
|
use fork::{daemon, Fork, setsid};
|
||||||
use stardust_xr_fusion::{
|
use std::process::{Command,Stdio};
|
||||||
client::{Client, FrameInfo, RootHandler},
|
use std::os::unix::process::CommandExt;
|
||||||
core::values::Transform,
|
use stardust_xr_molecules::{
|
||||||
drawable::{MaterialParameter, Model, ResourceID},
|
fusion::{
|
||||||
fields::BoxField,
|
client::{Client, FrameInfo, RootHandler},
|
||||||
node::NodeType,
|
core::values::Transform,
|
||||||
spatial::Spatial,
|
drawable::{MaterialParameter, Model, ResourceID},
|
||||||
startup_settings::StartupSettings,
|
fields::BoxField,
|
||||||
|
node::NodeType,
|
||||||
|
spatial::Spatial,
|
||||||
|
startup_settings::StartupSettings,
|
||||||
|
},
|
||||||
|
GrabData, Grabbable,
|
||||||
};
|
};
|
||||||
use stardust_xr_molecules::{GrabData, Grabbable};
|
use stardust_xr_molecules::{GrabData, Grabbable};
|
||||||
use std::{f32::consts::PI, ffi::CStr, sync::Arc};
|
use std::{f32::consts::PI, ffi::CStr, sync::Arc};
|
||||||
use tween::{QuartInOut, Tweener};
|
use tween::{QuartInOut, Tweener};
|
||||||
use ustr::ustr;
|
use ustr::ustr;
|
||||||
|
use nix::unistd::fork;
|
||||||
|
|
||||||
fn model_from_icon(parent: &Spatial, icon: &Icon) -> Result<Model> {
|
fn model_from_icon(parent: &Spatial, icon: &Icon) -> Result<Model> {
|
||||||
|
|
||||||
@@ -55,6 +61,7 @@ pub struct ProtoStar {
|
|||||||
field: BoxField,
|
field: BoxField,
|
||||||
icon: Model,
|
icon: Model,
|
||||||
icon_shrink: Option<Tweener<f32, f64, QuartInOut>>,
|
icon_shrink: Option<Tweener<f32, f64, QuartInOut>>,
|
||||||
|
icon_grow: Option<Tweener<f32, f64, QuartInOut>>,
|
||||||
execute_command: String,
|
execute_command: String,
|
||||||
}
|
}
|
||||||
impl ProtoStar {
|
impl ProtoStar {
|
||||||
@@ -123,6 +130,7 @@ impl ProtoStar {
|
|||||||
field,
|
field,
|
||||||
icon,
|
icon,
|
||||||
icon_shrink: None,
|
icon_shrink: None,
|
||||||
|
icon_grow: None,
|
||||||
execute_command,
|
execute_command,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -140,9 +148,15 @@ impl RootHandler for ProtoStar {
|
|||||||
self.icon
|
self.icon
|
||||||
.set_scale(None, Vector3::from([scale; 3]))
|
.set_scale(None, Vector3::from([scale; 3]))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
}
|
||||||
self.client.stop_loop();
|
if let Some(icon_grow) = &mut self.icon_shrink {
|
||||||
|
if !icon_grow.is_finished(){
|
||||||
|
let scale = icon_grow.move_by(info.delta);
|
||||||
|
self.icon
|
||||||
|
.set_scale(None, Vector3::from([scale; 3]))
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if self.grabbable.grab_action().actor_stopped() {
|
} else if self.grabbable.grab_action().actor_stopped() {
|
||||||
let startup_settings = StartupSettings::create(&self.field.client().unwrap()).unwrap();
|
let startup_settings = StartupSettings::create(&self.field.client().unwrap()).unwrap();
|
||||||
self.icon
|
self.icon
|
||||||
@@ -164,19 +178,21 @@ impl RootHandler for ProtoStar {
|
|||||||
//TODO: split the executable string for the args
|
//TODO: split the executable string for the args
|
||||||
tokio::task::spawn(async move {
|
tokio::task::spawn(async move {
|
||||||
std::env::set_var("STARDUST_STARTUP_TOKEN", future.await.unwrap());
|
std::env::set_var("STARDUST_STARTUP_TOKEN", future.await.unwrap());
|
||||||
if unsafe { fork() }.unwrap().is_parent() {
|
unsafe {
|
||||||
println!("Launching \"{}\"...", &executable);
|
Command::new(executable)
|
||||||
execv::<&CStr>(
|
.stdin(Stdio::null())
|
||||||
ustr("/bin/sh").as_cstr(),
|
.stdout(Stdio::null())
|
||||||
&[
|
.stderr(Stdio::null())
|
||||||
ustr("/bin/sh").as_cstr(),
|
.pre_exec(|| {
|
||||||
ustr("-c").as_cstr(),
|
setsid();
|
||||||
ustr(&executable).as_cstr(),
|
Ok(())
|
||||||
],
|
})
|
||||||
)
|
.spawn()
|
||||||
.unwrap();
|
.expect("Failed to start child process")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
self.icon_grow = Some(Tweener::quart_in_out(0.00, 0.03, 0.25)); //TODO make the scale a parameter
|
||||||
|
dbg!("reached here");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user