From ce3083fad295869724293a5d1614d99d21ebd23b Mon Sep 17 00:00:00 2001 From: dingo Date: Mon, 10 Aug 2026 16:38:38 +0700 Subject: [PATCH] Patch D: install beside COSMIC, not over it The binary went to $(bindir)/cosmic-comp, which is the distro's own cosmic-comp. Installing this fork there replaces the compositor the stock COSMIC session runs, and that makes installing HyprCosmic a one-way door: if the fork fails to start, the session you would log into to fix it is now running the same broken binary. It goes to $(libexecdir)/hyprcosmic instead, which is where the hand-installed copy has been living all along -- this teaches the Makefile the layout rather than inventing one. Both sessions are meant to coexist. /usr/share/wayland-sessions holds cosmic.desktop and hyprcosmic.desktop side by side, and the greeter offers both; that only stays true while the two compositors occupy different paths. The two .ron files move out of `install` for a related reason. They are COSMIC's shared defaults, at paths the distro's cosmic-comp package already owns, so a HyprCosmic package installing them would conflict with that package over two files it has no reason to change -- and `uninstall` would have deleted the stock session's keybindings on the way out. The fork reads the stock copies, which costs nothing: a HyprCosmic session already needs the rest of COSMIC for the greeter, the portals and the settings daemon. `install-defaults` keeps them reachable for anyone building this fork without a COSMIC install to borrow from. Verified by staging into a DESTDIR: the result is byte-identical to the copy currently running from /usr/libexec/hyprcosmic/cosmic-comp. --- Makefile | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 16f59ee..b5c74ed 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ export prefix ?= /usr sysconfdir ?= /etc bindir = $(prefix)/bin libdir = $(prefix)/lib +libexecdir ?= $(prefix)/libexec sharedir = $(prefix)/share BINARY = cosmic-comp @@ -9,7 +10,7 @@ CARGO_TARGET_DIR ?= target TARGET = debug DEBUG ?= 0 -.PHONY = all clean install uninstall vendor +.PHONY = all clean install install-defaults uninstall vendor ifeq ($(DEBUG),0) TARGET = release @@ -21,7 +22,15 @@ ifneq ($(VENDOR),0) ARGS += --offline --locked endif -TARGET_BIN="$(DESTDIR)$(bindir)/$(BINARY)" +# HyprCosmic installs *beside* the distro's COSMIC rather than over it. Both +# sessions stay on the greeter's menu -- /usr/share/wayland-sessions holds +# cosmic.desktop and hyprcosmic.desktop at the same time -- which only works +# while this binary stays out of $(bindir)/cosmic-comp, where it would replace +# the compositor the stock session runs. A private directory is what keeps +# installing HyprCosmic from being a one-way door: if the fork misbehaves, the +# stock session is still there to log into and fix it from. +compdir ?= $(libexecdir)/hyprcosmic +TARGET_BIN="$(DESTDIR)$(compdir)/$(BINARY)" KEYBINDINGS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.Shortcuts/v1/defaults" TILING_EXCEPTIONS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.WindowRules/v1/tiling_exception_defaults" @@ -48,8 +57,19 @@ ifeq ($(VENDOR),1) rm -rf vendor; tar pxf vendor.tar endif +# The binary only. The two .ron files are COSMIC's *shared* defaults, and they +# sit at paths the distro's own cosmic-comp package already owns, so installing +# them from here would make a HyprCosmic package conflict with that one over two +# files it has no reason to change. The fork reads the stock copies instead -- +# which is honest, because a HyprCosmic session needs the rest of COSMIC present +# anyway for the greeter, the portals and the settings daemon. +# +# `install-defaults` keeps them reachable for anyone building this fork on its +# own, without a COSMIC install to borrow them from. install: install -Dm0755 "$(CARGO_TARGET_DIR)/$(TARGET)/$(BINARY)" "$(TARGET_BIN)" + +install-defaults: install -Dm0644 "data/keybindings.ron" "$(KEYBINDINGS_CONF)" install -Dm0644 "data/tiling-exceptions.ron" "$(TILING_EXCEPTIONS_CONF)" @@ -60,8 +80,11 @@ install-bare-session: install install -Dm0644 "data/cosmic-comp.service" "$(DESTDIR)$(libdir)/systemd/user/cosmic-comp.service" install -Dm0755 "data/cosmic-service" "$(DESTDIR)/$(bindir)/cosmic-service" +# Only what `install` placed. Removing KEYBINDINGS_CONF here would delete a file +# belonging to the distro's cosmic-comp, breaking the stock session on the way +# out -- the exact failure the private compdir above exists to prevent. uninstall: - rm "$(TARGET_BIN)" "$(KEYBINDINGS_CONF)" + rm "$(TARGET_BIN)" uninstall-bare-session: rm "$(DESTDIR)$(sharedir)/wayland-sessions/cosmic.desktop"