code: def create_default_options_getter():
      
      options = []
      try:
          ttyname = subprocess.check_output(args=['tty']).strip()
          options.append(b'ttyname=' + ttyname)
      except subprocess.CalledProcessError as e:
          log.warning('no TTY found: %s', e)
  
      display = os.environ.get('DISPLAY')
      if display is not None:
          options.append('display={}'.format(display).encode('ascii'))
      else:
          log.warning('DISPLAY not defined')
  
      log.info('using %s for pinentry options', options)
      return lambda: options
docs: Return current TTY and DISPLAY settings for GnuPG pinentry.