add support files for cosmic-session
This commit is contained in:
parent
34bdcc4c47
commit
0db2927c86
6 changed files with 124 additions and 0 deletions
58
Makefile
Normal file
58
Makefile
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
export prefix ?= /usr
|
||||
sysconfdir ?= /etc
|
||||
bindir = $(prefix)/bin
|
||||
libdir = $(prefix)/lib
|
||||
sharedir = $(prefix)/share
|
||||
|
||||
BINARY = cosmic-comp
|
||||
ID = com.pop-os.Compositor
|
||||
TARGET = debug
|
||||
DEBUG ?= 0
|
||||
|
||||
.PHONY = all clean install uninstall vendor
|
||||
|
||||
ifeq ($(DEBUG),0)
|
||||
TARGET = release
|
||||
ARGS += --release
|
||||
endif
|
||||
|
||||
VENDOR ?= 0
|
||||
ifneq ($(VENDOR),0)
|
||||
ARGS += --frozen
|
||||
endif
|
||||
|
||||
TARGET_BIN="$(DESTDIR)$(bindir)/$(BINARY)"
|
||||
|
||||
all: extract-vendor
|
||||
cargo build $(ARGS)
|
||||
|
||||
clean:
|
||||
cargo clean
|
||||
|
||||
distclean:
|
||||
rm -rf .cargo vendor vendor.tar target
|
||||
|
||||
vendor:
|
||||
mkdir -p .cargo
|
||||
cargo vendor | head -n -1 > .cargo/config
|
||||
echo 'directory = "vendor"' >> .cargo/config
|
||||
tar pcf vendor.tar vendor
|
||||
rm -rf vendor
|
||||
|
||||
extract-vendor:
|
||||
ifeq ($(VENDOR),1)
|
||||
rm -rf vendor; tar pxf vendor.tar
|
||||
endif
|
||||
|
||||
install:
|
||||
install -Dm0644 "data/cosmic.desktop" "$(DESTDIR)$(sharedir)/wayland-sessions/cosmic.desktop"
|
||||
install -Dm0644 "data/cosmic-session.target" "$(DESTDIR)$(libdir)/systemd/user/cosmic-session.target"
|
||||
install -Dm0644 "data/cosmic-session-pre.target" "$(DESTDIR)$(libdir)/systemd/user/cosmic-session-pre.target"
|
||||
install -Dm0644 "data/cosmic-comp.service" "$(DESTDIR)$(libdir)/systemd/user/cosmic-comp.service"
|
||||
install -Dm04755 "data/cosmic-service" "$(DESTDIR)/$(bindir)/cosmic-service"
|
||||
install -Dm04755 "target/$(TARGET)/$(BINARY)" "$(TARGET_BIN)"
|
||||
|
||||
|
||||
uninstall:
|
||||
rm "$(DESTDIR)$(sharedir)/wayland-sessions/cosmic.desktop"
|
||||
rm "$(TARGET_BIN)"
|
||||
12
data/cosmic-comp.service
Normal file
12
data/cosmic-comp.service
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=Cosmic wayland compositor
|
||||
BindsTo=cosmic-session.target
|
||||
Wants=cosmic-session-pre.target
|
||||
After=cosmic-session-pre.target
|
||||
Before=cosmic-session.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/cosmic-comp
|
||||
Restart=never
|
||||
ExecStopPost=/usr/bin/systemctl --user unset-environment DISPLAY WAYLAND_DISPLAY
|
||||
32
data/cosmic-service
Normal file
32
data/cosmic-service
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#!/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=cosmic
|
||||
|
||||
# save environment variables that will be added to systemd
|
||||
new_env=$(systemctl --user show-environment | cut -d'=' -f 1 | sort | comm -13 - <(env | cut -d'=' -f 1 | sort))
|
||||
|
||||
# import environment variables from the login manager
|
||||
systemctl --user import-environment
|
||||
|
||||
# then start the service
|
||||
systemctl --wait --user start cosmic-comp.service
|
||||
|
||||
# cleanup environment
|
||||
systemctl --user unset-environment $new_env
|
||||
8
data/cosmic-session-pre.target
Normal file
8
data/cosmic-session-pre.target
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[Unit]
|
||||
Description=Cosmic session early services
|
||||
Documentation=man:systemd.special(7)
|
||||
RefuseManualStart=yes
|
||||
StopWhenUnneeded=yes
|
||||
BindsTo=graphical-session-pre.target
|
||||
Before=graphical-session-pre.target
|
||||
Before=cosmic-session.target
|
||||
7
data/cosmic-session.target
Normal file
7
data/cosmic-session.target
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[Unit]
|
||||
Description=Cosmic session
|
||||
Documentation=man:systemd.special(7)
|
||||
RefuseManualStart=yes
|
||||
StopWhenUnneeded=yes
|
||||
BindsTo=graphical-session.target
|
||||
Before=graphical-session.target
|
||||
7
data/cosmic.desktop
Normal file
7
data/cosmic.desktop
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[Desktop Entry]
|
||||
Name=Cosmic
|
||||
Commment=This session logs you into Cosmic
|
||||
Exec=/usr/bin/cosmic-service
|
||||
Type=Application
|
||||
DesktopNames=pop:COSMIC
|
||||
X-GDM-SessionRegisters=false
|
||||
Loading…
Add table
Add a link
Reference in a new issue