Skip to main content

code style: prettier

Battery Status Notifier (bsnotifier)

Command line application that shows a popup window when the battery is low. This Python script can be used to notify battery status in i3wm environments.

Notifier Popup Window

Table of contents

Get started

Installation

This application can be simply installed by running:

pip install bsnotifier

if you want to install from a source distribution:

git clone https://github.com/eccanto/battery-status-notifier
cd battery-status-notifier/
python setup.py install

Usage

To start the notifier you must run the command line application:

bsnotifier

By default the application will check the battery status every 1:30 minutes, if the battery percentage is less than 10% a popup window will be shown.

How to use it with i3

Auto start the notifier application in i3:

  1. Linking the application executable to make it accessible to other users.

    BSNOTIFIER_PATH="$(which bsnotifier)"
    sudo ln -s "${BSNOTIFIER_PATH}" /usr/bin/bsnotifier
    
  2. Edit i3 config file.

    # ~/.config/i3/config
    ...
    exec --no-startup-id bsnotifier -o "$(mktemp)"
    ...
    

Options

$ bsnotifier --help

Usage: bsnotifier [OPTIONS]

  Command line application that shows a popup window when the battery is low.

Options:
  -i, --interval INTEGER  The time interval in seconds that the script waits
                          before checking the battery again (default: 150.0
                          seconds).
  -l, --level INTEGER     The battery percentage at which the popup window is
                          displayed (default: 10).
  -s, --silent            Do not play the sound when popup window is
                          displayed.
  -o, --output PATH       Log file path (default: .bsnotifier.log).
  --help                  Show this message and exit.

Developers

Testing release with Tox

Requirements

Python requirements:

pip3 install -r requirements_testing.txt

Set Python versions

  1. Install pyenv
  2. Install python versions:
    for python_version in "3.7" "3.8" "3.9" "3.10" "3.11" ; do pyenv install ${python_version}; done
    
  3. Enable python versions:
    pyenv local "3.7" "3.8" "3.9" "3.10" "3.11"
    

Run

We use tox and pytest to run the test suite:

tox

to run the test suite for a particular Python version, you can do:

tox -e py37

Static code analysis tools

These are the linters that will help us to follow good practices and style guides of our source code. We will be using the following static analysis tools, which will be executed when generating a new push in the repository (git hooks).

Set up the Git hooks custom directory

After cloning the repository run the following command in the repository root:

git config core.hooksPath .githooks

Python Static Checkers

Tools used:

  • brunette: A best practice Python code formatter.

  • isort: Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.

  • prospector: Prospector is a tool to analyse Python code and output information about errors, potential problems, convention violations and complexity.

    Tools executed by Prospector:

    • pylint: Pylint is a Python static code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions.
    • bandit: Bandit is a tool designed to find common security issues.
    • dodgy: It is a series of simple regular expressions designed to detect things such as accidental SCM diff checkins, or passwords or secret keys hard coded into files.
    • mccabe: Complexity checker.
    • mypy: Mypy is an optional static type checker for Python.
    • pydocstyle: pydocstyle is a static analysis tool for checking compliance with Python PEP 257.
    • pycodestyle: pycodestyle is a tool to check your Python code against some of the style conventions in PEP 8.
    • pyflakes: Pyflakes analyzes programs and detects various errors.
    • pyroma: Pyroma is a product aimed at giving a rating of how well a Python project complies with the best practices of the Python packaging ecosystem, primarily PyPI, pip, Distribute etc, as well as a list of issues that could be improved.

Shell Static Checkers

Tools used:

  • shellcheck: Finds bugs in your shell scripts (bash).

    Installation:

    apt install shellcheck
    
tox -e code_checkers

Run manually

bash scripts/code_checkers.sh

License

MIT

Changelog

  • 1.0.0 - Initial version.
  • 1.0.1 - I3 support.
  • 1.0.2 - Close the popup window when connecting the battery, and update the information in real time.

Metadata

Release files for bsnotifier 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bsnotifier 1.0.2
File Size Uploaded Provenance Actions
bsnotifier-1.0.2.tar.gz 128.5 kB Without provenance Details for bsnotifier-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bsnotifier 1.0.2
File Interpreter ABI Platform Actions
bsnotifier-1.0.2-py3-none-any.whl Python 3 none any Details for bsnotifier-1.0.2-py3-none-any.whl

Total release size: 253.6 kB

Release files / bsnotifier-1.0.2.tar.gz

Download URL bsnotifier-1.0.2.tar.gz
Size 128.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bb91da98423e5106d1c85cfb1b0af093e4e62ca817274f2940ad98a0f47e72b9
BLAKE2b-256 checksum
How to use checksums
bd70768ccf47671c9a61b03a11dd96cb85ed9845936bcd802e23cf88c01b0eb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.0

Release files / bsnotifier-1.0.2-py3-none-any.whl

Download URL bsnotifier-1.0.2-py3-none-any.whl
Size 125.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8611f5236a1f503f5270984f8434b9322e6a4912d8a70211ec92caf424badfcf
BLAKE2b-256 checksum
How to use checksums
433226a84941d62937e920bf7a119253a7d821e0fbc8e1865dd54c2644784b24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.0

Security for bsnotifier 1.0.2

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page