#! /usr/bin/python

import sys, os, os.path
from subprocess import call

lang     = os.environ.get('LANG')
language = os.environ.get('LANGUAGE')
lc_all   = os.environ.get('LC_ALL')

preferred='en'
if language and language[0:2] != preferred:
    preferred=language[0:2]
elif lang and lang[0:2] != preferred:
    preferred=lang[0:2]
elif lc_all and lc_all[0:2] != preferred:
    preferred=lc_all[0:2]
if len(sys.argv)>1:
    preferred=sys.argv[1]

pdfTail='eyesj.pdf'
filename=os.path.join('/usr/share/expeyes/doc', preferred+'-'+pdfTail)
if not os.path.exists(filename):
    filename=os.path.join('/usr/share/expeyes/doc', 'en-'+pdfTail)
call('evince '+filename, shell=True)
