mirror of
https://github.com/outbackdingo/hyprcosmic-session.git
synced 2026-08-25 14:53:23 +00:00
Add session profiles so HyprCosmic can replace the COSMIC shell
Upstream hardcodes the set of cosmic-* components a session launches. HyprCosmic needs cosmic-comp for window management but waybar and rofi in place of cosmic-panel and cosmic-launcher, so `profile` gates that set. The default profile is upstream behaviour exactly, and it is what an unconfigured build gets; the alternate set is opt-in through HYPRCOSMIC_PROFILE, which only the new session entry sets. So installing this fork cannot change how the stock session boots, and a broken HyprCosmic config is always one logout away from being escaped. Gating lives at the single definition of `start_component` rather than at its call sites, keeping the diff against upstream small enough to rebase against a fast-moving tree. cosmic-panel and cosmic-notifications are the exception: they are started as a coupled pair sharing notification fds and cannot go through that path, so they are gated where they are spawned (hence the re-indentation in the diff). cosmic-greeter is deliberately never disabled - a display manager is the easiest thing to lock yourself out of. cosmic-osd and cosmic-idle stay too, since HyDE's equivalents are separate programs a user may not have and neither competes with waybar for layer-shell space. Verified: 5 unit tests over profile selection and extras parsing; `cargo check -j1` and `cargo build -j1` clean. NOT verified: the gating has never been observed at runtime. Two attempts to run this session nested inside the live desktop logged the developer out instead, so runtime confirmation is deferred to logging into the hyprcosmic.desktop entry from the greeter. Two hazards found along the way and worth recording: name-matching (pkill/pgrep) cannot distinguish this fork's processes from the live session's, and a nested cosmic-session steals the well-known D-Bus name com.system76.CosmicSession from the running session unless it is given a private bus.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
[Desktop Entry]
|
||||
Name=HyprCosmic
|
||||
Comment=COSMIC's compositor with a HyDE-style shell
|
||||
Exec=/usr/bin/start-hyprcosmic
|
||||
Type=Application
|
||||
DesktopNames=COSMIC
|
||||
Keywords=hyprland;hyde;waybar;cosmic;
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/bash
|
||||
#
|
||||
# Launch a HyprCosmic session: cosmic-comp for window management, HyDE's shell
|
||||
# on top.
|
||||
#
|
||||
# Deliberately separate from /usr/bin/start-cosmic rather than patching it.
|
||||
# The stock COSMIC session entry keeps working untouched, so a broken
|
||||
# HyprCosmic config is always one logout away from being escaped — which
|
||||
# matters when the thing you are replacing is your desktop.
|
||||
|
||||
set -e
|
||||
|
||||
# Default to the installed binaries. Override either one to point at an
|
||||
# in-tree debug build when testing the fork without installing it.
|
||||
HYPRCOSMIC_SESSION_BIN="${HYPRCOSMIC_SESSION_BIN:-/usr/bin/cosmic-session}"
|
||||
HYPRCOSMIC_COMP_BIN="${HYPRCOSMIC_COMP_BIN:-cosmic-comp}"
|
||||
|
||||
# Selects the component set in cosmic-session's profile module: cosmic-panel,
|
||||
# cosmic-launcher, cosmic-app-library, cosmic-workspaces, cosmic-bg and
|
||||
# cosmic-files-applet are skipped; waybar and friends come from
|
||||
# ~/.config/hyprcosmic/autostart.
|
||||
export HYPRCOSMIC_PROFILE=hyprcosmic
|
||||
|
||||
# Keep COSMIC's identity: portals, cosmic-settings and any COSMIC app still
|
||||
# key off this, and the compositor underneath really is COSMIC.
|
||||
export XDG_CURRENT_DESKTOP="${XDG_CURRENT_DESKTOP:-COSMIC}"
|
||||
export XDG_SESSION_DESKTOP="${XDG_SESSION_DESKTOP:-hyprcosmic}"
|
||||
|
||||
# Same hygiene as start-cosmic: a failed unit left by a previous graphical
|
||||
# session will otherwise block this one from starting.
|
||||
if command -v systemctl >/dev/null; then
|
||||
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
|
||||
fi
|
||||
|
||||
# cosmic-session takes the compositor to launch as its first argument
|
||||
# (main.rs: `args.next().unwrap_or_else(|| String::from("cosmic-comp"))`),
|
||||
# which is how a forked cosmic-comp gets used without replacing the system one.
|
||||
if [[ -z "${DBUS_SESSION_BUS_ADDRESS}" ]]; then
|
||||
exec /usr/bin/dbus-run-session -- "${HYPRCOSMIC_SESSION_BIN}" "${HYPRCOSMIC_COMP_BIN}"
|
||||
else
|
||||
exec "${HYPRCOSMIC_SESSION_BIN}" "${HYPRCOSMIC_COMP_BIN}"
|
||||
fi
|
||||
Reference in New Issue
Block a user