#!/bin/sh

LL="${LANG%%_*}"
LL="${LL%%.*}"
LL="${LL%%@*}"
CC="${LANG##*_}"
CC="${CC%%.*}"
CC="${CC%%@*}"

hide () {
  ORIG="/usr/share/applications/$1.desktop"
  FILE="$HOME/.local/share/applications/$1.desktop"
  if [ -e $FILE ]; then
    mkdir -p "$HOME/.local/share/applications"
    cp "$ORIG" "$FILE"
    echo "Hidden=true" >> $FILE
  fi
}

show () {
  FILE="$HOME/.local/share/applications/$1.desktop"
  rm -f "$FILE"
}

# Big table of possible specialized links:
case "$LL" in
  'cs|da|el|fi|he|hr|hu|ms|nl|no|pl|ru|sv|th|tr|vi')
    hide yahoo-maps
    ;;
  'en')
    case "$CC" in
      'GI|ID|MY|NZ|PH|SG|TH|VN|ZA')
        hide yahoo-maps
        ;;
      *)
        show yahoo-maps
        ;;
    esac
    ;;
  'zh')
    case "$CC" in
      'TW')
        show yahoo-maps
        ;;
      *)
        hide yahoo-maps
        ;;
    esac
    ;;
  'es')
    case "$CC" in
      'US')
        show yahoo-maps
        ;;
      *)
        hide yahoo-maps
        ;;
    esac
    ;;
  *)
    show yahoo-maps
    ;;
esac

exit 0
