✨ Add start-cosmic script; cosmic-session.target
This commit is contained in:
parent
7be35d6153
commit
bc07650f01
6 changed files with 74 additions and 2 deletions
7
Justfile
7
Justfile
|
|
@ -10,6 +10,7 @@ debug_args := if debug == '1' { '' } else { '--release' }
|
||||||
cargo_args := vendor_args + ' ' + debug_args
|
cargo_args := vendor_args + ' ' + debug_args
|
||||||
|
|
||||||
bindir := prefix + '/bin'
|
bindir := prefix + '/bin'
|
||||||
|
systemddir := prefix + '/lib/systemd/user'
|
||||||
sessiondir := prefix + '/share/wayland-sessions'
|
sessiondir := prefix + '/share/wayland-sessions'
|
||||||
|
|
||||||
all: _extract_vendor
|
all: _extract_vendor
|
||||||
|
|
@ -23,6 +24,12 @@ install:
|
||||||
# session desktop file
|
# session desktop file
|
||||||
install -Dm0644 data/cosmic.desktop {{sessiondir}}/cosmic.desktop
|
install -Dm0644 data/cosmic.desktop {{sessiondir}}/cosmic.desktop
|
||||||
|
|
||||||
|
# session start script
|
||||||
|
install -Dm0755 data/start-cosmic {{bindir}}/start-cosmic
|
||||||
|
|
||||||
|
# systemd target
|
||||||
|
install -Dm0644 data/cosmic-session.target {{systemddir}}/cosmic-session.target
|
||||||
|
|
||||||
clean_vendor:
|
clean_vendor:
|
||||||
rm -rf vendor vendor.tar .cargo/config
|
rm -rf vendor vendor.tar .cargo/config
|
||||||
|
|
||||||
|
|
|
||||||
5
data/cosmic-session.target
Normal file
5
data/cosmic-session.target
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Cosmic Session Target
|
||||||
|
Documentation=man:systemd.special(7)
|
||||||
|
BindsTo=graphical-session.target
|
||||||
|
Before=graphical-session.target
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=COSMIC
|
Name=COSMIC
|
||||||
Comment=This session logs you into the COSMIC desktop
|
Comment=This session logs you into the COSMIC desktop
|
||||||
Exec=/usr/bin/dbus-run-session -- /usr/bin/cosmic-session
|
Exec=/usr/bin/start-cosmic
|
||||||
TryExec=/usr/bin/cosmic-session
|
TryExec=/usr/bin/start-cosmic
|
||||||
Type=Application
|
Type=Application
|
||||||
DesktopNames=pop:COSMIC
|
DesktopNames=pop:COSMIC
|
||||||
|
|
|
||||||
28
data/start-cosmic
Executable file
28
data/start-cosmic
Executable file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# From: https://people.debian.org/~mpitt/systemd.conf-2016-graphical-session.pdf
|
||||||
|
|
||||||
|
# robustness: if the previous graphical session left some failed units,
|
||||||
|
# reset them so that they don't break this startup
|
||||||
|
for unit in $(systemctl --user --no-legend --state=failed --plain list-units | cut -f1 -d' '); do
|
||||||
|
partof="$(systemctl --user show -p PartOf --value "$unit")"
|
||||||
|
for target in cosmic-session.target graphical-session.target; do
|
||||||
|
if [ "$partof" = "$target" ]; then
|
||||||
|
systemctl --user reset-failed "$unit"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
# /etc/profile contains a lot of important environment variables
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:=pop:COSMIC}"
|
||||||
|
export XDG_SESSION_TYPE="${XDG_SESSION_TYPE:=wayland}"
|
||||||
|
export XCURSOR_THEME="${XCURSOR_THEME:=Adwaita}"
|
||||||
|
|
||||||
|
# import environment variables from the login manager
|
||||||
|
systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP
|
||||||
|
|
||||||
|
# Run cosmic-session
|
||||||
|
exec /usr/bin/dbus-run-session -- /usr/bin/cosmic-session
|
||||||
|
|
@ -5,6 +5,7 @@ extern crate tracing;
|
||||||
mod comp;
|
mod comp;
|
||||||
mod generic;
|
mod generic;
|
||||||
mod process;
|
mod process;
|
||||||
|
mod systemd;
|
||||||
|
|
||||||
use async_signals::Signals;
|
use async_signals::Signals;
|
||||||
use color_eyre::{eyre::WrapErr, Result};
|
use color_eyre::{eyre::WrapErr, Result};
|
||||||
|
|
@ -37,6 +38,9 @@ async fn main() -> Result<()> {
|
||||||
if let Err(err) = comp::run_compositor(token.child_token(), socket_rx, env_tx) {
|
if let Err(err) = comp::run_compositor(token.child_token(), socket_rx, env_tx) {
|
||||||
error!("compositor errored: {:?}", err);
|
error!("compositor errored: {:?}", err);
|
||||||
}
|
}
|
||||||
|
systemd::start_systemd_target()
|
||||||
|
.await
|
||||||
|
.wrap_err("failed to start systemd target")?;
|
||||||
let env_vars = env_rx
|
let env_vars = env_rx
|
||||||
.await
|
.await
|
||||||
.expect("failed to receive environmental variables")
|
.expect("failed to receive environmental variables")
|
||||||
|
|
|
||||||
28
src/systemd.rs
Normal file
28
src/systemd.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
use color_eyre::{
|
||||||
|
eyre::{eyre, WrapErr},
|
||||||
|
Result,
|
||||||
|
};
|
||||||
|
use tokio::process::Command;
|
||||||
|
|
||||||
|
pub async fn start_systemd_target() -> Result<()> {
|
||||||
|
let output = Command::new("systemctl")
|
||||||
|
.arg("--user")
|
||||||
|
.arg("start")
|
||||||
|
.arg("cosmic-session.target")
|
||||||
|
.spawn()
|
||||||
|
.wrap_err("failed to start systemd target")?
|
||||||
|
.wait()
|
||||||
|
.await
|
||||||
|
.wrap_err("failed to wait for systemd target to start")?;
|
||||||
|
|
||||||
|
if output.success() {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(eyre!(
|
||||||
|
"failed to start systemd target: code {}",
|
||||||
|
output.code().unwrap_or(-1),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue