mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Remove Win32API calls & upgrade to modern Ruby (#96)
* Win32API removal + Ruby 3 updates * Update binaries to match mkxp-z 2.1
This commit is contained in:
@@ -211,23 +211,14 @@ end
|
||||
|
||||
|
||||
def pbBatteryLow?
|
||||
power="\0"*12
|
||||
begin
|
||||
sps=Win32API.new('kernel32.dll','GetSystemPowerStatus','p','l')
|
||||
rescue
|
||||
return false
|
||||
end
|
||||
if sps.call(power)==1
|
||||
status=power.unpack("CCCCVV")
|
||||
# AC line presence
|
||||
return false if status[0]!=0 # Not plugged in or unknown
|
||||
# Battery Flag
|
||||
return true if status[1]==4 # Critical (<5%)
|
||||
# Battery Life Percent
|
||||
return true if status[2]<3 # Less than 3 percent
|
||||
# Battery Life Time
|
||||
return true if status[4]>0 && status[4]<300 # Less than 5 minutes and unplugged
|
||||
end
|
||||
pstate = System.power_state
|
||||
# If it's not discharging, it doesn't matter if it's low
|
||||
return false if !pstate[:discharging]
|
||||
# Check for less than 10m, priority over the percentage
|
||||
# Some laptops (Chromebooks, Macbooks) have very long lifetimes
|
||||
return true if pstate[:seconds] && pstate[:seconds] <= 600
|
||||
# Check for <=15%
|
||||
return true if pstate[:percent] && pstate[:percent] <= 15
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user