-
Notifications
You must be signed in to change notification settings - Fork 6
/
install.sh
executable file
·44 lines (36 loc) · 1.73 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
#!/bin/bash
# Configurables
GRUB_DIR=/boot/grub/themes
GRUB_THEME=grub-bgrt
FONTSIZE=24 # See README.md
# Sanity Checks
if [[ ! -r /sys/firmware/acpi/bgrt/image ]]; then
echo "Sorry, I can't read /sys/firmware/acpi/bgrt/image"
echo "Your system is not suitable for this theme"
exit 1
fi
command -v convert >/dev/null 2>&1 || { echo >&2 "I require convert (from imagemagick) but it's not installed. Aborting."; exit 1; }
command -v install >/dev/null 2>&1 || { echo >&2 "I require install (from coreutils) but it's not installed. Aborting."; exit 1; }
command -v awk >/dev/null 2>&1 || { echo >&2 "I require awk but it's not installed. Aborting."; exit 1; }
# OK. Convert the image to PNG (grub doesn't support BMPs)
convert /sys/firmware/acpi/bgrt/image PNG24:theme/bgrt.png
# Replace the placeholders with the image offsets
< theme/theme.txt.in awk \
-v BGRTLEFT=$(</sys/firmware/acpi/bgrt/xoffset) \
-v BGRTTOP=$(</sys/firmware/acpi/bgrt/yoffset) \
'{gsub (/\$BGRTLEFT\$/, BGRTLEFT);
gsub (/\$BGRTTOP\$/, BGRTTOP);
print}' > theme/theme.txt
# Finally, install the theme
install -d ${GRUB_DIR}/${GRUB_THEME}
install -m644 theme/dejavu-mono-12.pf2 ${GRUB_DIR}/${GRUB_THEME}/
install -m644 theme/lato-${FONTSIZE}.pf2 ${GRUB_DIR}/${GRUB_THEME}/
install -m644 theme/{bgrt,background}.png ${GRUB_DIR}/${GRUB_THEME}/
install -d ${GRUB_DIR}/${GRUB_THEME}/progress_bar/
install -m644 theme/progress_bar/progress_bar_{nw,n,ne,w,c,e,sw,s,se,hl_c}.png ${GRUB_DIR}/${GRUB_THEME}/progress_bar/
install -m644 theme/theme.txt ${GRUB_DIR}/${GRUB_THEME}/
echo "Install complete."
echo "To use this theme, add:"
echo " GRUB_THEME=${GRUB_DIR}/${GRUB_THEME}/theme.txt"
echo "to your grub config (e.g. /etc/default/grub),"
echo "then rebuild grub (e.g. update-grub)."