Skip to content

Commit

Permalink
Fix notification
Browse files Browse the repository at this point in the history
  • Loading branch information
yehwankim23 committed Jul 21, 2024
1 parent a6b7b1b commit 9418779
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ npm i
npm run make
```

2. Unzip `out/make/zip/darwin/arm64/Battery Status-darwin-arm64-2024.1.0.zip`
2. Unzip `out/make/zip/darwin/arm64/Battery Status-darwin-arm64-#.#.#.zip`
3. Move `Battery Status.app` to the `Applications` folder
4. (Optional) Add `Battery Status.app` in `System Settings` > `General` > `Login Items` > `+` to run `Battery Status` on computer startup
5. Run `Battery Status.app`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"productName": "Battery Status",
"name": "battery-status",
"version": "2024.1.0",
"version": "2024.7.0",
"description": "Program that notifies the user when it's time to plug in or unplug the laptop to maximize the battery life",
"license": "LGPL-3.0-or-later",
"author": {
Expand Down
6 changes: 3 additions & 3 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ function main() {

navigator.getBattery().then((batteryManager) => {
batteryManager.addEventListener("levelchange", (_event) => {
const level = batteryManager.level * 100;
const level = Math.round(batteryManager.level * 100);

if (batteryManager.charging) {
if (level >= 80) {
sendNotification("Battery sufficiently charged");
sendNotification(`You might want to unplug your PC (${level}%)`);
}

return;
}

if (level <= 20) {
sendNotification(`Low Battery: ${level}% battery remaining`);
sendNotification(`You might want to plug in your PC (${level}%)`);
}
});
});
Expand Down

0 comments on commit 9418779

Please sign in to comment.