networkInfo top-level property

String get networkInfo

Implementation

String get networkInfo {
  final data = (Process.runSync(
    "lspci",
    [],
  )).stdout.toString();
  final List<String> networkRaws = data.split("\n");
  final List<String> networks = [];
  for (var i = 0; i < networkRaws.length; i++) {
    final String line = networkRaws[i];
    if (!line.contains(":")) continue;

    final first = line.split(" ")[1];
    if (first != "Network") {
      continue;
    }
    String network = line.split(": ")[1].replaceAll(RegExp("\\(rev .*\\)\$"), "").trim();

    networks.add(network.trim());
  }
  return networks.join("\n");
}