#!/bin/sh

if [ -z "$HOME" ]; then
    exit 0
fi

status_file="$HOME/.local/share/deepin-keyrings-wb/status"
if [ ! -r "$status_file" ]; then
    exit 0
fi

status=$(LC_ALL=C head -c 2 "$status_file" 2>/dev/null)
if [ "${#status}" -ne 2 ]; then
    exit 0
fi

enable=${status%${status#?}}
is_wb=${status#?}

case "$enable" in
    0|1) ;;
    *) exit 0 ;;
esac

case "$is_wb" in
    0|1) ;;
    *) exit 0 ;;
esac

if [ "$enable" = "1" ] || [ "$is_wb" = "1" ]; then
    printf 'GNOME_KEYRING_CUSTOM_LOCAL_PATH=%s/.local/share/deepin-keyrings-wb\n' "$HOME"
fi
