forked from kmyi/refind-theme-regular
-
Notifications
You must be signed in to change notification settings - Fork 78
/
install.sh
executable file
·182 lines (168 loc) · 5.78 KB
/
install.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/env bash
set -euo pipefail
# An installer for refind-theme-regular by Munlik
#Check if root
[[ $EUID -ne 0 ]] && echo "This script must be run as root." && exit 1
clear
#Check if git is installed
if ! command -v git &> /dev/null
then
echo "git not found, please install it."
echo "On ubuntu it can be done with 'sudo apt install git'"
exit 1
fi
#Clone the theme
theme_source_directory=$(mktemp -d -t refind-theme-regular-XXXXXX)
cd "${theme_source_directory}"
echo -n "Downloading rEFInd theme Regular to ${theme_source_directory}"
git clone https://github.com/bobafetthotmail/refind-theme-regular.git &> /dev/null
echo " - [DONE]"
#Useful formatting tags
bold=$(tput bold)
normal=$(tput sgr0)
refind_dir_default="/boot/efi/EFI/refind"
#Set install path
echo "Enter rEFInd install location"
read -e -p "Default - ${bold}${refind_dir_default}${normal}: " refind_dir
if test -z "$refind_dir"; then
refind_dir="${refind_dir_default}" # If empty string passed above, set to default
fi
if [[ ! -d "${refind_dir}" ]]; then
echo "Specified rEFInd install location does not exist. Aborting install."
exit 1
fi
# remove trailing slash
refind_dir=$(realpath -s "$refind_dir")
#Set icon size
echo "Pick an icon size: (larger icons look better on bigger and denser displays)"
read -p "${bold}1: small (128px-48px)${normal}, 2: medium (256px-96px), 3: large (384px-144px), 4: extra-large (512px-192px): " size_select
if test -z "$size_select";
then
size_select=1
fi
case "$size_select" in
1)
size_big="128"
size_small="48"
;;
2)
size_big="256"
size_small="96"
;;
3)
size_big="384"
size_small="144"
;;
4)
size_big="512"
size_small="192"
;;
*)
echo "Incorrect choice. Exiting."
exit 1
;;
esac
echo
echo "Selected size - ${bold}big icons: $size_big px, small icons: $size_small px${normal}"
echo
#Set theme color
echo "Select a theme color"
read -p "${bold}1: light${normal}, 2: dark: " theme_select
if test -z "$theme_select";
then
theme_select=1
fi
case "$theme_select" in
1)
theme_name="light"
theme_path=""
;;
2)
theme_name="dark"
theme_path="_dark"
;;
*)
echo "Incorrect choice. Exiting."
exit 1
;;
esac
echo
echo "Selected theme - ${bold}$theme_name${normal}"
echo
#Uncomment relevant lines from src/theme.conf
echo -n "Generating theme file theme.conf"
cd refind-theme-regular
cp src/theme.conf theme.conf
sed -i "s/#icons_dir themes\/refind-theme-regular\/icons\/$size_big-$size_small/icons_dir themes\/refind-theme-regular\/icons\/$size_big-$size_small/" theme.conf
sed -i "s/#big_icon_size $size_big/big_icon_size $size_big/" theme.conf
sed -i "s/#small_icon_size $size_small/small_icon_size $size_small/" theme.conf
sed -i "s/#banner themes\/refind-theme-regular\/icons\/$size_big-$size_small\/bg$theme_path.png/banner themes\/refind-theme-regular\/icons\/$size_big-$size_small\/bg$theme_path.png/" theme.conf
sed -i "s/#selection_big themes\/refind-theme-regular\/icons\/$size_big-$size_small\/selection$theme_path-big.png/selection_big themes\/refind-theme-regular\/icons\/$size_big-$size_small\/selection$theme_path-big.png/" theme.conf
sed -i "s/#selection_small themes\/refind-theme-regular\/icons\/$size_big-$size_small\/selection$theme_path-small.png/selection_small themes\/refind-theme-regular\/icons\/$size_big-$size_small\/selection$theme_path-small.png/" theme.conf
cd ..
echo " - [DONE]"
#Clean up
echo -n "Removing unused directories"
rm -rf refind-theme-regular/{src,.git}
rm -rf refind-theme-regular/install.sh
echo " - [DONE]"
#Remove previous installs
echo -n "Deleting older installed versions (if any)"
rm -rf "${refind_dir}"/{regular-theme,refind-theme-regular}
rm -rf "${refind_dir}"/themes/{regular-theme,refind-theme-regular}
echo " - [DONE]"
#Copy theme setup folders
echo -n "Copying theme to ${refind_dir}/themes"
mkdir -p "${refind_dir}/themes"
cp -r refind-theme-regular "${refind_dir}/themes"
echo " - [DONE]"
#Edit refind.conf - remove older themes
echo -n "Removing old themes from refind.conf"
echo
echo
read -p "Do you have a secondary config file to preserve? Default: N (y/${bold}N${normal}): " config_confirm
if test -z "$config_confirm";
then
config_confirm="n"
fi
case "$config_confirm" in
y|Y)
read -p "Enter the name of the config file to be preserved in full eg: manual.conf: " configname
# Checking for enter key. If so it has the same effect having no files to preserve.
if [[ $configname == "" ]]; then
configname='^#'
fi
#Excludes line with entered config file then ^\s*include matches lines starting with any nuber of spaces and then include.
sed --in-place=".bak" "/$configname/! s/^\s*include/# (disabled) include/" "${refind_dir}"/refind.conf
;;
n|N)
# ^\s*include matches lines starting with any nuber of spaces and then include.
sed --in-place=".bak" 's/^\s*include/# (disabled) include/' "${refind_dir}"/refind.conf
;;
*)
;;
esac
echo " - [DONE]"
#Edit refind.conf - add new theme
echo -n "Updating refind.conf"
echo "
# Load rEFInd theme Regular
include themes/refind-theme-regular/theme.conf" | tee -a "${refind_dir}"/refind.conf &> /dev/null
echo " - [DONE]"
#Clean up - remove download
read -p "Delete download? (${bold}Y${normal}/n): " del_confirm
if test -z "$del_confirm";
then
del_confirm="y"
fi
case "$del_confirm" in
y|Y)
echo -n "Deleting download folder ${theme_source_directory}"
rm -r "${theme_source_directory}"
echo " - [DONE]"
;;
*)
;;
esac
echo "Thank you for installing rEFInd theme Regular."
echo "NOTE: If you're not getting your full resolution or have color issues then try disabling the CSM in your UEFI settings."