code: def get_agent_sock_path(env=None, sp=subprocess):
      
      args = [util.which('gpgconf'), '--list-dirs']
      output = check_output(args=args, env=env, sp=sp)
      lines = output.strip().split(b'\n')
      dirs = dict(line.split(b':', 1) for line in lines)
      log.debug('%s: %s', args, dirs)
      return dirs[b'agent-socket']
docs: Parse gpgconf output to find out GPG agent UNIX socket path.