-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
executable file
·92 lines (75 loc) · 3.14 KB
/
Makefile
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
# Build variables.
BUILD_DIR := build
THEME_DIR := grub-fallout-terminal-theme
INSTALL_DIR := /boot/grub/themes
GRUB_CONFIG := /etc/default/grub
GRUB_CFG := /boot/grub/grub.cfg
# Customizable properties.
BACKGROUND_SIZE := 1920x1080
FONT_SIZE := 20
ICON_SIZE := 24
THEME_COLOR := 25d46c
BACKGROUND_COLOR := black
SELECTED_FG_COLOR := white
SELECTED_BG_COLOR := $(THEME_COLOR)40
# Helper vars.
bg_w := $(firstword $(subst x, ,$(BACKGROUND_SIZE)))
bg_w := $(firstword $(subst X, ,$(bg_w)))
# Target vars.
bg := $(BUILD_DIR)/background.png
sel := $(BUILD_DIR)/selected_c.png
font := $(BUILD_DIR)/fixedsys$(FONT_SIZE).pf2
icons := $(patsubst icons/%.xcf, $(BUILD_DIR)/icons/%.png, $(wildcard icons/*.xcf))
theme := $(BUILD_DIR)/theme
.PHONY: all clean check install uninstall preview
all: $(bg) $(sel) $(font) $(icons) $(theme)
$(BUILD_DIR):
mkdir -p $@
$(BUILD_DIR)/icons: | $(BUILD_DIR)
mkdir -p $@
$(bg): scanline.xcf vaultboy.xcf | $(BUILD_DIR)
xcf2png scanline.xcf |\
convert - -fuzz 100% -fill '#$(THEME_COLOR)' -opaque white \
-background '$(BACKGROUND_COLOR)' -alpha remove - |\
convert -size '$(BACKGROUND_SIZE)' tile:- -strip $@
xcf2png vaultboy.xcf |\
convert - -resize $(bg_w) -scale 25% -fuzz 100% -fill '#$(THEME_COLOR)' -opaque white - |\
convert $@ - -gravity SouthEast -geometry +40+40 -composite -strip png32:$@
$(sel): | $(BUILD_DIR)
convert 'xc:#$(SELECTED_BG_COLOR)' -strip png32:$@
$(font): fixedsys.ttf | $(BUILD_DIR)
rm -rf $(BUILD_DIR)/*.pf2
grub-mkfont -s $(FONT_SIZE) -o $@ $<
$(BUILD_DIR)/icons/%.png: icons/%.xcf | $(BUILD_DIR)/icons
xcf2png $< | convert - -fuzz 100% -fill '#$(THEME_COLOR)' -opaque white -resize '$(ICON_SIZE)x$(ICON_SIZE)' -strip png32:$@
$(theme): theme | $(BUILD_DIR)
cp $< $@
sed -i 's/@font@/fixedsys$(FONT_SIZE).pf2/' $@
sed -i 's/@iconsize@/$(ICON_SIZE)/' $@
sed -i 's/@themecolor@/#$(THEME_COLOR)/' $@
sed -i 's/@selectedfgcolor@/$(SELECTED_FG_COLOR)/' $@
clean:
rm -rf $(BUILD_DIR)
check:
@[ $$(id -u) -eq 0 ] || echo 'ERROR: This action requires root privileges.'
[ $$(id -u) -eq 0 ]
@[ -f $(GRUB_CONFIG) ] || echo 'ERROR: Unable to locate grub user configuration! Edit GRUB_CONFIG at the top of this Makefile.' >&2
@[ -f $(GRUB_CFG) ] || echo 'ERROR: Unable to locate grub.cfg! Edit GRUB_CFG at the top of this Makefile.' >&2
[ -f $(GRUB_CONFIG) ] && [ -f $(GRUB_CFG) ]
install: check all
[ -d $(INSTALL_DIR)/$(THEME_DIR) ] && rm -rf $(INSTALL_DIR)/$(THEME_DIR) || true
mkdir -p $(INSTALL_DIR)
cp -r $(BUILD_DIR) $(INSTALL_DIR)/$(THEME_DIR)
sed -i '/GRUB_TERMINAL\s*=/ s/^#*/#/' $(GRUB_CONFIG)
sed -i '\|GRUB_THEME=$(INSTALL_DIR)/$(THEME_DIR)/theme|d' $(GRUB_CONFIG)
echo 'GRUB_THEME=$(INSTALL_DIR)/$(THEME_DIR)/theme' >> $(GRUB_CONFIG)
grub-mkconfig -o $(GRUB_CFG)
uninstall: check
rm -rf $(INSTALL_DIR)/$(THEME_DIR)
sed -i '\|GRUB_THEME=$(INSTALL_DIR)/$(THEME_DIR)/theme|d' $(GRUB_CONFIG)
grub-mkconfig -o $(GRUB_CFG)
@grep -q 'GRUB_TERMINAL' $(GRUB_CONFIG) && echo 'NOTE: Uncomment GRUB_TERMINAL=... in $(GRUB_CONFIG) and re-run this if you wish to disable the graphical terminal.' >&2 || true
preview:
sleep 5 && kill -9 `pidof grub-emu` &
grub-emu || true
reset