mirror of
https://github.com/zoriya/astal.git
synced 2026-06-03 18:31:16 +00:00
1.8 KiB
1.8 KiB
Battery
Library and CLI tool for monitoring upowerd devices.
Installation
- install dependencies
:::code-group
sudo pacman -Syu meson vala json-glib gobject-introspection
sudo dnf install meson gcc valac json-glib-devel gobject-introspection-devel
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. :::
- clone repo
git clone https://github.com/aylur/astal.git
cd astal/lib/battery
- install
meson setup build
meson install -C build
:::tip
Most distros recommend manual installs in /usr/local,
which is what meson defaults to. If you want to install to /usr
instead which most package managers do, set the prefix option:
meson setup --prefix /usr build
:::
Usage
You can browse the Battery reference.
CLI
astal-battery --help
Library
:::code-group
import Battery from "gi://AstalBattery"
const battery = Battery.get_default()
print(battery.percentage)
from gi.repository import AstalBattery as Battery
battery = Battery.get_default()
print(battery.get_percentage())
local Battery = require("lgi").require("AstalBattery")
local battery = Battery.get_default()
print(battery.percentage)
// Not yet documented
:::