Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

16
LINES

< > BotCompany Repo | #1000735 // getBattery (Linux working. Windows not yet)

JavaX fragment (include)

static S getBattery_code;
sbool getBattery_debug;

static int getBattery() ctex {
  if (getBattery_code == null)
    getBattery_code = loadSnippet(isWindows() ? "#2000583" : "#1008531");
  backtick_uninterruptable.set(true);
  String s = backtick(getBattery_code);
   backtick_uninterruptable.set(null);
 if (getBattery_debug) print("getBattery >> " + quote(s));
  String x = find(isWindows() ? "EstimatedChargeRemaining=(\\d+)" : "(\\d+)\\.?\\d*%", s);
  if (getBattery_debug) print("getBattery >> " + x);
  int l = x != null ? Integer.parseInt(x) : 0;
  if (isLinux() && l == 0) l = 100;
  ret l;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

1 comment(s) hidden. show

Snippet ID: #1000735
Snippet name: getBattery (Linux working. Windows not yet)
Eternal ID of this version: #1000735/4
Text MD5: c633fd7822d48a9d352ac0f50a724b4c
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-21 14:13:32
Source code size: 615 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 990 / 1203
Version history: 3 change(s)
Referenced in: [show references]