All Projects → svartalf → Rust Battery

svartalf / Rust Battery

Licence: other
Rust crate providing cross-platform information about the notebook batteries.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Rust Battery

Rust Battop
Interactive batteries viewer
Stars: ✭ 133 (-50.37%)
Mutual labels:  freebsd, battery
gost
Build a local copy of Security Tracker. Notify via E-mail/Slack if there is an update.
Stars: ✭ 108 (-59.7%)
Mutual labels:  freebsd
batify
Only one udevrule file triggering plug and critical battery level notifications (multi-x sessions support)
Stars: ✭ 47 (-82.46%)
Mutual labels:  battery
tesla-style-solar-power-card
Home assistant power card mimicking the one tesla provides for the powerwall app.
Stars: ✭ 103 (-61.57%)
Mutual labels:  battery
unifi-pfsense
A script that installs the UniFi Controller software on pfSense and other FreeBSD systems
Stars: ✭ 617 (+130.22%)
Mutual labels:  freebsd
libjail-rs
Rust implementation of a FreeBSD jail library
Stars: ✭ 32 (-88.06%)
Mutual labels:  freebsd
dotfiles
My .dotfiles
Stars: ✭ 12 (-95.52%)
Mutual labels:  freebsd
Poudriere
Port/Package build and test system
Stars: ✭ 257 (-4.1%)
Mutual labels:  freebsd
BatteryView
Simple battery shaped UIView
Stars: ✭ 49 (-81.72%)
Mutual labels:  battery
impedance.py
A Python package for working with electrochemical impedance data
Stars: ✭ 102 (-61.94%)
Mutual labels:  battery
dotfiles
personal dotfiles with stow
Stars: ✭ 16 (-94.03%)
Mutual labels:  freebsd
AndroidBatteryStats
Displays all battery stats of an Android device using broadcast receiver.
Stars: ✭ 20 (-92.54%)
Mutual labels:  battery
powersave
Linux power save settings, compatible with systemd
Stars: ✭ 79 (-70.52%)
Mutual labels:  battery
zelda-battery
A Legend of Zelda inspired health-bar battery meter for the CLI and GUI
Stars: ✭ 22 (-91.79%)
Mutual labels:  battery
vzvol
vzvol is a general use ZFS zvol management tool, that handles creation, destruction, listing, and formatting with various FSes, in an easy to use single program
Stars: ✭ 27 (-89.93%)
Mutual labels:  freebsd
LawRun
Kernel source code (LawRun Kernel) for xiaomi sdm845 | Pocophone f1 (beryllium), Mi 8 (dipper), Mi Mix 2s (polaris) | You can fork and enjoy.
Stars: ✭ 22 (-91.79%)
Mutual labels:  battery
macstats
Mac OS X Statistics - Battery, Fans, CPU
Stars: ✭ 55 (-79.48%)
Mutual labels:  battery
static-web-server
A blazing fast and asynchronous web server for static files-serving. ⚡
Stars: ✭ 230 (-14.18%)
Mutual labels:  freebsd
Krf
A kernelspace syscall interceptor and randomized faulter
Stars: ✭ 267 (-0.37%)
Mutual labels:  freebsd
Twizy-Virtual-BMS
This is an Arduino library providing an emulation of the CAN communication protocol of the BMS (battery management system) on a Renault Twizy.
Stars: ✭ 57 (-78.73%)
Mutual labels:  battery

battery

Latest Version Latest Version Build Status Minimum rustc version Apache 2.0 OR MIT licensed Backers on Open Collective Sponsors on Open Collective

Rust crate providing cross-platform information about the notebook batteries.

Table of contents

Overview

battery provides a cross-platform unified API to a notebook batteries state.

Its main goal is to wrap the OS-specific interfaces, cover all the hacks and legacy cases and get the batteries information (such as state of charge, energy rate, voltage and temperature) as a typed values, recalculated as necessary to be returned as a SI measurement units.

Supported platforms

  • Linux 2.6.39+
  • MacOS 10.10+
  • iOS
  • Windows 7+
  • FreeBSD
  • DragonFlyBSD

Do note that iOS implementation uses IOKit bindings, your application might be automatically rejected by Apple based on that fact. Use it on your own risk.

Install

As a prerequisite, battery crate requires at least Rustc version 1.36 or greater.

Add the following line into a Cargo.toml:

[dependencies]
battery = "0.7.8"

Examples

fn main() -> Result<(), battery::Error> {
    let manager = battery::Manager::new()?;

    for (idx, maybe_battery) in manager.batteries()?.enumerate() {
        let battery = maybe_battery?;
        println!("Battery #{}:", idx);
        println!("Vendor: {:?}", battery.vendor());
        println!("Model: {:?}", battery.model());
        println!("State: {:?}", battery.state());
        println!("Time to full charge: {:?}", battery.time_to_full());
        println!("");
    }

    Ok(())
}

See the battery/examples/ folder in the repository for additional examples.

FFI bindings

Experimental battery-ffi crate provides the FFI bindings to the battery crate, so it can be used with other languages, such as C, Python or NodeJS.

Check its README and documentation for details.

Users

This an incomplete list of the battery crate users. If you are using it too, send me a message and I'll add your project here!

battop

battop is an interactive viewer, similar to top, htop and other *top utilities, but about the batteries installed in your notebook.
It is using the battery crate API to show the batteries information in your terminal.

starship

starship is a Rust port of the minimalistic, powerful, and extremely customizable prompt Spaceship ZSH.
It is using the battery crate to show the the current battery level and status in a shell prompt.

Here is what @matchai says:

I really appreciate how easily we were able to get your library up and running! Battery APIs were a headache for us in predecessors of this project 😅

And there is this tweet also!

License

Licensed under either of Apache License 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Donations

If you appreciate my work and want to support me, you can do it here or support this project at Open Collective.

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].