|
1 | 1 | #!/bin/bash |
2 | | - |
3 | 2 | # functions |
4 | 3 |
|
| 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 |
5 | 19 | patch_nv () { |
6 | 20 |
|
| 21 | + cd $HOME |
| 22 | + wget -O patch-nvidia https://raw.githubusercontent.com/psygreg/shader-booster/refs/heads/main/patch-nvidia; |
7 | 23 | cat "${HOME}/patch-nvidia" >> "${DEST_FILE}" |
8 | 24 | whiptail --title "Shader Booster" --msgbox "Success! Reboot to apply." 8 78 |
| 25 | + cat "1" > "${HOME}/.booster" |
9 | 26 | rm ${HOME}/patch-nvidia |
10 | 27 | exit 0 |
11 | 28 |
|
12 | 29 | } |
| 30 | + |
| 31 | +# patch for Mesa-driven GPUs |
13 | 32 | patch_mesa () { |
14 | 33 |
|
| 34 | + cd $HOME |
| 35 | + wget -O patch-mesa https://raw.githubusercontent.com/psygreg/shader-booster/refs/heads/main/patch-mesa; |
15 | 36 | cat "${HOME}/patch-mesa" >> "${DEST_FILE}" |
16 | 37 | whiptail --title "Shader Booster" --msgbox "Success! Reboot to apply." 8 78 |
| 38 | + cat "1" > "${HOME}/.booster" |
17 | 39 | rm ${HOME}/patch-mesa |
18 | 40 | exit 0 |
19 | 41 |
|
20 | 42 | } |
21 | 43 |
|
22 | 44 | # runtime |
23 | | - |
24 | | -sudo apt install wget whiptail |
| 45 | +depcheck |
25 | 46 | 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 |
43 | 69 | 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 |
58 | 72 | fi |
59 | 73 | 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 |
62 | 76 | fi |
0 commit comments