forked from SanderKlootwijk/vollanotchfix
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathapply-notch-hax.sh
executable file
·91 lines (76 loc) · 2.64 KB
/
apply-notch-hax.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
set -e
if [ $UID -eq 0 ]; then
echo ">> ERROR: Please run this script as the regular user 'phablet'!"
exit 1
fi
WORK="$HOME/.cache/lomiri-notch-hax"
DEVICE="$1"
if [ -z "$DEVICE" ]; then
echo ">> No device specified, detecting device name..."
DEVICE="$(getprop ro.product.device)" # e.g. 'yggdrasil'
fi
if [ "$DEVICE" = "halium_arm64" ]; then
echo ">> Detected halium_arm64 systemimage; trying alternative getprop..."
DEVICE="$(getprop ro.product.vendor.device)" # e.g. 'OnePlus6'
fi
echo ">> Device is '$DEVICE'"
DIFF="$WORK/$DEVICE.diff"
echo ">> Using diff '$DIFF'"
if [ ! -e $DIFF ]; then
mkdir -p $WORK
echo ">> Fetching patches for $DEVICE..."
if ! wget -O $DIFF https://raw.githubusercontent.com/JamiKettunen/lomiri-notch-hax/main/patches/$DEVICE.diff; then
rm $DIFF
echo "ERROR: It seems your device isn't supported by this project;
please tune the files on your device manually first,
then fork the repo, create a patches/$DEVICE.diff
and modify this script to fetch the patches from your
fork for testing!
Alternatively, specify a device template to use with
'$0 <device>'"
exit 1
fi
fi
if ! hash patch 2>/dev/null; then
echo ">> System utility 'patch' not found, starting installation..."
mount | grep -q ' / .*ro' && sudo mount -o remount,rw /
sudo mkdir -p /var/cache/apt/archives /var/lib/apt/lists
sudo mount -t tmpfs tmpfs /var/cache/apt/archives
sudo mount -t tmpfs tmpfs /var/lib/apt/lists
sudo apt update
sudo apt install -y patch
sudo umount /var/cache/apt/archives /var/lib/apt/lists
fi
if [ -d /usr/share/lomiri ]; then
echo ">> Adjusting patches locally for Lomiri shell path rename (UT 20.04+)..."
sed 's:/usr/share/unity8:/usr/share/lomiri:g' -i $DIFF
fi
echo ">> Copying system files to patch & checking compatability..."
cd $WORK
for file in $(grep '^diff' $DIFF | grep -Eo '\ b/.*' | cut -c 4-); do
mkdir -p $(dirname $WORK/root/$file)
cp /$file $WORK/root/$file
done
cd root/
if ! patch -p1 < $DIFF; then
echo ">> ERROR: Some system files are incompatible with the patches;
Please adjust '$DEVICE.diff' and try again!"
exit 1
fi
cd ../
echo ">> Patches applied successfully! Proceeding to replacing system files..."
mount | grep -q ' / .*ro' && sudo mount -o remount,rw /
sudo cp -r root/* /
sudo mount -o remount,ro /
read -p ">> All done, would you like to restart the Lomiri shell right now (Y/n)? " ans
if [[ -z "$ans" || "${ans^^}" = "Y"* ]]; then
if [ -x "$(command -v initctl)" ]; then
initctl restart unity8
else
systemctl --user restart lomiri-full-greeter
fi
else
echo ">> Please reboot later for the changes to take effect!"
fi
rm -r $WORK/root/