Fix battery reporting on Dells
This commit is contained in:
		
							parent
							
								
									ae0c29559c
								
							
						
					
					
						commit
						047db4eb8c
					
				| @ -1315,8 +1315,12 @@ read_battery_status (int dir, struct error **e) | |||||||
| 	 || (charge_full = read_number (dir, "charge_full", &error), error)) | 	 || (charge_full = read_number (dir, "charge_full", &error), error)) | ||||||
| 		error_propagate (e, error); | 		error_propagate (e, error); | ||||||
| 	else | 	else | ||||||
| 		result = xstrdup_printf ("%s (%u%%)", | 	{ | ||||||
| 			status, (unsigned) (charge_now / charge_full * 100 + 0.5)); | 		// Dell is being unreasonable and seems to set charge_now
 | ||||||
|  | 		// to charge_full_design when the battery is fully charged
 | ||||||
|  | 		unsigned percentage = charge_now / charge_full * 100 + 0.5; | ||||||
|  | 		result = xstrdup_printf ("%s (%u%%)", status, MIN (percentage, 100)); | ||||||
|  | 	} | ||||||
| 
 | 
 | ||||||
| 	free (status); | 	free (status); | ||||||
| 	return result; | 	return result; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user