#!/bin/bash

set -e

mkdir -p /usr/lib/license/
_pkgname=wechat-universal

if tput setaf 0 &>/dev/null; then
    all_off="$(tput sgr0)"
    bold="${all_off}$(tput bold)"
    blue="${bold}$(tput setaf 4)"
    yellow="${bold}$(tput setaf 3)"
    eval "note() {
        printf '${blue}==>${yellow} NOTE:${bold} %s${all_off}\n' \"\$@\"
    }" # avoid run-time expanding
else
    note() {
        printf '==> NOTE: %s\n' "$@"
    }
fi

post_install() {
    if [[ "${LANG}" == zh_CN* ]]; then
        note "采用 bubblewrap 沙盒运行微信，对于家目录，默认只能对 '\$XDG_DOCUMENTS_DIR/WeChat_Data' 读写...
          如需增加更多的读写目录，请在 '~/.config/${_pkgname}/binds.list' 文件（如不存在请自行创建）中增加...
          一个路径一行，可以使用绝对路径，形如：/home/username/music
          也可以使用相对于运行用户家目录的相对路径，形如：pictures/screenshot
          请运行'wechat-universal --help'来查看可接受的命令行参数"
    else
        note "Run WeChat with the bubblewrap sandbox. For home directory, WeChat can only read and write '\$XDG_DOCUMENTS_DIR/WeChat_Data'...
          Custom binds could be declared in '~/.config/${_pkgname}/binds.list', each line a path, absolute or relative to your HOME...
          Run 'wechat-universal --help' to check for CLI help message"
    fi
}

post_install
