Skip to content

Commit d53fed8

Browse files
committed
cleanup, better dependency check, store system patched state
1 parent 1c53af9 commit d53fed8

File tree

2 files changed

+50
-43
lines changed

2 files changed

+50
-43
lines changed

patcher-cachy.fish

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
#!/bin/fish
2-
# vars
3-
SUCCESS="Success! Reboot to apply."
4-
APPLIED="Patch already present in '$DEST_FILE'. Nothing to do."
52

63
# runtime
74
GPU=$(lspci | grep -i '.* vga .* nvidia .*')
85
shopt -s nocasematch
96
if command -v fish &>/dev/null; then
107
if [[ $GPU == *' nvidia '* ]]; then
118
set -x --universal __GL_SHADER_DISK_CACHE_SIZE '12000000000'
12-
echo "$SUCCESS"
13-
sleep 5
149
exit 0
1510
else
1611
set -x --universal AMD_VULKAN_ICD 'RADV'
1712
set -x --universal MESA_SHADER_CACHE_MAX_SIZE '12G'
18-
echo "$SUCCESS"
19-
sleep 5
2013
exit 0
2114
fi
2215
else

patcher.sh

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,76 @@
11
#!/bin/bash
2-
32
# functions
43

4+
# dependency checker
5+
depcheck () {
6+
7+
local dependencies=(wget whiptail)
8+
for dep in "${dependencies[@]}"; do
9+
if dpkg -s "$dep" 2>/dev/null 1>&2; then
10+
continue
11+
else
12+
sudo apt install -y "$dep"
13+
fi
14+
done
15+
16+
}
17+
18+
# patch for Nvidia GPUs
519
patch_nv () {
620

21+
cd $HOME
22+
wget -O patch-nvidia https://raw.githubusercontent.com/psygreg/shader-booster/refs/heads/main/patch-nvidia;
723
cat "${HOME}/patch-nvidia" >> "${DEST_FILE}"
824
whiptail --title "Shader Booster" --msgbox "Success! Reboot to apply." 8 78
25+
cat "1" > "${HOME}/.booster"
926
rm ${HOME}/patch-nvidia
1027
exit 0
1128

1229
}
30+
31+
# patch for Mesa-driven GPUs
1332
patch_mesa () {
1433

34+
cd $HOME
35+
wget -O patch-mesa https://raw.githubusercontent.com/psygreg/shader-booster/refs/heads/main/patch-mesa;
1536
cat "${HOME}/patch-mesa" >> "${DEST_FILE}"
1637
whiptail --title "Shader Booster" --msgbox "Success! Reboot to apply." 8 78
38+
cat "1" > "${HOME}/.booster"
1739
rm ${HOME}/patch-mesa
1840
exit 0
1941

2042
}
2143

2244
# runtime
23-
24-
sudo apt install wget whiptail
45+
depcheck
2546
GPU=$(lspci | grep -i '.* vga .* nvidia .*')
26-
if [[ -f "${HOME}/.bash_profile" ]]; then
27-
DEST_FILE="${HOME}/.bash_profile"
28-
if [[ $GPU == *' nvidia '* ]]; then
29-
cd $HOME
30-
wget -O patch-nvidia https://raw.githubusercontent.com/psygreg/shader-booster/refs/heads/main/patch-nvidia;
31-
patch_nv
32-
else
33-
cd $HOME
34-
wget -O patch-mesa https://raw.githubusercontent.com/psygreg/shader-booster/refs/heads/main/patch-mesa;
35-
patch_mesa
36-
fi
37-
elif [[ -f "$HOME/.profile" ]]; then
38-
DEST_FILE="${HOME}/.profile"
39-
if [[ $GPU == *' nvidia '* ]]; then
40-
cd $HOME
41-
wget -O patch-nvidia https://raw.githubusercontent.com/psygreg/shader-booster/refs/heads/main/patch-nvidia;
42-
patch_nv
47+
if [ ! -f ${HOME}/.booster ]; then
48+
if [[ -f "${HOME}/.bash_profile" ]]; then
49+
DEST_FILE="${HOME}/.bash_profile"
50+
if [[ $GPU == *' nvidia '* ]]; then
51+
patch_nv
52+
else
53+
patch_mesa
54+
fi
55+
elif [[ -f "$HOME/.profile" ]]; then
56+
DEST_FILE="${HOME}/.profile"
57+
if [[ $GPU == *' nvidia '* ]]; then
58+
patch_nv
59+
else
60+
patch_mesa
61+
fi
62+
elif [[ -f "$HOME/.zshrc" ]]; then
63+
DEST_FILE="${HOME}/.zshrc"
64+
if [[ $GPU == *' nvidia '* ]]; then
65+
patch_nv
66+
else
67+
patch_mesa
68+
fi
4369
else
44-
cd $HOME
45-
wget -O patch-mesa https://raw.githubusercontent.com/psygreg/shader-booster/refs/heads/main/patch-mesa;
46-
patch_mesa
47-
fi
48-
elif [[ -f "$HOME/.zshrc" ]]; then
49-
DEST_FILE="${HOME}/.zshrc"
50-
if [[ $GPU == *' nvidia '* ]]; then
51-
cd $HOME
52-
wget -O patch-nvidia https://raw.githubusercontent.com/psygreg/shader-booster/refs/heads/main/patch-nvidia;
53-
patch_nv
54-
else
55-
cd $HOME
56-
wget -O patch-mesa https://raw.githubusercontent.com/psygreg/shader-booster/refs/heads/main/patch-mesa;
57-
patch_mesa
70+
whiptail --title "Shader Booster" --msgbox "No valid shell found." 8 78
71+
exit 1
5872
fi
5973
else
60-
whiptail --title "Shader Booster" --msgbox "No valid shell found." 8 78
61-
exit 1
74+
whiptail --title "Shader Booster" --msgbox "System already patched." 8 78
75+
exit 0
6276
fi

0 commit comments

Comments
 (0)