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)

1  
static S getBattery_code;
2  
sbool getBattery_debug;
3  
4  
static int getBattery() ctex {
5  
  if (getBattery_code == null)
6  
    getBattery_code = loadSnippet(isWindows() ? "#2000583" : "#1008531");
7  
  backtick_uninterruptable.set(true);
8  
  String s = backtick(getBattery_code);
9  
   backtick_uninterruptable.set(null);
10  
 if (getBattery_debug) print("getBattery >> " + quote(s));
11  
  String x = find(isWindows() ? "EstimatedChargeRemaining=(\\d+)" : "(\\d+)\\.?\\d*%", s);
12  
  if (getBattery_debug) print("getBattery >> " + x);
13  
  int l = x != null ? Integer.parseInt(x) : 0;
14  
  if (isLinux() && l == 0) l = 100;
15  
  ret l;
16  
}

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

Comments [hide]

ID Author/Program Comment Date
1172 stefan Doesn't work for Windows yet... process hangs (?) 2015-11-16 21:11:48

add comment

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: 974 / 1187
Version history: 3 change(s)
Referenced in: [show references]