Files
astal/docs/libraries/powerprofiles.md
2024-09-14 09:55:29 +00:00

1.9 KiB

Power Profiles

Library and CLI tool for monitoring upowerd powerprofiles.

Installation

  1. 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. :::

  1. clone repo
git clone https://github.com/aylur/astal.git
cd astal/lib/powerprofiles
  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 PowerProfiles reference.

CLI

astal-power-profiles --help

Library

:::code-group

import PowerProfiles from "gi://AstalPowerProfiles"

const powerprofiles = PowerProfiles.get_default()

print(powerprofiles.activeProfile)
from gi.repository import AstalPowerProfiles as PowerProfiles

powerprofiles = PowerProfiles.get_default()

print(powerprofiles.get_active_profile())
local PowerProfiles = require("lgi").require("AstalPowerProfiles")

local powerprofiles = PowerProfiles.get_default()

print(powerprofiles.active_profile)
// Not yet documented

:::