From e2ad40dfb9b2f000e8a03880bc43484c14d49fe4 Mon Sep 17 00:00:00 2001 From: rickpeters Date: Sun, 27 Sep 2026 15:59:17 +0200 Subject: [PATCH] refactor: The session sync and kernel headers scripts in patches/ --- CHANGELOG.md | 3 ++- lib/login-manager.sh | 19 +------------------ lib/steam-machine.sh | 17 +---------------- patches/README.md | 2 ++ patches/ensure-kernel-headers.sh | 14 ++++++++++++++ patches/sync-steamos-session.sh | 16 ++++++++++++++++ 6 files changed, 36 insertions(+), 35 deletions(-) create mode 100644 patches/ensure-kernel-headers.sh create mode 100644 patches/sync-steamos-session.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 64fe679..0d02441 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ one per merged pull request. ## 2.5.0 - 2026-09-27 -- **refactor: systemd units in services/, read with service_file like patches/** +- **refactor: The session sync and kernel headers scripts in patches/** +- `8ffa0f2` **refactor: systemd units in services/, read with service_file like patches/** - `8a2601d` **docs: README screenshot at 2.5.0 with Update notifications; AGENTS.md: retake it when rows change** - `572417b` **fix: Open Steamify from the notification starts the app (own scope), the same way it was last used (app or terminal)** - `cf73229` **feat: Update notifications: a notification and tray icon when there's a new Steamify** diff --git a/lib/login-manager.sh b/lib/login-manager.sh index 4cfde87..d2c4ea8 100644 --- a/lib/login-manager.sh +++ b/lib/login-manager.sh @@ -185,24 +185,7 @@ install_session_sync() { local SYNC_SCRIPT="/usr/local/bin/sync-steamos-session.sh" info "Installing session sync bridge at $SYNC_SCRIPT" - sudo tee "$SYNC_SCRIPT" > /dev/null << 'EOF' -#!/bin/bash -SRC="/etc/plasmalogin.conf.d/zz-steamos-autologin.conf" -DEST="/etc/plasmalogin.conf" - -[[ -f "$SRC" ]] || exit 0 -SESSION=$(grep -oP '^Session=\K.*' "$SRC") -[[ -z "$SESSION" ]] && exit 0 - -# Only touch Session= inside [Autologin]; other sections may have their own. -if sed -n '/^\[Autologin\]/,/^\[/p' "$DEST" | grep -q '^Session='; then - sed -i "/^\[Autologin\]/,/^\[/ s|^Session=.*|Session=$SESSION|" "$DEST" -elif grep -q '^\[Autologin\]' "$DEST"; then - sed -i "/^\[Autologin\]/a Session=$SESSION" "$DEST" -else - printf '\n[Autologin]\nSession=%s\n' "$SESSION" >> "$DEST" -fi -EOF + patch_file sync-steamos-session.sh | sudo tee "$SYNC_SCRIPT" > /dev/null sudo chmod +x "$SYNC_SCRIPT" ok "Sync script installed." diff --git a/lib/steam-machine.sh b/lib/steam-machine.sh index 0758682..348e717 100644 --- a/lib/steam-machine.sh +++ b/lib/steam-machine.sh @@ -295,22 +295,7 @@ install_headers_boot_check() { # So check at every boot and install missing headers, which triggers # that hook and builds the driver for the new kernel. sudo mkdir -p "$(dirname "$HEADERS_SCRIPT")" - sudo tee "$HEADERS_SCRIPT" > /dev/null << 'EOF' -#!/bin/bash -# Installed by cachyos-gamescope-boot: install missing -headers for every -# installed kernel, so DKMS builds leds-valve for it. -set -u -missing=() -for k in $(pacman -Qqo /usr/lib/modules/*/pkgbase 2>/dev/null | sort -u); do - pacman -Q "${k}-headers" >/dev/null 2>&1 && continue - pacman -Si "${k}-headers" >/dev/null 2>&1 && missing+=("${k}-headers") -done -[[ ${#missing[@]} -eq 0 ]] && exit 0 -# Another pacman is running (e.g. an update): try again next boot. -[[ -e /var/lib/pacman/db.lck ]] && { echo "pacman is busy, skipping"; exit 0; } -echo "Installing missing kernel headers: ${missing[*]}" -exec pacman -S --needed --noconfirm "${missing[@]}" -EOF + patch_file ensure-kernel-headers.sh | sudo tee "$HEADERS_SCRIPT" > /dev/null sudo chmod 755 "$HEADERS_SCRIPT" service_file ensure-kernel-headers.service HEADERS_SCRIPT="$HEADERS_SCRIPT" | sudo tee "$HEADERS_UNIT" > /dev/null sudo systemctl daemon-reload diff --git a/patches/README.md b/patches/README.md index edd8556..9a88df6 100644 --- a/patches/README.md +++ b/patches/README.md @@ -7,5 +7,7 @@ read and reviewed on their own. `lib/*.sh` reads them with `patch_file | File | Used by | What | |---|---|---| | `steamify-fremont-poweroff.c` | `lib/fremont-poweroff.sh` (Steam Machine support) | Kernel module (DKMS): clears GPIO 18's S4/S5 wake bit before power-off, so the Steam Machine stays off with recent kernels | +| `sync-steamos-session.sh` | `lib/login-manager.sh` (SteamOS conversion, plasma-login-manager) | The sync bridge: copies Steam's session choice from `zz-steamos-autologin.conf` into `plasmalogin.conf`'s `[Autologin]` | +| `ensure-kernel-headers.sh` | `lib/steam-machine.sh` (Steam Machine support) | Run at boot: installs missing headers for every installed kernel | | `steamify-notifier.py` | `lib/update-notifier.sh` (Update notifications) | The daily check: notification and tray icon when there's a new release | | `cros-ec-cec-single-port.patch` | `lib/cec.sh` (HDMI-CEC) | Makes Valve's Steam Machine CEC driver find amdgpu's HDMI port | diff --git a/patches/ensure-kernel-headers.sh b/patches/ensure-kernel-headers.sh new file mode 100644 index 0000000..ca69b41 --- /dev/null +++ b/patches/ensure-kernel-headers.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Installed by cachyos-gamescope-boot: install missing -headers for every +# installed kernel, so DKMS builds leds-valve for it. +set -u +missing=() +for k in $(pacman -Qqo /usr/lib/modules/*/pkgbase 2>/dev/null | sort -u); do + pacman -Q "${k}-headers" >/dev/null 2>&1 && continue + pacman -Si "${k}-headers" >/dev/null 2>&1 && missing+=("${k}-headers") +done +[[ ${#missing[@]} -eq 0 ]] && exit 0 +# Another pacman is running (e.g. an update): try again next boot. +[[ -e /var/lib/pacman/db.lck ]] && { echo "pacman is busy, skipping"; exit 0; } +echo "Installing missing kernel headers: ${missing[*]}" +exec pacman -S --needed --noconfirm "${missing[@]}" diff --git a/patches/sync-steamos-session.sh b/patches/sync-steamos-session.sh new file mode 100644 index 0000000..518d151 --- /dev/null +++ b/patches/sync-steamos-session.sh @@ -0,0 +1,16 @@ +#!/bin/bash +SRC="/etc/plasmalogin.conf.d/zz-steamos-autologin.conf" +DEST="/etc/plasmalogin.conf" + +[[ -f "$SRC" ]] || exit 0 +SESSION=$(grep -oP '^Session=\K.*' "$SRC") +[[ -z "$SESSION" ]] && exit 0 + +# Only touch Session= inside [Autologin]; other sections may have their own. +if sed -n '/^\[Autologin\]/,/^\[/p' "$DEST" | grep -q '^Session='; then + sed -i "/^\[Autologin\]/,/^\[/ s|^Session=.*|Session=$SESSION|" "$DEST" +elif grep -q '^\[Autologin\]' "$DEST"; then + sed -i "/^\[Autologin\]/a Session=$SESSION" "$DEST" +else + printf '\n[Autologin]\nSession=%s\n' "$SESSION" >> "$DEST" +fi