Files
astal/docs/libraries/battery.md
2024-09-11 13:30:51 +00:00

1.6 KiB

Battery

Library and CLI tool for monitoring upowerd devices.

Installation

  1. install dependencies

:::code-group

sudo pacman -Syu meson vala gobject-introspection
sudo dnf install meson gcc valac gobject-introspection-devel
sudo apt install meson valac 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
git clone https://github.com/aylur/astal.git
cd astal/lib/battery
  1. 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()

console.log(battery.percentage)
# Not yet documented
-- Not yet documented
// Not yet documented

:::