Don't show battery estimate at 0
If we think we're done might as well not show 0h 0min as the estimate and just not show anything.
This commit is contained in:
		
							parent
							
								
									89ca155c43
								
							
						
					
					
						commit
						31a4aff1f8
					
				| 
						 | 
				
			
			@ -200,10 +200,14 @@ const std::string waybar::modules::Battery::getAdapterStatus(uint8_t capacity) c
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
const std::string waybar::modules::Battery::formatTimeRemaining(float hoursRemaining) {
 | 
			
		||||
  hoursRemaining = std::fabs(hoursRemaining);
 | 
			
		||||
  hoursRemaining = std::fabs(hoursRemaining); 
 | 
			
		||||
  uint16_t full_hours = static_cast<uint16_t>(hoursRemaining);
 | 
			
		||||
  uint16_t minutes = static_cast<uint16_t>(60 * (hoursRemaining - full_hours));
 | 
			
		||||
  auto     format = std::string("{H} h {M} min");
 | 
			
		||||
  if (full_hours == 0 && minutes == 0) {
 | 
			
		||||
    // Migh as well not show "0h 0min"
 | 
			
		||||
    return "";
 | 
			
		||||
  }
 | 
			
		||||
  if (config_["format-time"].isString()) {
 | 
			
		||||
    format = config_["format-time"].asString();
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue