From 7a03c661d4b2638b47e3e4233b31df6fc47f54f7 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Fri, 4 Sep 2020 15:28:19 +0200 Subject: [PATCH] Add alternative_package.sh --- alternative_package.sh | 74 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 alternative_package.sh diff --git a/alternative_package.sh b/alternative_package.sh new file mode 100755 index 0000000..6678f31 --- /dev/null +++ b/alternative_package.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# Convert app to a different package with different icon and name, +# to allow multiple installations on the same device +# (different colors for different account :D). + +package_add="$1" +name_add="$2" +mydir="$(dirname "$(realpath "$0")")" + +if [ -z "$package_add" ] || [ -z "$name_add" ]; then + echo "Usage: $0 " + exit 1 +fi + +pushd "$mydir" > /dev/null + +web_dir="element-web" +desktop_dir="element-desktop" +package_file="$desktop_dir/package.json" + +if grep -q "schildichat-desktop-$package_add" "$package_file"; then + echo "Abort, $package_add already active" + exit 0 +fi + +# Analog to SchildiChat-Android's alternative_package.sh +logo_replace_color() { + local file="$1" + local color_shell="$2" + local color_shell_dark="$3" + local color_bg="$4" + # shell color + sed -i "s|#8BC34A|$color_shell|gi" "$file" + sed -i "s|#33691E|$color_shell_dark|gi" "$file" + # bg color + sed -i "s|#e2f0d2|$color_bg|gi" "$file" +} + +logo_alternative() { + for f in "$web_dir"/graphics/*.svg; do + logo_replace_color "$f" "$@" + done + for f in "$desktop_dir"/graphics/*.svg; do + logo_replace_color "$f" "$@" + done + "$web_dir/graphics/icon_gen.sh" + "$desktop_dir/graphics/icon_gen.sh" +} + +# Analog to SchildiChat-Android's alternative_package.sh +case "$package_add" in +"a") + # cyan + logo_alternative "#00ACC1" "#006064" "#B2EBF2" + ;; +"b") + # orange: 900 color recuded in value + logo_alternative "#FB8C00" "#7f2c00" "#FFE0B2" + ;; +"c") + # purple + logo_alternative "#5E35B1" "#311B92" "#D1C4E9" + ;; +"d") + # red: 900 color reduced in value + logo_alternative "#E53935" "#4c0b0b" "#FFCDD2" + ;; +"x") + logo_alternative "#ffffff" "#000000" "#eeeeee" + ;; +esac + +sed -i "s|SchildiChat|SchildiChat.$name_add|g" "$package_file" +sed -i "s|schildichat-desktop|schildichat-desktop-$package_add|g" "$package_file"