aerothemeplasma/misc/libplasma/install.sh
wackyideas 6ff6ef2e12 Improve libplasma installation method
Up until now compiling libplasma modifications was rather violent as it
would cause both plasmashell and kwin to crash (the latter is
potentially destructive if running a Wayland session), leaving the user
with a potentially unstable state where plasmashell will start to
crashloop until the entire system reboots.

With this commit, the replacement of patched library files is deferred
until the system restarts, by using a temporary systemd service that
performs the replacement of files before Plasma starts, leading to
no crashes during the install or update process.
2025-10-20 17:37:54 +02:00

68 lines
1.9 KiB
Bash

#!/bin/bash
USE_NINJA=
if [[ "$*" == *"--ninja"* ]]
then
if [[ -z "$(command -v ninja)" ]]; then
echo "Attempted to build using Ninja, but Ninja was not found on the system. Falling back to GNU Make."
else
echo "Compiling using Ninja"
USE_NINJA="-G Ninja"
fi
fi
OUTPUT=$(plasmashell --version)
IFS=' ' read -a array <<< "$OUTPUT"
VERSION="${array[1]}"
URL="https://invent.kde.org/plasma/libplasma/-/archive/v${VERSION}/libplasma-v${VERSION}.tar.gz"
ARCHIVE="libplasma-v${VERSION}.tar.gz"
SRCDIR="libplasma-v${VERSION}"
INSTALLDST="/usr/lib/x86_64-linux-gnu/qt6/qml/org/kde/plasma/core/libcorebindingsplugin.so"
LIBDIR="/usr/lib/x86_64-linux-gnu/"
if [ ! -d ${LIBDIR} ]; then
LIBDIR="/usr/lib64/"
fi
if [ ! -f ${INSTALLDST} ]; then
INSTALLDST="/usr/lib64/qt6/qml/org/kde/plasma/core/libcorebindingsplugin.so"
fi
if [ ! -d ./build/${SRCDIR} ]; then
rm -rf build
mkdir -p build
echo "Downloading $ARCHIVE"
curl $URL -o ./build/$ARCHIVE
tar -xvf ./build/$ARCHIVE -C ./build/
echo "Extracted $ARCHIVE"
fi
PWDDIR=$(pwd)
cp -r src ./build/$SRCDIR/
cd ./build/$SRCDIR/
mkdir -p build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr .. $USE_NINJA
cmake --build . --target corebindingsplugin
TMPDIR="/opt/aerothemeplasma/tmp"
sudo mkdir -p $TMPDIR
sudo cp ./bin/org/kde/plasma/core/libcorebindingsplugin.so $TMPDIR
for filename in "$PWD/bin/libPlasma"*; do
echo "Copying $filename to $TMPDIR"
sudo cp "$filename" "$TMPDIR"
done
cd $PWDDIR
sudo cp apply $TMPDIR
sudo chmod +x "$TMPDIR/apply"
sudo cp apply-libplasma-patches.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable apply-libplasma-patches.service
echo "Libraries have been compiled and moved to $TMPDIR. Restart your computer to apply the changes."
echo "In case Plasma crashes and/or fails to load after installing these patches, simply reinstall the libplasma package from your respective distro."