#!/bin/bash

# 脚本解释器 强制设置为 bash
#if [ "$BASH" != "/bin/bash" ] && [ "$BASH" != "/usr/bin/bash" ]; then
#    bash "$0" "$@"
#    exit $?
#fi

# sleep for a little while to avoid duplicate startup
function autostart()
{
    local LOCAL_DISPLAY=$DISPLAY
    if [ -n "$LOCAL_DISPLAY" ];then
        /usr/bin/fcitx -d
    else
        sleep 2
        autostart
    fi
}

autostart
sleep 2

# Test whether fcitx is running correctly with dbus...
fcitx-remote > /dev/null 2>&1

if [ $? = "1" ]; then
    echo "Fcitx seems is not running"
    /usr/bin/fcitx -d
else
    echo "Fcitx is running correctly."
fi
