Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ timedate-zbus = { git = "https://github.com/pop-os/dbus-settings-bindings" }
cosmic-randr-shell = { workspace = true }
kdl.workspace = true
color-eyre.workspace = true
which = "8.0.0"
Copy link
Contributor Author

@Pandapip1 Pandapip1 Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that it brings in a total of two other dependencies (winsafe and env_home). This seems reasonable, although obviously the former is unneeded.


[dependencies.greetd_ipc]
version = "0.10.3"
Expand Down
38 changes: 31 additions & 7 deletions src/greeter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ use tracing::metadata::LevelFilter;
use tracing::warn;
use tracing_subscriber::{EnvFilter, fmt, prelude::*};
use wayland_client::{Proxy, protocol::wl_output::WlOutput};
use which::which;
use zbus::{Connection, proxy};

use crate::{
Expand Down Expand Up @@ -184,6 +185,13 @@ pub fn main() -> Result<(), Box<dyn Error>> {
.map(|dir| (dir, SessionType::X11)),
);

//TODO: xinit may be better, but more complicated to set up
let startx_path_res = which("startx");
match startx_path_res {
Ok(_) => {},
Err(err) => tracing::warn!("Unable to find startx in path, skipping X11 sessions: {err:?}")
}

let sessions = {
let mut sessions = HashMap::new();
for (session_dir, session_type) in session_dirs {
Expand Down Expand Up @@ -250,9 +258,16 @@ pub fn main() -> Result<(), Box<dyn Error>> {
let mut env = Vec::new();
match session_type {
SessionType::X11 => {
//TODO: xinit may be better, but more complicated to set up
command.push("startx".to_string());
env.push("XDG_SESSION_TYPE=x11".to_string());
match startx_path_res {
Ok(ref startx_path) => {
command.push(startx_path.display().to_string());
env.push("XDG_SESSION_TYPE=x11".to_string());
},
Err(err) => {
// Don't add the broken session
continue;
}
}
}
SessionType::Wayland => {
env.push("XDG_SESSION_TYPE=wayland".to_string());
Expand All @@ -267,7 +282,8 @@ pub fn main() -> Result<(), Box<dyn Error>> {
}

// Session exec may contain environmental variables
command.push("/usr/bin/env".to_string());
let env_path = which("env").expect("env not in path");
command.push(env_path.display().to_string());

// To ensure the env is set correctly, we also set it in the session command
for arg in env.iter() {
Expand Down Expand Up @@ -460,7 +476,8 @@ struct Accessibility {
impl App {
/// Applies a display configuration via `cosmic-randr`.
fn exec_randr(&self, user_config: cosmic_randr_shell::List) -> Task<Message> {
let mut task = tokio::process::Command::new("cosmic-randr");
let cosmic_randr_path = which("cosmic-randr").expect("cosmic-randr not in path");
let mut task = tokio::process::Command::new(cosmic_randr_path.display().to_string());
task.arg("kdl");

cosmic::task::future::<(), ()>(async move {
Expand Down Expand Up @@ -1559,8 +1576,15 @@ impl cosmic::Application for App {
.as_mut()
.is_none_or(|c| c.try_wait().is_ok())
{
self.accessibility.screen_reader =
tokio::process::Command::new("/usr/bin/orca").spawn().ok();
match which("orca") {
Ok(orca_path) => {
self.accessibility.screen_reader =
tokio::process::Command::new(orca_path.display().to_string()).spawn().ok();
},
Err(err) => {
tracing::warn!("Screen reader enabled, but could not find orca: {err:?}");
}
}
} else {
if let Some(mut c) = self.accessibility.screen_reader.take() {
return cosmic::task::future::<(), ()>(async move {
Expand Down
20 changes: 20 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use clap_lex::RawArgs;
use cosmic_greeter::{greeter, locker};
use std::error::Error;
use which::which;

fn main() -> Result<(), Box<dyn Error>> {
let raw_args = RawArgs::from_args();
Expand All @@ -23,6 +24,25 @@ fn main() -> Result<(), Box<dyn Error>> {
env!("VERGEN_GIT_SHA")
);
return Ok(());
},
Some("--check-deps") => {
let mut failed = false;
for cmd in [ "orca", "env", "cosmic-randr", "startx" ] {
match which(cmd) {
Ok(cmd_path) => {
println!("Found {cmd} at: {}", cmd_path.display().to_string());
},
Err(err) => {
println!("Could not find {cmd} in PATH: {err:?}");
failed = true;
}
}
}
if failed {
return Err("failed to find at least one dependency".into())
} else {
return Ok(());
}
}
_ => {}
}
Expand Down