System power and battery status monitoring and automation in Julia
Uses https://github.com/distatus/battery
pkg> add PowerMonitor
julia> import PowerMonitor
julia> PowerMonitor.status()
PowerMonitor.PowerStatus(:charging, 84.0)
import PowerMonitor
PowerMonitor.automate(
Dict( :nobatteries => ()->println("Batteries not included"),
:charging => ()->println("Plugged in"),
:full => ()->println("Plugged in & full"),
:discharging => ()->println("On battery & discharging"),
:unknown => ()->nothing,
);
interval = 1
)
To stop all automation:
PowerMonitor.stop_automation()
Add this to .julia/config/startup.jl
to disable Julia Pkg's auto-precompilation (requires v1.6) when on battery
import PowerMonitor
PowerMonitor.autoprecomp_notbattery()