NoSignal-OS/os updates/sudo-timed-nopasswd/patch-servicespage.sh
28allday 19fd794b6b NoSignal — fully-offline Arch → Hyprland desktop installer
Single-script builder (nosignal.sh) that turns a stock Arch Linux ISO into a
fully-offline installer for a themed Hyprland + caelestia (Quickshell) desktop:
matching SDDM greeter, Btrfs/Limine bootable snapshots, chwd-style GPU
detection, and a curated "os updates" layer (keybind cheatsheet, settings
panels, system polish, on-box management skill). See README.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 11:03:10 +01:00

41 lines
1.7 KiB
Bash
Executable file

#!/bin/sh
# patch-servicespage.sh — add the "Passwordless sudo (15 min)" toggle to the
# caelestia Settings -> Services page. Runs as root (installer, or the pacman
# hook after every caelestia-shell upgrade, which reverts ServicesPage.qml).
# Idempotent.
#
# 1. install SudoToggleRow.qml into nexus/common/ (untracked -> survives upgrades)
# 2. insert `SudoToggleRow {}` after the "Smart colour scheme" ToggleRow in
# ServicesPage.qml (re-applied by the hook each upgrade)
set -eu
SELF_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
NEXUS=${NEXUS:-/etc/xdg/quickshell/caelestia/modules/nexus}
COMMON="$NEXUS/common"
PAGE="$NEXUS/pages/ServicesPage.qml"
[ -f "$PAGE" ] || { echo "caelestia ServicesPage not found at $PAGE — nothing to patch"; exit 0; }
# 1. component type (auto-discovered via `import qs.modules.nexus.common`)
install -m 0644 "$SELF_DIR/SudoToggleRow.qml" "$COMMON/SudoToggleRow.qml"
# 2. insert the row (idempotent)
if grep -q 'SudoToggleRow' "$PAGE"; then
echo ":: ServicesPage already has the sudo toggle"
exit 0
fi
grep -q 'smartScheme = checked' "$PAGE" || {
echo "WARNING: anchor (Smart colour scheme ToggleRow) not found in ServicesPage — skipping insert" >&2
exit 0
}
cp -n "$PAGE" "$PAGE.pre-nosignal-sudoless" 2>/dev/null || true
perl -0pi -e 's/(onToggled: GlobalConfig\.services\.smartScheme = checked\n\s*\})/$1\n\n SudoToggleRow {\n Layout.fillWidth: true\n }/' "$PAGE"
if grep -q 'SudoToggleRow' "$PAGE"; then
echo ":: patched ServicesPage (sudo toggle added)"
else
echo "WARNING: ServicesPage insert did not take; restoring" >&2
[ -f "$PAGE.pre-nosignal-sudoless" ] && cp "$PAGE.pre-nosignal-sudoless" "$PAGE"
exit 1
fi