mirror of
https://github.com/theupriser/steamify-cachyos.git
synced 2026-10-03 17:41:58 +02:00
refactor: systemd units in services/, read with service_file like patches/
This commit is contained in:
1 parent
8a2601d73d
commit
8ffa0f2449
20 files changed
+147
-114
No files matched your search
+1
-13
@@ -23,19 +23,7 @@ boot_enable() {
|
||||
# the session into the base config; run it right away rather than rely
|
||||
# on its path unit, which could still be pending when the login manager
|
||||
# starts.
|
||||
sudo tee "$BOOT_UNIT" > /dev/null << EOF
|
||||
[Unit]
|
||||
Description=Steamify CachyOS: boot into the desktop instead of gaming mode
|
||||
Before=display-manager.service sddm.service plasmalogin.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/lib/steamos/steam-set-session plasma.desktop
|
||||
ExecStart=/bin/sh -c '[ -x $SESSION_SYNC ] && exec $SESSION_SYNC || true'
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical.target
|
||||
EOF
|
||||
service_file "$BOOT_UNIT_NAME" SESSION_SYNC="$SESSION_SYNC" | sudo tee "$BOOT_UNIT" > /dev/null
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable "$BOOT_UNIT_NAME" || { err "Enabling $BOOT_UNIT_NAME failed."; return 1; }
|
||||
ok "Boots into the desktop from the next boot on (Return to Gaming Mode still works)."
|
||||
|
||||
@@ -9,6 +9,17 @@ ok() { echo -e "${c_green}[OK]${c_reset} $*"; }
|
||||
# patch_file <name>: a file from patches/ (module sources, patches). The
|
||||
# single-file build replaces this with one that has them embedded.
|
||||
patch_file() { cat "$SCRIPT_DIR/patches/$1"; }
|
||||
# service_file <name> [KEY=value...]: a systemd unit from services/, with
|
||||
# each @KEY@ replaced by its value. The single-file build replaces
|
||||
# service_raw like patch_file.
|
||||
service_raw() { cat "$SCRIPT_DIR/services/$1"; }
|
||||
service_file() {
|
||||
local name="$1" kv
|
||||
local -a subst=(-e '')
|
||||
shift
|
||||
for kv in "$@"; do subst+=(-e "s|@${kv%%=*}@|${kv#*=}|g"); done
|
||||
service_raw "$name" | sed "${subst[@]}"
|
||||
}
|
||||
warn() { echo -e "${c_yellow}[WARN]${c_reset} $*"; }
|
||||
err() { echo -e "${c_red}[ERROR] $*${c_reset}" >&2; }
|
||||
ask_yn() {
|
||||
|
||||
+2
-21
@@ -211,28 +211,9 @@ EOF
|
||||
# 7. systemd path watcher + service
|
||||
info "Installing systemd path watcher so session switches take effect immediately"
|
||||
|
||||
sudo tee /etc/systemd/system/sync-steamos-session.path > /dev/null << 'EOF'
|
||||
[Unit]
|
||||
Description=Watch for steamos session changes
|
||||
service_file sync-steamos-session.path | sudo tee /etc/systemd/system/sync-steamos-session.path > /dev/null
|
||||
|
||||
[Path]
|
||||
PathModified=/etc/plasmalogin.conf.d/zz-steamos-autologin.conf
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
sudo tee /etc/systemd/system/sync-steamos-session.service > /dev/null << 'EOF'
|
||||
[Unit]
|
||||
Description=Sync steamos session selection into plasmalogin.conf
|
||||
# Session switches can come in bursts (switch + autologin reset); never
|
||||
# let systemd's start rate limit silently stop the bridge.
|
||||
StartLimitIntervalSec=0
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/sync-steamos-session.sh
|
||||
EOF
|
||||
service_file sync-steamos-session.service | sudo tee /etc/systemd/system/sync-steamos-session.service > /dev/null
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable --now sync-steamos-session.path
|
||||
|
||||
+1
-17
@@ -16,23 +16,7 @@ steam_enable() {
|
||||
systemd_user_dir="$HOME/.config/systemd/user"
|
||||
mkdir -p "$systemd_user_dir"
|
||||
|
||||
cat << 'EOF' > "$systemd_user_dir/steam-desktop-autostart.service"
|
||||
[Unit]
|
||||
Description=Steam Background Autostart for Virtual Keyboard
|
||||
After=graphical-session.target
|
||||
PartOf=graphical-session.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
# Only in the Plasma desktop session; gamescope-session starts its own Steam.
|
||||
ExecCondition=/bin/sh -c '[ "$XDG_CURRENT_DESKTOP" = KDE ]'
|
||||
ExecStart=/usr/bin/steam -silent
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session.target
|
||||
EOF
|
||||
service_file steam-desktop-autostart.service > "$systemd_user_dir/steam-desktop-autostart.service"
|
||||
|
||||
# Clean out old .desktop shortcut so they don't fight
|
||||
rm -f "$HOME/.config/autostart/steam.desktop"
|
||||
|
||||
+1
-13
@@ -312,19 +312,7 @@ echo "Installing missing kernel headers: ${missing[*]}"
|
||||
exec pacman -S --needed --noconfirm "${missing[@]}"
|
||||
EOF
|
||||
sudo chmod 755 "$HEADERS_SCRIPT"
|
||||
sudo tee "$HEADERS_UNIT" > /dev/null << EOF
|
||||
[Unit]
|
||||
Description=Install missing kernel headers so DKMS builds leds-valve for every kernel
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=$HEADERS_SCRIPT
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
service_file ensure-kernel-headers.service HEADERS_SCRIPT="$HEADERS_SCRIPT" | sudo tee "$HEADERS_UNIT" > /dev/null
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable ensure-kernel-headers.service
|
||||
}
|
||||
|
||||
+2
-28
@@ -39,34 +39,8 @@ notify_enable() {
|
||||
patch_file steamify-notifier.py | install_executable "$NOTIFY_SCRIPT" 755 ||
|
||||
{ err "Couldn't write $NOTIFY_SCRIPT."; return 1; }
|
||||
mkdir -p "$NOTIFY_UNITS"
|
||||
# PartOf the graphical session: the tray icon goes with a logout. The
|
||||
# short wait at login lets the tray come up first (in the script: an
|
||||
# ExecStartPre sleep runs into the start timeout).
|
||||
cat > "$NOTIFY_UNITS/$NOTIFY_NAME.service" << EOF
|
||||
[Unit]
|
||||
Description=Steamify: check for a new release
|
||||
After=plasma-workspace.target
|
||||
PartOf=graphical-session.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=$NOTIFY_SCRIPT --delay 60
|
||||
|
||||
[Install]
|
||||
WantedBy=plasma-workspace.target
|
||||
EOF
|
||||
cat > "$NOTIFY_UNITS/$NOTIFY_NAME.timer" << EOF
|
||||
[Unit]
|
||||
Description=Steamify: check for a new release daily
|
||||
|
||||
[Timer]
|
||||
OnCalendar=daily
|
||||
RandomizedDelaySec=1h
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOF
|
||||
service_file "$NOTIFY_NAME.service" NOTIFY_SCRIPT="$NOTIFY_SCRIPT" > "$NOTIFY_UNITS/$NOTIFY_NAME.service"
|
||||
service_file "$NOTIFY_NAME.timer" > "$NOTIFY_UNITS/$NOTIFY_NAME.timer"
|
||||
systemctl --user daemon-reload
|
||||
systemctl --user enable "$NOTIFY_NAME.service" >/dev/null 2>&1 &&
|
||||
systemctl --user enable --now "$NOTIFY_NAME.timer" >/dev/null 2>&1 ||
|
||||
|
||||
Reference in new issue
Block a user