getAppBatteryLevel method

Future<int?> getAppBatteryLevel()

Implementation

Future<int?> getAppBatteryLevel() async {
  try {
    final result = await Process.run('cat', [
      '/sys/class/power_supply/BAT0/capacity',
    ]);
    final res = result.stdout.toString().trim();
    if (int.tryParse(res) != null) {
      return int.parse(res);
    }
  } catch (e) {
    ThanPkg.showDebugLog(e.toString(), tag: 'LinuxApp:getAppBatteryLevel');
  }
  return null;
}