mirror of
				https://github.com/rad4day/Waybar.git
				synced 2025-11-04 09:42:42 +01:00 
			
		
		
		
	Always mark battery as full at 100%
Since we're now clamping at 100% and rounding, mark as full at that point. Some batteries will stay in charging state for a long time while stuck at the same charge level. Just mark them as full to not be confusing.
This commit is contained in:
		@@ -134,11 +134,17 @@ const std::tuple<uint8_t, float, std::string> waybar::modules::Battery::getInfos
 | 
			
		||||
    }
 | 
			
		||||
    if (capacity > 100.f) {
 | 
			
		||||
      // This can happen when the battery is calibrating and goes above 100%
 | 
			
		||||
      // Handle it gracefully by clamping at 100% and presenting it as full
 | 
			
		||||
      // Handle it gracefully by clamping at 100%
 | 
			
		||||
      capacity = 100.f;
 | 
			
		||||
    }
 | 
			
		||||
    uint8_t cap = round(capacity);
 | 
			
		||||
    if (cap == 100) {
 | 
			
		||||
      // If we've reached 100% just mark as full as some batteries can stay
 | 
			
		||||
      // stuck reporting they're still charging but not yet done
 | 
			
		||||
      status = "Full";
 | 
			
		||||
    }
 | 
			
		||||
    return {round(capacity), time_remaining, status};
 | 
			
		||||
 | 
			
		||||
    return {cap, time_remaining, status};
 | 
			
		||||
  } catch (const std::exception& e) {
 | 
			
		||||
    spdlog::error("Battery: {}", e.what());
 | 
			
		||||
    return {0, 0, "Unknown"};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user