Uses 6315K of libraries. Click here for Pure Java version (4694L/22K).
1 | !7 |
2 | |
3 | cmodule BatteryTrayIcon > DynPrintLog { |
4 | transient S value; |
5 | transient JLabel lbl; |
6 | transient bool _startMinimized = true; |
7 | switchable double interval = 10.0; // restart to take effect |
8 | transient double level; |
9 | |
10 | start { |
11 | dm_addTrayIcon(onLeftClick(rThreadEnter dm_showModule, lbl = dm_fieldLabel_noAutoToolTip value())); |
12 | doEveryAndNow(interval, r actualUpdate); |
13 | dm_registerAs_direct batteryLevel(); |
14 | } |
15 | |
16 | void actualUpdate { |
17 | S value = "-"; |
18 | level = oshi_batteryLevel_withZeroPercentFix(); |
19 | if (!isNaN(level)) value = iround(level) + "%"; |
20 | if (set_trueIfChanged(this, +value)) |
21 | fireChangeWithoutPersisting(); |
22 | toolTip(lbl, "Battery level: " + value); |
23 | } |
24 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1026815 |
Snippet name: | Battery Tray Icon |
Eternal ID of this version: | #1026815/4 |
Text MD5: | bbf5e4a831027e7fe2cdebe979a2d68b |
Transpilation MD5: | c09941bfe3d72aa97e4118b2d5c1e74f |
Author: | stefan |
Category: | |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-25 01:10:50 |
Source code size: | 722 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 249 / 1751 |
Version history: | 3 change(s) |
Referenced in: | [show references] |