feat(startup settings): use /proc/{pid}/environ

This commit is contained in:
Nova
2022-12-10 09:17:37 -05:00
parent 004454d75e
commit 2315aca8b5
5 changed files with 68 additions and 33 deletions

View File

@@ -4,7 +4,7 @@ use super::{
};
use crate::{
core::{
client::{Client, INTERNAL_CLIENT},
client::{get_env, startup_settings, Client, INTERNAL_CLIENT},
registry::Registry,
},
nodes::{
@@ -68,7 +68,7 @@ impl PanelItem {
&nanoid!(),
true,
));
Spatial::add_to(&node, None, Mat4::IDENTITY, false).unwrap();
let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false).unwrap();
let specialization = ItemType::Panel(PanelItem {
node: Arc::downgrade(&node),
@@ -103,6 +103,13 @@ impl PanelItem {
node.add_local_signal("keyboard_deactivate", PanelItem::keyboard_deactivate_flex);
node.add_local_signal("keyboard_key_state", PanelItem::keyboard_key_state_flex);
node.add_local_signal("resize", PanelItem::resize_flex);
if let Some(startup_settings) = core_surface
.pid()
.and_then(|pid| get_env(pid).ok())
.and_then(|env| startup_settings(&env))
{
spatial.set_local_transform(startup_settings.transform);
}
node
}

View File

@@ -213,6 +213,18 @@ impl CoreSurface {
});
}
pub fn pid(&self) -> Option<i32> {
Some(
self.weak_surface
.upgrade()
.ok()?
.client()?
.get_credentials(&self.dh)
.ok()?
.pid,
)
}
pub fn wayland_state(&self) -> Arc<Mutex<WaylandState>> {
self.state.upgrade().unwrap()
}