How to get Laptop battery level
Dukc
ajieskola at gmail.com
Mon Feb 22 21:14:48 UTC 2021
On Monday, 22 February 2021 at 20:59:01 UTC, Greatsam4sure wrote:
> Dlang is a system programming language. How do I access the
> battery level of my system using code in dlang?
As a systems language, D could access the hardware interface
directly, if you knew it and loaded your program as a kernel
driver - if your operating system lets you do that.
Now, I don't think that was the most practical way to approach
the problem :-). Instead, I recommend you use the SDL2 multimedia
library to give you a more portable interface. Usage example in D
here:
https://github.com/Dgame/Dgame/blob/master/source/Dgame/System/Battery.d
Note that the D module I linked does not contain the machinery to
initialize SDL2. This module seems to contain that:
https://github.com/Dgame/Dgame/blob/master/source/Dgame/Window/Window.d
Note that DGame seems to be currently unmaintained - it might
have some bits that do not compile anymore. SDL2 is a commonly
used library though - you should be able to find more examples
about it if you need to.
More information about the Digitalmars-d-learn
mailing list