Get battery level implementation
Some checks failed
Lint Test / build (20) (push) Has been cancelled
MacOS Build / build (20) (push) Has been cancelled
MacOS 12 - x64 DMG Build / build (20) (push) Has been cancelled
Ubuntu 22.04 - AppImage Build / build (20) (push) Has been cancelled
Ubuntu 22.04 - x64 DEB Build / build (20) (push) Has been cancelled
Ubuntu 24.04 - x64 DEB Build / build (20) (push) Has been cancelled
Windows Build / build (20) (push) Has been cancelled

This commit is contained in:
everoddandeven 2024-11-08 18:36:05 +01:00
parent 72e5dfd607
commit f2c67073a8
7 changed files with 395 additions and 0 deletions

View file

@ -11,6 +11,8 @@ import * as os from 'os';
import * as pidusage from 'pidusage';
import AutoLaunch from './auto-launch';
import * as AdmZip from 'adm-zip';
const batteryLevel = require('battery-level');
const network = require('network');
interface Stats {
@ -1000,6 +1002,15 @@ try {
});
});
ipcMain.handle('get-battery-level', (event: IpcMainInvokeEvent) => {
batteryLevel().then((level: number) => {
win?.webContents.send('on-get-battery-level', level);
}).catch((error: any) => {
console.error(error);
win?.webContents.send('on-get-battery-level', -1);
})
});
ipcMain.handle('disable-auto-launch', (event: IpcMainInvokeEvent) => {
autoLauncher.isEnabled().then((enabled: boolean) => {
if (!enabled) {

355
app/package-lock.json generated
View file

@ -10,6 +10,7 @@
"dependencies": {
"adm-zip": "^0.5.16",
"applescript": "^1.0.0",
"battery-level": "^3.0.0",
"network": "^0.7.0",
"os": "^0.1.2",
"pidusage": "^3.0.2",
@ -20,6 +21,7 @@
"devDependencies": {
"@types/adm-zip": "^0.5.5",
"@types/auto-launch": "^5.0.5",
"@types/battery-level": "^3.0.2",
"@types/pidusage": "^2.0.5",
"@types/winreg": "^1.2.36"
}
@ -75,6 +77,12 @@
"integrity": "sha512-/nGvQZSzM/pvCMCh4Gt2kIeiUmOP/cKGJbjlInI+A+5MoV/7XmT56DJ6EU8bqc3+ItxEe4UC2GVspmPzcCc8cg==",
"dev": true
},
"node_modules/@types/battery-level": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/@types/battery-level/-/battery-level-3.0.2.tgz",
"integrity": "sha512-e9EM6s+LekAEJrBnEf8ZTyooBwfDL2vE9Zs6H24fFERX+xXO7gWTIT1ZyQuCzoTsnG6Bz6W6sAQlY3j12hd0WQ==",
"dev": true
},
"node_modules/@types/node": {
"version": "22.8.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.0.tgz",
@ -160,6 +168,33 @@
}
]
},
"node_modules/battery-level": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/battery-level/-/battery-level-3.0.0.tgz",
"integrity": "sha512-kwxKiVwqWV1udqUfxdfUpsYWFY4jxqbYLzCL4CgjVTv8uJuRKWVblsF14CTICbUynEEgEOEWOrQQQUxOsBuBBQ==",
"dependencies": {
"execa": "^0.8.0",
"linux-battery": "^3.0.1",
"osx-battery": "^4.0.0",
"to-decimal": "^2.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/bplist-creator": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.0.4.tgz",
"integrity": "sha512-S6SjiqI9rOOcXGpinzdoW4gXri2IxiXdn3V5tfHTVWuGVxuU+SQK4Iwkjg7QzjRsT5on66oOVlgCDaqCYtZ11A==",
"dependencies": {
"stream-buffers": "~0.2.3"
}
},
"node_modules/bplist-parser": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.0.6.tgz",
"integrity": "sha512-fGeghPEH4Eytvf+Mi446aKcDqvkA/+eh6r7QGiZWMQG6TzqrnsToLP379XFfqRSZ41+676hhGIm++maNST1Apw=="
},
"node_modules/brace-expansion": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
@ -191,6 +226,26 @@
"ieee754": "^1.1.13"
}
},
"node_modules/camelcase": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
"integrity": "sha512-wzLkDa4K/mzI1OSITC+DUyjgIl/ETNHE9QvYgy6J6Jvqyyz4C0Xfd+lQhb19sX2jMpZV4IssUn0VDVmglV+s4g==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/camelcase-keys": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-1.0.0.tgz",
"integrity": "sha512-hwNYKTjJTlDabjJp2xn0h8bRmOpObvXVgYbQmR+Xob/EeBDtYea3xttjr5hqiWqLWtI3/6xO7x1ZAktQ9up+ag==",
"dependencies": {
"camelcase": "^1.0.1",
"map-obj": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/chownr": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
@ -249,6 +304,82 @@
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="
},
"node_modules/execa": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-0.8.0.tgz",
"integrity": "sha512-zDWS+Rb1E8BlqqhALSt9kUhss8Qq4nN3iof3gsOdyINksElaPyNBtKUMTR62qhvgVWR0CqCX7sdnKe4MnUbFEA==",
"dependencies": {
"cross-spawn": "^5.0.1",
"get-stream": "^3.0.0",
"is-stream": "^1.1.0",
"npm-run-path": "^2.0.0",
"p-finally": "^1.0.0",
"signal-exit": "^3.0.0",
"strip-eof": "^1.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/execa/node_modules/cross-spawn": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
"integrity": "sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==",
"dependencies": {
"lru-cache": "^4.0.1",
"shebang-command": "^1.2.0",
"which": "^1.2.9"
}
},
"node_modules/execa/node_modules/lru-cache": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz",
"integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==",
"dependencies": {
"pseudomap": "^1.0.2",
"yallist": "^2.1.2"
}
},
"node_modules/execa/node_modules/shebang-command": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz",
"integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==",
"dependencies": {
"shebang-regex": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/execa/node_modules/shebang-regex": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz",
"integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/execa/node_modules/signal-exit": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz",
"integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="
},
"node_modules/execa/node_modules/which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"which": "bin/which"
}
},
"node_modules/execa/node_modules/yallist": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
"integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A=="
},
"node_modules/foreground-child": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz",
@ -264,6 +395,14 @@
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/get-stream": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ==",
"engines": {
"node": ">=4"
}
},
"node_modules/glob": {
"version": "10.4.5",
"resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz",
@ -326,6 +465,14 @@
"node": ">=8"
}
},
"node_modules/is-stream": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
"integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@ -345,11 +492,59 @@
"@pkgjs/parseargs": "^0.11.0"
}
},
"node_modules/linux-batteries": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/linux-batteries/-/linux-batteries-2.0.0.tgz",
"integrity": "sha512-1OrNC3z3UWsffWssasly+DIh+AgSHy/f+x5ZHcFBXXlT5KswNSxry0SBKkg4oPVvOvIOWVGStZrh3bx7jRbCxw==",
"dependencies": {
"pify": "^2.2.0",
"pinkie-promise": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/linux-battery": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/linux-battery/-/linux-battery-3.0.1.tgz",
"integrity": "sha512-iU3K7TMzI0xSNq5ChErfmjsiUXtBtXyQOexoSahKFGqF1CjEwKt/ao0nj0wEAEx9yy4yopdeYHXaJvUF0MYFOA==",
"dependencies": {
"camelcase-keys": "^1.0.0",
"linux-batteries": "^2.0.0",
"pify": "^2.2.0",
"pinkie-promise": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/lodash-node": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/lodash-node/-/lodash-node-2.4.1.tgz",
"integrity": "sha512-egEt8eNQp2kZWRmngahiqMoDCDCENv3uM188S7Ed5t4k3v6RrLELXC+FqLNMUnhCo7gvQX3G1V8opK/Lcslahg==",
"deprecated": "This package is discontinued. Use lodash@^4.0.0."
},
"node_modules/lowercase-first-keys": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/lowercase-first-keys/-/lowercase-first-keys-1.0.1.tgz",
"integrity": "sha512-ad6HkGnEWENTmglzmZ34FUYZEHNyw1bYGKtDs/xAa7AXoVM4HShmBvA/gFJkboEwm003ezzzqmNWKxtltsaLww==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/lru-cache": {
"version": "10.4.3",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz",
"integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="
},
"node_modules/map-obj": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz",
"integrity": "sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/minimatch": {
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
@ -413,11 +608,61 @@
"network": "bin/network"
}
},
"node_modules/npm-run-path": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",
"integrity": "sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==",
"dependencies": {
"path-key": "^2.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/npm-run-path/node_modules/path-key": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz",
"integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==",
"engines": {
"node": ">=4"
}
},
"node_modules/obj-type": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/obj-type/-/obj-type-1.0.1.tgz",
"integrity": "sha512-Ek2el5XJyMSW8mOyXF/4Jm3dmSEbeas9y2x3yit7C+DX7G8epk8xly7nX2z3aaM26/+MziS+RegNlKgkjyGLTw==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/os": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/os/-/os-0.1.2.tgz",
"integrity": "sha512-ZoXJkvAnljwvc56MbvhtKVWmSkzV712k42Is2mA0+0KTSRakq5XXuXpjZjgAt9ctzl51ojhQWakQQpmOvXWfjQ=="
},
"node_modules/osx-battery": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/osx-battery/-/osx-battery-4.0.0.tgz",
"integrity": "sha512-B2LWF3ugcq2hgilug+RkB0hUGDbk8s78MzHDO6ff90bN2mBNuAYYNMXb4YkeSvECkz3MFaFnHpyYjKSlrZK7IQ==",
"dependencies": {
"lowercase-first-keys": "^1.0.0",
"obj-type": "^1.0.0",
"pify": "^2.2.0",
"pinkie-promise": "^1.0.0",
"simple-plist": "0.0.4"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/p-finally": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
"integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==",
"engines": {
"node": ">=4"
}
},
"node_modules/package-json-from-dist": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
@ -457,6 +702,57 @@
"node": ">=10"
}
},
"node_modules/pify": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/pinkie": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/pinkie/-/pinkie-1.0.0.tgz",
"integrity": "sha512-VFVaU1ysKakao68ktZm76PIdOhvEfoNNRaGkyLln9Os7r0/MCxqHjHyBM7dT3pgTiBybqiPtpqKfpENwdBp50Q==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/pinkie-promise": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-1.0.0.tgz",
"integrity": "sha512-5mvtVNse2Ml9zpFKkWBpGsTPwm3DKhs+c95prO/F6E7d6DN0FPqxs6LONpLNpyD7Iheb7QN4BbUoKJgo+DnkQA==",
"dependencies": {
"pinkie": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/plist": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/plist/-/plist-1.1.0.tgz",
"integrity": "sha512-MYB88Mp5Ep79QuHbDWIJsT8OrCLRwV1sVD+3sJQUSZRKf/Mm/378053MUipNDMok4kH7c9pyef0BW+wC14xvOQ==",
"dependencies": {
"base64-js": "0.0.6",
"util-deprecate": "1.0.0",
"xmlbuilder": "2.2.1",
"xmldom": "0.1.x"
}
},
"node_modules/plist/node_modules/base64-js": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.6.tgz",
"integrity": "sha512-fsyA7iUnTsMJtsDqcL/8BqXAp66zldDas+PP1lDY6fVjcXxjQllGSmuT58evJbqmLK1WutPTq/lmQqFCN2eftw==",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/pseudomap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
"integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ=="
},
"node_modules/rimraf": {
"version": "5.0.10",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.10.tgz",
@ -530,6 +826,24 @@
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/simple-plist": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-0.0.4.tgz",
"integrity": "sha512-YAKuAmppvbHhwhO8ILBTvogIYfsgt6JvGzyF/Y8al191N1rnbNAid/VzpINMY4SNWOVx3UXmhtYvvGQN5z6Y0A==",
"dependencies": {
"bplist-creator": "0.0.4",
"bplist-parser": "0.0.6",
"plist": "1.1.0"
}
},
"node_modules/stream-buffers": {
"version": "0.2.6",
"resolved": "https://registry.npmjs.org/stream-buffers/-/stream-buffers-0.2.6.tgz",
"integrity": "sha512-ZRpmWyuCdg0TtNKk8bEqvm13oQvXMmzXDsfD4cBgcx5LouborvU5pm3JMkdTP3HcszyUI08AM1dHMXA5r2g6Sg==",
"engines": {
"node": ">= 0.3.0"
}
},
"node_modules/string-width": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
@ -618,6 +932,14 @@
"node": ">=8"
}
},
"node_modules/strip-eof": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
"integrity": "sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/tar": {
"version": "7.4.3",
"resolved": "https://registry.npmjs.org/tar/-/tar-7.4.3.tgz",
@ -653,6 +975,14 @@
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg=="
},
"node_modules/to-decimal": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-decimal/-/to-decimal-2.0.0.tgz",
"integrity": "sha512-QDK/FxpLrqATwrAwxZ0eMh8kAzMQyMCX2QeFlsNyBWdX+3gKt9hUt4maj51xIG5ksclHGMs+07IyXyCh5UefDQ==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/unbzip2-stream": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz",
@ -668,6 +998,11 @@
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
"dev": true
},
"node_modules/util-deprecate": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.0.tgz",
"integrity": "sha512-sTmIWz2UtUfg8kaf6qlicnMn6ghnpMboyWJAv+kgorwAmCHY78TcfaRWfMD8OECWkqVFwyat+r1VJxA4dDfGSA=="
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@ -796,6 +1131,26 @@
"node": ">=8"
}
},
"node_modules/xmlbuilder": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-2.2.1.tgz",
"integrity": "sha512-/1lEQGgeVQU1a4lB8dMRTiJf9k2WDnwWSxka5via8FZxV9OE7IYidIg9895dhqWx+FVdvHod0fX+j41z7kTXew==",
"dependencies": {
"lodash-node": "~2.4.1"
},
"engines": {
"node": "0.8.x || 0.10.x"
}
},
"node_modules/xmldom": {
"version": "0.1.31",
"resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz",
"integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ==",
"deprecated": "Deprecated due to CVE-2021-21366 resolved in 0.5.0",
"engines": {
"node": ">=0.1"
}
},
"node_modules/yallist": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz",

View file

@ -12,6 +12,7 @@
"dependencies": {
"adm-zip": "^0.5.16",
"applescript": "^1.0.0",
"battery-level": "^3.0.0",
"network": "^0.7.0",
"os": "^0.1.2",
"pidusage": "^3.0.2",
@ -22,6 +23,7 @@
"devDependencies": {
"@types/adm-zip": "^0.5.5",
"@types/auto-launch": "^5.0.5",
"@types/battery-level": "^3.0.2",
"@types/pidusage": "^2.0.5",
"@types/winreg": "^1.2.36"
}

View file

@ -2,6 +2,15 @@
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
getBatteryLevel: () => {
ipcRenderer.invoke('get-battery-level');
},
onGetBatteryLevel: (callback) => {
ipcRenderer.on('on-get-battery-level', callback);
},
unregisterOnGetBatteryLevel: () => {
ipcRenderer.removeAllListeners('on-get-battery-level');
},
copyToClipboard: (content) => {
ipcRenderer.invoke('copy-to-clipboard', content);
},

View file

@ -91,6 +91,19 @@ export class ElectronService {
return false;
}
public async getBatteryLevel(): Promise<number> {
const promise = new Promise<number>((resolve) => {
window.electronAPI.onGetBatteryLevel((event: any, level: number) => {
window.electronAPI.unregisterOnGetBatteryLevel();
resolve(level);
});
});
window.electronAPI.getBatteryLevel();
return await promise;
}
public async isAutoLaunched(): Promise<boolean> {
if (this._isAutoLaunched === undefined) {
try {

View file

@ -81,6 +81,7 @@
<select class="form-select" id="log-level" [(ngModel)]="donateCrypto" [ngModelOptions]="{standalone: true}">
<option [ngValue]="'XMR'">XMR</option>
<option [ngValue]="'BTC'">BTC</option>
<option [ngValue]="'WOW'">WOW</option>
</select>
</div>

View file

@ -151,6 +151,10 @@ declare global {
onTrayQuitDaemon: (callback: (event: any) => void) => void;
setTrayItemEnabled: (id: string, enabled: boolean) => void;
setTrayToolTip: (toolTip: string) => void;
getBatteryLevel: () => void;
onGetBatteryLevel: (callback: (event: any, level: number) => void) => void;
unregisterOnGetBatteryLevel: () => void;
};
}
}