Coder Social home page Coder Social logo

svartalf / rust-battop Goto Github PK

View Code? Open in Web Editor NEW
448.0 11.0 19.0 104 KB

Interactive batteries viewer

Home Page: https://crates.io/crates/battop

License: Apache License 2.0

Rust 100.00%
battery battery-monitor tui terminal linux macos freebsd dragonflybsd

rust-battop's People

Contributors

lyokum avatar svartalf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-battop's Issues

[feature request] allow fractional "delay" time

It would be cool if I could get a more fluent chart with --delay option set to something like 0.5, 0.2 or 0.1, or 0.01 seconds.

If I ever finally get more serious about Rust I might implement this myself :)

Build failing on Fedora 36

Hi, just tried building this on Fedora Linux 36 (Workstation Edition). It failed at building uom, and it seems to be this exact issue.

Without much experience in rust / cargo / the build system, I tried looking at Cargo.toml if there's a direct dependency on an older uom version, but there's none, right?

I'm not sure what to do, and just reporting what I experienced.

brew formula

Hi, is it possible to wrap the code into a brew formula for quick installation? Thanks.

RUSTSEC-2022-0006: Data race in `Iter` and `IterMut`

Data race in Iter and IterMut

Details
Package thread_local
Version 0.3.4
URL Amanieu/thread_local-rs#33
Date 2022-01-23
Patched versions >=1.1.4

In the affected version of this crate, {Iter, IterMut}::next used a weaker memory ordering when loading values than what was required, exposing a potential data race
when iterating over a ThreadLocal's values.

Crates using Iter::next, or IterMut::next are affected by this issue.

See advisory page for additional details.

RUSTSEC-2020-0159: Potential segfault in `localtime_r` invocations

Potential segfault in localtime_r invocations

Details
Package chrono
Version 0.4.19
URL chronotope/chrono#499
Date 2020-11-10

Impact

Unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires an environment variable to be set in a different thread than the affected functions. This may occur without the user's knowledge, notably in a third-party library.

Workarounds

No workarounds are known.

References

See advisory page for additional details.

battop exits when plugging AC back in

Running battop 0.2.2, installed via yay -S battop on ArchLinux 5.1.5-arch1-2-ARCH.
Battery detected as SMP DELL GPM0365.

Steps to reproduce:

  1. launch battop
  2. plug AC out.
  3. wait more than ~2/3 seconds.
  4. plug AC back in.
  5. battop exits apparently gracefully (running with RUST_BACKTRACE=1 does not report anything).

stderr collected via -vvvvv:

2019-05-29T11:50:25+00:00 - ERROR - Error occurred: Battery(Error { source: Os { code: 19, kind: Other, message: "No such device" }, description: None })
Error: Battery(Error { source: Os { code: 19, kind: Other, message: "No such device" }, description: None })

RUSTSEC-2020-0071: Potential segfault in the time crate

Potential segfault in the time crate

Details
Package time
Version 0.1.44
URL time-rs/time#293
Date 2020-11-18
Patched versions >=0.2.23
Unaffected versions =0.2.0,=0.2.1,=0.2.2,=0.2.3,=0.2.4,=0.2.5,=0.2.6

Impact

Unix-like operating systems may segfault due to dereferencing a dangling pointer in specific circumstances. This requires an environment variable to be set in a different thread than the affected functions. This may occur without the user's knowledge, notably in a third-party library.

The affected functions from time 0.2.7 through 0.2.22 are:

  • time::UtcOffset::local_offset_at
  • time::UtcOffset::try_local_offset_at
  • time::UtcOffset::current_local_offset
  • time::UtcOffset::try_current_local_offset
  • time::OffsetDateTime::now_local
  • time::OffsetDateTime::try_now_local

The affected functions in time 0.1 (all versions) are:

  • at
  • at_utc

Non-Unix targets (including Windows and wasm) are unaffected.

Patches

Pending a proper fix, the internal method that determines the local offset has been modified to always return None on the affected operating systems. This has the effect of returning an Err on the try_* methods and UTC on the non-try_* methods.

Users and library authors with time in their dependency tree should perform cargo update, which will pull in the updated, unaffected code.

Users of time 0.1 do not have a patch and should upgrade to an unaffected version: time 0.2.23 or greater or the 0.3. series.

Workarounds

No workarounds are known.

References

time-rs/time#293

See advisory page for additional details.

Stack overflow on battery removal

Description

First world problem: When removing the (only) battery that is installed on my system, battop crashes:

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
[1] 23948 abort (core dumped) battop

The terminal becomes unusable after battop crashed (random inserted characters when using the mouse, sigterm will not work).

System info:

  • Arch linux, kernel 5.1.3
  • Thinkpad P71
  • battop 0.2.3

Additional notes

  • battop works fine when not removing the battery. Temperature monitoring does not work (not available), but I guess this is something system-specific.
  • The reason I am swapping batteries is to be able to charge my second one

Let me know if there is any information that is missing.

ERROR - Unable to find any batteries in system, exiting | Error: NoBatteries

I am using Thinkpad T16 Gen 1 and I got this error

2023-09-02T03:12:01+08:00 - ERROR - Unable to find any batteries in system, exiting
Error: NoBatteries

This s the result of the command you posted

/sys/class/power_supply
cat: /sys/class/power_supply: Is a directory

/sys/class/power_supply/BAT0
cat: /sys/class/power_supply/BAT0: Is a directory

/sys/class/power_supply/BAT0/uevent
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Charging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-poly
POWER_SUPPLY_CYCLE_COUNT=4
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=15440000
POWER_SUPPLY_VOLTAGE_NOW=16094000
POWER_SUPPLY_POWER_NOW=71618000
POWER_SUPPLY_ENERGY_FULL_DESIGN=86000000
POWER_SUPPLY_ENERGY_FULL=87740000
POWER_SUPPLY_ENERGY_NOW=29100000
POWER_SUPPLY_CAPACITY=33
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=LNV-5B10W51871@�
POWER_SUPPLY_MANUFACTURER=SMP
POWER_SUPPLY_SERIAL_NUMBER= 2999

/sys/class/power_supply/BAT0/serial_number
 2999

/sys/class/power_supply/BAT0/technology
Li-poly

/sys/class/power_supply/BAT0/power_now
71618000

/sys/class/power_supply/BAT0/charge_stop_threshold
100

/sys/class/power_supply/BAT0/present
1

/sys/class/power_supply/BAT0/power
cat: /sys/class/power_supply/BAT0/power: Is a directory

/sys/class/power_supply/BAT0/manufacturer
SMP

/sys/class/power_supply/BAT0/charge_control_start_threshold
0

/sys/class/power_supply/BAT0/hwmon2
cat: /sys/class/power_supply/BAT0/hwmon2: Is a directory

/sys/class/power_supply/BAT0/device
cat: /sys/class/power_supply/BAT0/device: Is a directory

/sys/class/power_supply/BAT0/energy_now
29100000

/sys/class/power_supply/BAT0/type
Battery

/sys/class/power_supply/BAT0/capacity
33

/sys/class/power_supply/BAT0/cycle_count
4

/sys/class/power_supply/BAT0/voltage_now
16094000
find: File system loop detected; ‘/sys/class/power_supply/BAT0/subsystem’ is part of the same file system loop as ‘/sys/class/power_supply’.

/sys/class/power_supply/BAT0/status
Charging

/sys/class/power_supply/BAT0/charge_behaviour
[auto] inhibit-charge force-discharge

/sys/class/power_supply/BAT0/alarm
0

/sys/class/power_supply/BAT0/model_name
LNV-5B10W51871@�

/sys/class/power_supply/BAT0/voltage_min_design
15440000

/sys/class/power_supply/BAT0/capacity_level
Normal

/sys/class/power_supply/BAT0/energy_full_design
86000000

/sys/class/power_supply/BAT0/charge_control_end_threshold
100

/sys/class/power_supply/BAT0/energy_full
87740000

/sys/class/power_supply/BAT0/charge_start_threshold
0

/sys/class/power_supply/AC
cat: /sys/class/power_supply/AC: Is a directory

/sys/class/power_supply/AC/uevent
POWER_SUPPLY_NAME=AC
POWER_SUPPLY_TYPE=Mains
POWER_SUPPLY_ONLINE=1

/sys/class/power_supply/AC/power
cat: /sys/class/power_supply/AC/power: Is a directory

/sys/class/power_supply/AC/online
1

/sys/class/power_supply/AC/device
cat: /sys/class/power_supply/AC/device: Is a directory

/sys/class/power_supply/AC/wakeup30
cat: /sys/class/power_supply/AC/wakeup30: Is a directory

/sys/class/power_supply/AC/type
Mains

/sys/class/power_supply/AC/hwmon0
cat: /sys/class/power_supply/AC/hwmon0: Is a directory
find: File system loop detected; ‘/sys/class/power_supply/AC/subsystem’ is part of the same file system loop as ‘/sys/class/power_supply’.

Windows support

This is a tracking issue for Windows support.

Main problem is that termion backend for tui dependency does not support Windows terminals.

Another option for tui - crossterm supports Windows and should be considered as a replacement.

Debian packaging for Pop!_OS

Whenever you're ready, I'll package and add this to our Pop repository. This seems like a very useful tool for us.

RUSTSEC-2021-0119: Out-of-bounds write in nix::unistd::getgrouplist

Out-of-bounds write in nix::unistd::getgrouplist

Details
Package nix
Version 0.19.1
URL nix-rust/nix#1541
Date 2021-09-27
Patched versions ^0.20.2,^0.21.2,^0.22.2,>=0.23.0
Unaffected versions <0.16.0

On certain platforms, if a user has more than 16 groups, the
nix::unistd::getgrouplist function will call the libc getgrouplist
function with a length parameter greater than the size of the buffer it
provides, resulting in an out-of-bounds write and memory corruption.

The libc getgrouplist function takes an in/out parameter ngroups
specifying the size of the group buffer. When the buffer is too small to
hold all of the reqested user's group memberships, some libc
implementations, including glibc and Solaris libc, will modify ngroups
to indicate the actual number of groups for the user, in addition to
returning an error. The version of nix::unistd::getgrouplist in nix
0.16.0 and up will resize the buffer to twice its size, but will not
read or modify the ngroups variable. Thus, if the user has more than
twice as many groups as the initial buffer size of 8, the next call to
getgrouplist will then write past the end of the buffer.

The issue would require editing /etc/groups to exploit, which is usually
only editable by the root user.

See advisory page for additional details.

RUSTSEC-2020-0168: mach is unmaintained

mach is unmaintained

Details
Status unmaintained
Package mach
Version 0.3.2
URL fitzgen/mach#63
Date 2020-07-14

Last release was almost 4 years ago.

Maintainer(s) seem to be completely unreachable.

Possible Alternative(s)

These may or may not be suitable alternatives and have not been vetted in any way;

See advisory page for additional details.

Problems on Linux

I have tested battop on Linux and I found two issues:

  • Temperature doesn't seem to work at all
  • Cycles count shows 0 even tough I have used this laptop over 2 years almost every day. ( Maybe it is because I have installed the OS just yesterday? )

Here is a screenshot on Linux Mint 19.1
image

Build fails with battery crate version < 0.7.5

Just a heads up, build fails now with any version of the battery crate < 0.7.5. It might be worth bumping versions and making another release so builds work when people use the release tarball. I made a note with a sed hack on the AUR for anyone trying to grab the package there.

Nice tool by the way, thanks for your work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.