use dbus-run-session and set XDG_CURRENT_DESKTOP

This commit is contained in:
Jeremy Soller 2024-03-19 21:11:21 -06:00
parent df9f2092e8
commit 1b13865ea0
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
2 changed files with 28 additions and 20 deletions

1
debian/control vendored
View file

@ -21,6 +21,7 @@ Depends:
bash,
cosmic-comp,
cosmic-greeter-daemon,
dbus,
greetd,
${misc:Depends},
${shlibs:Depends}

View file

@ -133,10 +133,9 @@ pub fn main() -> Result<(), Box<dyn Error>> {
.map(|dir| (dir, SessionType::Wayland))
.chain(
xdg::BaseDirectories::with_prefix("xsessions")
.map_or(
vec![PathBuf::from("/usr/share/xsessions")],
|xdg_dirs| xdg_dirs.get_data_dirs(),
)
.map_or(vec![PathBuf::from("/usr/share/xsessions")], |xdg_dirs| {
xdg_dirs.get_data_dirs()
})
.into_iter()
.map(|dir| (dir, SessionType::X11)),
);
@ -207,6 +206,8 @@ pub fn main() -> Result<(), Box<dyn Error>> {
SessionType::X11 => {
//TODO: xinit may be better, but more complicated to set up
vec![
"dbus-run-session".to_string(),
"--".to_string(),
"startx".to_string(),
"/usr/bin/env".to_string(),
"XDG_SESSION_TYPE=x11".to_string(),
@ -214,12 +215,18 @@ pub fn main() -> Result<(), Box<dyn Error>> {
}
SessionType::Wayland => {
vec![
"dbus-run-session".to_string(),
"--".to_string(),
"/usr/bin/env".to_string(),
"XDG_SESSION_TYPE=wayland".to_string(),
]
}
};
if let Some(desktop_names) = entry.section("Desktop Entry").attr("DesktopNames") {
command.push(format!("XDG_CURRENT_DESKTOP={desktop_names}"));
}
match shlex::split(exec) {
Some(args) => {
for arg in args {