🐛 Whoops, I'm supposed to use WAYLAND_DISPLAY, not WAYLAND_SOCKET (thanks @Drakulix!)
This commit is contained in:
parent
1350cd4335
commit
be2b800716
3 changed files with 18 additions and 19 deletions
12
src/comp.rs
12
src/comp.rs
|
|
@ -3,12 +3,10 @@ use crate::process::{ProcessEvent, ProcessHandler};
|
||||||
use tokio::sync::{mpsc::unbounded_channel, oneshot};
|
use tokio::sync::{mpsc::unbounded_channel, oneshot};
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
|
|
||||||
pub async fn run_compositor(token: CancellationToken, wayland_socket_tx: oneshot::Sender<String>) {
|
pub async fn run_compositor(token: CancellationToken, wayland_display_tx: oneshot::Sender<String>) {
|
||||||
let mut wayland_socket_tx = Some(wayland_socket_tx);
|
let mut wayland_display_tx = Some(wayland_display_tx);
|
||||||
let (tx, mut rx) = unbounded_channel::<ProcessEvent>();
|
let (tx, mut rx) = unbounded_channel::<ProcessEvent>();
|
||||||
ProcessHandler::new(tx, &token).run("cosmic-comp", vec![], vec![]);
|
ProcessHandler::new(tx, &token).run("cosmic-comp", vec![], vec![]);
|
||||||
let span = info_span!("cosmic-comp");
|
|
||||||
let _enter = span.enter();
|
|
||||||
while let Some(event) = rx.recv().await {
|
while let Some(event) = rx.recv().await {
|
||||||
match event {
|
match event {
|
||||||
ProcessEvent::Started => {
|
ProcessEvent::Started => {
|
||||||
|
|
@ -18,13 +16,13 @@ pub async fn run_compositor(token: CancellationToken, wayland_socket_tx: oneshot
|
||||||
ProcessEvent::Stdout(line) | ProcessEvent::Stderr(line) => {
|
ProcessEvent::Stdout(line) | ProcessEvent::Stderr(line) => {
|
||||||
if line.contains("Listening on \"") {
|
if line.contains("Listening on \"") {
|
||||||
// Message format: Listening on "wayland-0"
|
// Message format: Listening on "wayland-0"
|
||||||
if let Some(tx) = wayland_socket_tx.take() {
|
if let Some(tx) = wayland_display_tx.take() {
|
||||||
let socket_name = line
|
let socket_name = line
|
||||||
.split('"')
|
.split('"')
|
||||||
.nth(1)
|
.nth(1)
|
||||||
.expect("failed to get WAYLAND_SOCKET");
|
.expect("failed to get WAYLAND_DISPLAY");
|
||||||
tx.send(socket_name.to_string())
|
tx.send(socket_name.to_string())
|
||||||
.expect("failed to send WAYLAND_SOCKET back to main app");
|
.expect("failed to send WAYLAND_DISPLAY back to main app");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info!("{}", line);
|
info!("{}", line);
|
||||||
|
|
|
||||||
17
src/main.rs
17
src/main.rs
|
|
@ -31,22 +31,25 @@ async fn main() -> Result<()> {
|
||||||
info!("Starting cosmic-session");
|
info!("Starting cosmic-session");
|
||||||
|
|
||||||
let token = CancellationToken::new();
|
let token = CancellationToken::new();
|
||||||
let (wayland_socket_tx, wayland_socket_rx) = oneshot::channel();
|
let (wayland_display_tx, wayland_display_rx) = oneshot::channel();
|
||||||
tokio::spawn(comp::run_compositor(token.child_token(), wayland_socket_tx));
|
tokio::spawn(comp::run_compositor(
|
||||||
let wayland_socket = wayland_socket_rx
|
token.child_token(),
|
||||||
|
wayland_display_tx,
|
||||||
|
));
|
||||||
|
let wayland_display = wayland_display_rx
|
||||||
.await
|
.await
|
||||||
.expect("failed to get WAYLAND_SOCKET");
|
.expect("failed to get WAYLAND_DISPLAY");
|
||||||
info!("got WAYLAND_SOCKET: {}", wayland_socket);
|
info!("got WAYLAND_DISPLAY: {}", wayland_display);
|
||||||
|
|
||||||
tokio::spawn(panel::run_panel(
|
tokio::spawn(panel::run_panel(
|
||||||
token.child_token(),
|
token.child_token(),
|
||||||
"testing-panel",
|
"testing-panel",
|
||||||
wayland_socket.clone(),
|
wayland_display.clone(),
|
||||||
));
|
));
|
||||||
tokio::spawn(panel::run_panel(
|
tokio::spawn(panel::run_panel(
|
||||||
token.child_token(),
|
token.child_token(),
|
||||||
"testing-dock",
|
"testing-dock",
|
||||||
wayland_socket.clone(),
|
wayland_display.clone(),
|
||||||
));
|
));
|
||||||
|
|
||||||
let mut signals = Signals::new(vec![libc::SIGTERM, libc::SIGINT]).unwrap();
|
let mut signals = Signals::new(vec![libc::SIGTERM, libc::SIGINT]).unwrap();
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,12 @@ use crate::process::{ProcessEvent, ProcessHandler};
|
||||||
use tokio::sync::mpsc::unbounded_channel;
|
use tokio::sync::mpsc::unbounded_channel;
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
|
|
||||||
pub async fn run_panel(token: CancellationToken, config: &str, wayland_socket: String) {
|
pub async fn run_panel(token: CancellationToken, config: &str, wayland_display: String) {
|
||||||
let (tx, mut rx) = unbounded_channel::<ProcessEvent>();
|
let (tx, mut rx) = unbounded_channel::<ProcessEvent>();
|
||||||
ProcessHandler::new(tx, &token).run("cosmic-panel", vec![config.to_string()], vec![(
|
ProcessHandler::new(tx, &token).run("cosmic-panel", vec![config.to_string()], vec![(
|
||||||
"WAYLAND_SOCKET".into(),
|
"WAYLAND_DISPLAY".into(),
|
||||||
wayland_socket,
|
wayland_display,
|
||||||
)]);
|
)]);
|
||||||
let span = info_span!("cosmic-panel");
|
|
||||||
let _enter = span.enter();
|
|
||||||
while let Some(event) = rx.recv().await {
|
while let Some(event) = rx.recv().await {
|
||||||
match event {
|
match event {
|
||||||
ProcessEvent::Started => {
|
ProcessEvent::Started => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue