Release Vulpes OS 2.7-preview.24

This commit is contained in:
OverSu 2026-11-04 12:52:20 +01:00
commit 97ef99f827
135 changed files with 7717 additions and 2524 deletions

View file

@ -15,7 +15,33 @@ def battery_state(root=Path('/sys/class/power_supply/battery')):
status = (root/'status').read_text().strip()
if not 0 <= level <= 100 or status not in ('Charging', 'Discharging', 'Full', 'Not charging'):
return None
return {'level': level/100, 'charging': status in ('Charging', 'Full'), 'status': status}
charging = status in ('Charging', 'Full')
state = {'level': level/100, 'charging': charging, 'status': status}
# Linux power-supply values use matching micro-units, so their ratio
# gives hours. Keep the estimate absent when the driver has no usable
# current/energy telemetry; Gaia will show that honestly.
try:
energy = int((root/'energy_now').read_text().strip())
power = abs(int((root/'power_now').read_text().strip()))
if charging:
energy = int((root/'energy_full').read_text().strip()) - energy
if power > 0 and energy > 0:
seconds = energy * 3600 / power
if 0 < seconds < 10 * 24 * 3600:
state['chargingTime' if charging else 'dischargingTime'] = seconds
except (OSError, ValueError):
try:
charge = int((root/'charge_counter').read_text().strip())
current = abs(int((root/'current_now').read_text().strip()))
if charging:
charge = int((root/'charge_full').read_text().strip()) - charge
if current > 0 and charge > 0:
seconds = charge * 3600 / current
if 0 < seconds < 10 * 24 * 3600:
state['chargingTime' if charging else 'dischargingTime'] = seconds
except (OSError, ValueError):
pass
return state
except (OSError, ValueError):
return None