summaryrefslogtreecommitdiff
path: root/Ports
diff options
context:
space:
mode:
Diffstat (limited to 'Ports')
-rwxr-xr-xPorts/.port_include.sh32
-rw-r--r--Ports/README.md5
2 files changed, 37 insertions, 0 deletions
diff --git a/Ports/.port_include.sh b/Ports/.port_include.sh
index 16d9c78ae3..805a74379c 100755
--- a/Ports/.port_include.sh
+++ b/Ports/.port_include.sh
@@ -69,6 +69,7 @@ shift
: "${launcher_name:=}"
: "${launcher_category:=}"
: "${launcher_command:=}"
+: "${icon_file:=}"
run_nocd() {
echo "+ $@ (nocd)"
@@ -95,6 +96,36 @@ ensure_build() {
fi
}
+install_main_icon() {
+ if [ -n "$icon_file" ] && [ -n "$launcher_command" ]; then
+ install_icon "$icon_file" "$launcher_command"
+ fi
+}
+
+install_icon() {
+ if [ "$#" -lt 2 ]; then
+ echo "Syntax: install_icon <icon> <launcher>"
+ exit 1
+ fi
+ icon="$1"
+ launcher="$2"
+
+ command -v convert >/dev/null 2>&1
+ convert_exists=$?
+
+ command -v identify >/dev/null 2>&1
+ identify_exists=$?
+
+ if [ "$convert_exists" == "0" ] && [ "$identify_exists" == "0" ]; then
+ for icon_size in "16x16" "32x32"; do
+ index=$(run identify "$icon" | grep "$icon_size" | grep -oE "\[[0-9]+\]" | tr -d "[]" | head -n1)
+ run convert "${icon}[${index}]" "app-${icon_size}.png"
+ done
+ run objcopy --add-section serenity_icon_s="app-16x16.png" "${DESTDIR}${launcher}"
+ run objcopy --add-section serenity_icon_m="app-32x32.png" "${DESTDIR}${launcher}"
+ fi
+}
+
install_main_launcher() {
if [ -n "$launcher_name" ] && [ -n "$launcher_category" ] && [ -n "$launcher_command" ]; then
install_launcher "$launcher_name" "$launcher_category" "$launcher_command"
@@ -413,6 +444,7 @@ do_install() {
echo "Installing $port!"
install
install_main_launcher
+ install_main_icon
post_install
addtodb "${1:-}"
}
diff --git a/Ports/README.md b/Ports/README.md
index 1c8f44f85a..727fcdd47a 100644
--- a/Ports/README.md
+++ b/Ports/README.md
@@ -186,6 +186,11 @@ compressed file, it will be extracted.
If a file is an `.asc` file (PGP signature) it will be imported into `gpg`'s
keyring and can later be used for verification using [`auth_opts`](#auth_opts).
+#### `icon_file`
+
+The file to use for the port launcher icon. The icon file is assumed to have a
+16x16 as well as a 32x32 layer.
+
#### `installopts`
Options passed to `make install` in the default `install` function.