batnotifsd — Battery notifications daemon
What
This is a Python script that sends notifications about the battery's status (charger plugged in/unplugged, low/critical battery levels).
It's useful for window managers where you don't get this functionality out of the box like in a desktop environment.
Why
I wrote this because I simply could not find anything else that did the job 100%
right. The internet is full of shell scripts that just tap into
/sys/class/power_supply and take info from that in a while true loop with a
sleep, most don't even autodetect the laptop's battery and they make you set a
variable for the right battery for you, or, even worse, manually edit the shell
script to put it in.
How
This Python script uses the pydbus library to
get information directly from UPower through
DBus, and then send it back through DBus using
the org.freedesktop.Notifications bus, all in a
GLib loop.
Also, it automatically detects the first battery that classifies as a laptop battery1.
Usage
To start the daemon, simply use:
$ batnotifsd
You probably want to add it to the autostart of your window manager, check with your WM's documentation for that.
Packages
NixOS
A derivation for this package is available inside
my Nix package collection.
Just follow
my-nixpkgs/Usage
to add the flake to your config and to add the program to your
environment.systemPackages.
Right now I'm the only person actually using this program, so it's only available in the repo with my personal Nix derivations. If there's going to be any interest in it, I'll upstream a derivation into Nixpkgs.
Feel free to just take out the derivation from the pkgs/ folder and stick it in your configuration, if you know what you're doing.
PyPi
This script is available in PyPi here.
To install it using pip, run:
$ pip install batnotifsd
About the flake
The Nix flake present in this repo is just the development shell I use to test this script.
More info
- pydbus documentation
- pydbus tutorial (teaches how to actually take values out of DBus)
- pydbus notification example (teaches how to send notifications using DBus)
org.freedesktop.UPower.devicespecification in the UPower Manual (teaches what UPower properties are there and what they mean)
-
If the value is set to "Battery", you will need to verify that the property power-supply has the value "true" before considering it as a laptop battery. Otherwise it will likely be the battery for a device of an unknown type. —
org.freedesktop.UPower.devicespecification in the UPower Manual ↩
Metadata
Release files for batnotifsd 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| batnotifsd-1.0.5.tar.gz | 11.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| batnotifsd-1.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.4 kB
Release files / batnotifsd-1.0.5.tar.gz
| Download URL | batnotifsd-1.0.5.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c93761ddeeaddd3b099a44e95609e0852c1ec42f1a56e560d8f500ee3d7d04ba
|
|
BLAKE2b-256 checksum How to use checksums |
e8d0c2ce3cdfcb46cd5b33daf9eb50e67fc10b589adfbab07c127885a7d39152
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Release files / batnotifsd-1.0.5-py3-none-any.whl
| Download URL | batnotifsd-1.0.5-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5115e6e7a355ffab28e73b4a7548de67b47c18169440cfea77cabd7fa17ed63e
|
|
BLAKE2b-256 checksum How to use checksums |
5355a7aa2a6faeaf46d21b3229c8de7aa18b5be2e61cf8b855cd6099e77f8a39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.5
|
Security for batnotifsd 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.