diff --git a/rimerc.sh b/rimerc.sh index dd011f6..4e052eb 100755 --- a/rimerc.sh +++ b/rimerc.sh @@ -1,12 +1,14 @@ #!/usr/bin/env bash +RELEASE_PATH=release + if [ -z $1 ]; then echo "Provide at least one input method!" echo "Such as: $0 fcitx5" exit fi -VALID_RIME="fcitx, fcitx5, ibus or squirrel" +VALID_RIME="fcitx, fcitx5, ibus, squirrel, trime or weasel" case $1 in fcitx) RIME_CONFIG_PATH=~/.config/fcitx/rime @@ -23,6 +25,25 @@ ibus) squirrel) RIME_CONFIG_PATH=~/Library/Rime ;; + +trime | weasel) + case $1 in + weasel) + RIME_CONFIG_PATH=%AppData%\Rime + ;; + + trime) + RIME_CONFIG_PATH=/sdcard/rime + ;; + esac + + # package flavor + ./script/package.sh $1 + echo "Please install $1 manually" + echo "Copy ${RELEASE_PATH}/$1 to your rime $1 ${RIME_CONFIG_PATH} and deploy" + exit + ;; + *) echo "Invalid $1 input method" echo "Valid input method is ${VALID_RIME}" @@ -32,10 +53,12 @@ esac echo -e "Starting setup $1...\n" -EXTRACT=7z INPUT_METHOD=$1 RIMERC=rimerc +# package flavor +./script/package.sh $1 + # check if input method installed if [ $1 == squirrel ]; then if [ ! -d '/Library/Input Methods/Squirrel.app' ]; then @@ -50,18 +73,6 @@ else fi fi -# check if 7z installed -if ! command -v ${EXTRACT} &>/dev/null; then - echo "${EXTRACT} could not be found" - echo "Please install ${EXTRACT} in your distro and try again!" - exit -fi - -# extract -TMP_DIR=$(mktemp -d -t ${RIMERC}-XXXX) -echo -e "Extracting archive ${INPUT_METHOD}.7z to ${TMP_DIR} ..." -7z e ${INPUT_METHOD}.7z -o${TMP_DIR} -primerc >/dev/null 2>&1 - # backup rime config if [ -d ${RIME_CONFIG_PATH} ]; then BACKUP_PATH=$(mktemp -p $(dirname ${RIME_CONFIG_PATH}) -d \ @@ -70,12 +81,12 @@ if [ -d ${RIME_CONFIG_PATH} ]; then echo -e "\nBackup your rime config to ${BACKUP_PATH}" fi -# copy yaml to config path +# copy config to config path mkdir -p ${RIME_CONFIG_PATH} -cp ${TMP_DIR}/*.yaml ${RIME_CONFIG_PATH} +cp -ra ${RELEASE_PATH}/${INPUT_METHOD}/* ${RIME_CONFIG_PATH} -# remove tmp dir -rm -rf ${TMP_DIR} +# copy userdb to config path +cp -ra ${BACKUP_PATH}/*.userdb ${RIME_CONFIG_PATH} # restart input method echo -e "\nWaiting for ${INPUT_METHOD} restart and deploying..." diff --git a/script/package.sh b/script/package.sh index 886203a..3dd6cf5 100755 --- a/script/package.sh +++ b/script/package.sh @@ -2,7 +2,12 @@ releasePath=release -flavors=(fcitx fcitx5 ibus squirrel trime weasel) +if [ -z $1 ]; then + flavors=(fcitx fcitx5 ibus squirrel trime weasel) +else + flavors=($1) +fi + schemas=(common easy_en luna_pinyin) mkdir -p ${releasePath}