Skip to content

Battery

Library and CLI tool for monitoring upowerd devices.

Usage

You can browse the Battery reference.

CLI

sh
astal-battery --help

Library

js
import Battery from "gi://AstalBattery"

const battery = Battery.get_default()

print(battery.percentage)
py
from gi.repository import AstalBattery as Battery

battery = Battery.get_default()

print(battery.get_percentage())
lua
local Battery = require("lgi").require("AstalBattery")

local battery = Battery.get_default()

print(battery.percentage)
vala
// Not yet documented

Installation

  1. install dependencies
sh
sudo pacman -Syu meson vala json-glib gobject-introspection
sh
sudo dnf install meson vala valadoc json-glib-devel gobject-introspection-devel
sh
sudo apt install meson valac libjson-glib-dev gobject-introspection

INFO

Although UPower is not a direct build dependency, it should be self-explanatory that the daemon is required to be available at runtime.

  1. clone repo
sh
git clone https://github.com/aylur/astal.git
cd astal/lib/battery
  1. install
sh
meson setup --prefix /usr build
meson install -C build

Released under the LGPL v2.1 License