Skip to content

Commit

Permalink
Merge pull request #119 from igorkulman/fix/battery-percentage-icon
Browse files Browse the repository at this point in the history
Correct way to determine battery percentage icon for the menu tray
  • Loading branch information
actuallymentor authored Mar 26, 2023
2 parents 5f5d259 + f6d56e6 commit f601da1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions app/modules/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ const get_logo_template = ( percent = 100, active ) => {
for( let percentage = 0; percentage <= 100; percentage+=percentage_increment_to_render ) {
image_percentages.push( percentage )
}
image_percentages.sort()
image_percentages.sort((a, b) => a - b)

// Find which image size is the highest that is still under the current percentage
let display_percentage = 20
image_percentages.map( percent_option => {
if( percent_option <= percent ) display_percentage = percent_option
} )
log( `Display percentage ${ display_percentage } based on ${ percent }` )
let display_percentage = image_percentages.findLast((p) => p < percent)
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

0 comments on commit f601da1

Please sign in to comment.