Skip to content

Commit

Permalink
Merge pull request #125 from bjarketrux/main
Browse files Browse the repository at this point in the history
Battery percentage calculated
  • Loading branch information
actuallymentor authored Jul 20, 2023
2 parents 79df4af + 4d571f3 commit bbd4d32
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 2 additions & 9 deletions app/modules/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@ const get_logo_template = ( percent = 100, active ) => {
// Image sizes available
// see assets/modules/compile-images.je for values
const percentage_increment_to_render = 5
const image_percentages = []
for( let percentage = 0; percentage <= 100; percentage+=percentage_increment_to_render ) {
image_percentages.push( percentage )
}
image_percentages.sort((a, b) => a - b)

// Find which image size is the highest that is still under the current percentage
let display_percentage = image_percentages.findLast((p) => p < percent)
log(`Display percentage ${display_percentage} based on ${percent}`)
const display_percentage = Math.floor( percent / percentage_increment_to_render ) * percentage_increment_to_render
log( `Display percentage ${ display_percentage } based on ${ percent }` )

const image_path = path.join( asset_path, `/battery-${ active ? 'active' : 'inactive' }-${ display_percentage }-Template.png` )
const exists = existsSync( image_path )
Expand Down
4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "battery",
"version": "1.1.4",
"version": "1.1.5",
"description": "A battery charge limiter for Apple silicon Mac devices",
"main": "main.js",
"build": {
Expand Down Expand Up @@ -56,4 +56,4 @@
"electron-store": "^8.1.0",
"update-electron-app": "^2.0.1"
}
}
}

0 comments on commit bbd4d32

Please sign in to comment.