-
Notifications
You must be signed in to change notification settings - Fork 1
/
patch-rpi-imager
executable file
·94 lines (82 loc) · 3.42 KB
/
patch-rpi-imager
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
#!/bin/bash
# Define usage function
usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -n, --name NAME Specify custom name to replace Raspberry Pi with (default: Custom)"
echo " -c, --color COLOR Specify custom theme color (default: #000)"
echo " --logo LOGO_PATH Specify path to custom banner logo image (default: logo.png)"
echo " --app-icon ICON_PATH Specify path to custom application icon image (default: app-icon.png)"
echo " --logo-stacked LOGO_STACKED_PATH Specify path to custom stacked logo image (default: logo-stacked_imager.png)"
echo " --app-icon-ico APP_ICON_ICO_PATH Specify path to custom .ico application icon image (default: app-icon.ico)"
echo " --app-icon-icns APP_ICON_ICNS_PATH Specify path to custom .icns application icon image (default: app-icon.icns)"
echo " --source SOURCE_PATH Specify path to source folder (default: rpi-imager)"
echo " --repo REPO_URL Specify the new repository URL"
exit 1
}
# Default values
name="Custom"
color="#000"
logo="../logo.png"
app_icon="../app-icon.png"
logo_stacked="../logo-stacked_imager.png"
app_icon_ico="../app-icon.ico"
app_icon_icns="../app-icon.icns"
source_folder="rpi-imager"
# Parse command-line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
-n|--name) name="$2"; shift ;;
-c|--color) color="$2"; shift ;;
--logo) logo="$2"; shift ;;
--app-icon) app_icon="$2"; shift ;;
--logo-stacked) logo_stacked="$2"; shift ;;
--app-icon-ico) app_icon_ico="$2"; shift ;;
--app-icon-icns) app_icon_icns="$2"; shift ;;
--source) source_folder="$2"; shift ;;
--repo) repo_url="$2"; shift ;;
--help) usage ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
# Perform text replacement in main.qml with custom name
sed -i "s/Raspberry Pi/$name/g" "$source_folder/src/main.qml"
# Perform color replacement
sed -i "s/#cd2355/$color/g" "$source_folder/src/main.qml"
# Perform logo replacement if the file exists
if [[ -f "$logo" ]]; then
cp "$logo" "$source_folder/src/icons/logo_sxs_imager.png"
else
echo "Custom logo image not found. Using default logo."
fi
# Perform stacked logo replacement if the file exists
if [[ -f "$logo_stacked" ]]; then
cp "$logo_stacked" "$source_folder/src/icons/logo_stacked_imager.png"
else
echo "Custom stacked logo image not found. Using default stacked logo."
fi
# Perform app icon replacement if the file exists
if [[ -f "$app_icon" ]]; then
cp "$app_icon" "$source_folder/src/icons/rpi-imager.png"
else
echo "Custom app icon image not found. Using default app icon."
fi
# Perform app icon .ico replacement if the file exists
if [[ -f "$app_icon_ico" ]]; then
cp "$app_icon_ico" "$source_folder/src/icons/rpi-imager.ico"
else
echo "Custom .ico app icon image not found. Using default .ico app icon."
fi
# Perform app icon .icns replacement if the file exists
if [[ -f "$app_icon_icns" ]]; then
cp "$app_icon_icns" "$source_folder/src/icons/rpi-imager.icns"
else
echo "Custom .icns app icon image not found. Using default .icns app icon."
fi
# Perform OSLIST_URL replacement only if --repo option is provided
if [[ -n "$repo_url" ]]; then
sed -i "s|^\(#define OSLIST_URL\s*\).*|\1\"$repo_url\"|g" "$source_folder/src/config.h"
echo "OSLIST_URL patched successfully."
fi
echo "Modifications applied successfully."