Commit 702f5a33 authored by Guido Gunther's avatar Guido Gunther
Browse files

Initial commit

parents
Pipeline #50170 passed with stages
in 2 minutes and 58 seconds
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
[meson.build]
indent_size = 2
tab_size = 2
indent_style = space
[*.{c,h,h.in}]
indent_size = 2
tab_size = 2
indent_style = space
max_line_length = 80
[*.css]
indent_size = 2
tab_size = 2
indent_style = space
[*.xml]
indent_size = 2
tab_size = 2
indent_style = space
[*.json]
indent_size = 2
tab_size = 2
indent_style = space
[NEWS]
max_line_length = 72
_build
debian/.debhelper/
debian/debhelper-build-stamp
debian/files
debian/gir1.2-gtherm-0.0.substvars
debian/gir1.2-gtherm-0.0/
debian/gir1.2-gtherm-1.0.substvars
debian/gir1.2-gtherm-1.0/
debian/gthd.debhelper.log
debian/gthd.substvars
debian/gthd/
debian/libgtherm-0.0-0.substvars
debian/libgtherm-0.0-0/
debian/libgtherm-dev.substvars
debian/libgtherm-dev/
debian/tmp/
include:
- 'https://source.puri.sm/Librem5/librem5-ci/raw/master/librem5-pipeline-definitions.yml'
stages:
- build
- package
- test-package
variables:
DEPS: build-essential git
WANT_BUILD_DEPS: "true"
before_script:
- export DEBIAN_FRONTEND=noninteractive
- apt-get -y update
- apt-get -y build-dep .
.tags: &tags
tags:
- librem5
build:native-debian-buster:
<<: *tags
stage: build
image: debian:buster
artifacts:
paths:
- _build
script:
- meson --werror . _build
- ninja -C _build
build:native-debian-bullseye:
<<: *tags
stage: build
image: debian:bullseye
artifacts:
paths:
- _build
script:
- meson --werror . _build
- ninja -C _build
package:deb-debian-buster:
extends: .l5-build-debian-package
autopkgtest-debian-buster-package:
dependencies:
- package:deb-debian-buster
extends: .l5-autopkgtest-debian-package
This diff is collapsed.
This diff is collapsed.
Thermal information for GNOME
=============================
gtherm provides a DBus daemon (gthd) to monitor thermal zones and cooling
devices. It offers a library (libgtherm) and GObject introspection bindings to
ease reading the values in applications.
## License
gtherm is licensed under the GPLv3+ while the libgtherm library is licensed
under LGPL 2.1+.
## Getting the source
```sh
git clone https://source.puri.sm/guido.gunther/gtherm
cd gtherm
```
The master branch has the current development version.
## Dependencies
On a Debian based system run
```sh
sudo apt-get -y install build-essential
sudo apt-get -y build-dep .
```
For an explicit list of dependencies check the `Build-Depends` entry in the
[debian/control][] file.
## Building
We use the meson (and thereby Ninja) build system for gtherm. The quickest
way to get going is to do the following:
meson . _build
ninja -C _build
ninja -C _build install
## Running
### Running from the source tree
To run the daemon use
```sh
_build/src/gthd
```
You can then see temperature changes via
```sh
gdbus monitor --session --dest org.sigxcpu.Thermal
```
See `examples/` for a simple python example using GObject introspection.
[debian/control]: https://source.puri.sm/guido.gunther/gtherm/blob/master/debian/control#L5
/*
* Copyright (C) 2019 Purism SPC
* SPDX-License-Identifier: GPL-3.0+
* Author: Guido Günther <agx@sigxcpu.org>
*/
#include "libgtherm.h"
#include <glib.h>
#include <gio/gio.h>
#include <locale.h>
static GthManager *
gthcli_get_manager_sync (GDBusConnection *connection)
{
GthManager *manager;
gchar *name_owner;
GError *error = NULL;
manager = gth_manager_new_sync (connection,
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START,
NULL,
&error);
if (!manager) {
g_printerr ("error: couldn't create manager: %s\n",
error ? error->message : "unknown error");
exit (EXIT_FAILURE);
}
name_owner = g_dbus_object_manager_client_get_name_owner (G_DBUS_OBJECT_MANAGER_CLIENT (manager));
if (!name_owner) {
g_printerr ("error: couldn't find the gthd process in the bus\n");
exit (EXIT_FAILURE);
}
g_debug ("Gthd found at '%s'", name_owner);
g_free (name_owner);
return manager;
}
static void
print_tzone (GthThermalZone *tzone)
{
const char * const *cdevs;
cdevs = gth_thermal_zone_get_cooling_devices_dbus_paths (tzone);
g_print (" dbus path: %s\n", gth_thermal_zone_get_path (tzone));
g_print (" type: %s\n", gth_thermal_zone_get_type_ (tzone));
g_print (" temperature: %.2f°C\n", gth_thermal_zone_get_temperature (tzone) / 1000.0);
if (cdevs && cdevs[0])
g_print ("cooling devices: %s\n", cdevs[0]);
for (int i = 1; cdevs[i]; i++)
g_print (" %s\n", cdevs[i]);
g_print ("\n");
}
static void
print_cdev (GthCoolingDevice *cdev)
{
g_print (" dbus path: %s\n", gth_cooling_device_get_path (cdev));
g_print (" type: %s\n", gth_cooling_device_get_type_ (cdev));
g_print (" max state: %d\n", gth_cooling_device_get_max_state (cdev));
g_print ("current state: %d\n", gth_cooling_device_get_current_state (cdev));
g_print ("\n");
}
int main(void)
{
g_autoptr(GError) err = NULL;
g_autoptr(GDBusConnection) connection = NULL;
g_autoptr(GthManager) manager = NULL;
GPtrArray *cdevs, *tzones;
setlocale (LC_ALL, "");
connection = g_bus_get_sync (GTH_DBUS_TYPE, NULL, &err);
if (!connection) {
g_printerr ("error: couldn't get bus: %s\n",
err ? err->message : "unknown error");
exit (EXIT_FAILURE);
}
manager = gthcli_get_manager_sync (connection);
g_print ("\n");
tzones = gth_manager_get_thermal_zones (manager);
g_debug ("Found %d thermal zones\n", tzones->len);
g_print ("Thermal Zones\n");
g_print ("-------------\n");
for (int i = 0; i < tzones->len; i++) {
print_tzone(g_ptr_array_index (tzones, i));
}
cdevs = gth_manager_get_cooling_devices (manager);
g_debug ("Found %d cooling devices\n", cdevs->len);
g_print ("Cooling Devices\n");
g_print ("---------------\n");
for (int i = 0; i < cdevs->len; i++) {
print_cdev(g_ptr_array_index (cdevs, i));
}
return EXIT_SUCCESS;
}
gthcli_sources = [
'gthcli.c',
]
gthcli_deps = [
gio,
gio_unix,
glib,
libgtherm_dep,
]
executable(
'gthcli',
gthcli_sources,
dependencies: gthcli_deps,
install: true,
)
# DBus server interface
prefix = 'org.sigxcpu.Thermal.'
namespace = 'GthGdbus'
generated_dbus_sources = []
dbus_interfaces = [
prefix + 'ThermalZone.xml',
prefix + 'CoolingDevice.xml',
]
# Thermal Zones interface
generated_dbus_sources += gnome.gdbus_codegen('gth-gdbus',
sources : dbus_interfaces,
object_manager : true,
docbook : 'libgtherm',
interface_prefix : prefix,
install_header : true,
install_dir : join_paths(get_option('includedir'), libname),
namespace : namespace)
dbus_header_dir = meson.current_build_dir()
install_data(dbus_interfaces, install_dir: ifacedir)
<?xml version="1.0" encoding="UTF-8" ?>
<node>
<!-- org.sigxcpu.Thermal.CoolingDevice
@short_description: Cooling device
This D-Bus interface is used to describe a cooling device.
-->
<interface name="org.sigxcpu.Thermal.CoolingDevice">
<!-- Type: type of the cooling device -->
<property name="Type" type="s" access="read"/>
<!-- CurrentState: the current cooling state of the device -->
<property name="CurrentState" type="i" access="read"/>
<!-- MaxState: the maximum cooling state of the device -->
<property name="MaxState" type="i" access="read"/>
</interface>
</node>
<?xml version="1.0" encoding="UTF-8" ?>
<node>
<!-- org.sigxcpu.Thermal.ThermalZone
@short_description: Thermal zones
This D-Bus interface is used to describe a termal zone.
-->
<interface name="org.sigxcpu.Thermal.ThermalZone">
<!-- Temperature: The current temperature in mC -->
<property name="Temperature" type="i" access="read"/>
<!-- Type: type of the thermal zone -->
<property name="Type" type="s" access="read"/>
<!-- TripPoints: zones trip points -->
<property name="TripPoints" type="a{s(si)}" access="read"/>
<!-- CoolingDevices: path to cooling devices for this zone -->
<property name="CoolingDevices" type="ao" access="read" />
</interface>
</node>
This package is maintained with git-buildpackage(1). It follows DEP-14
for branch naming (e.g. using debian/sid for the current version
in Debian unstable).
It uses pristine-tar(1) to store enough information in git to generate
bit identical tarballs when building the package without having
downloaded an upstream tarball first.
When working with patches it is recommended to use "gbp pq import" to
import the patches, modify the source and then use "gbp pq export
--commit" to commit the modifications.
The changelog is generated using "gbp dch" so if you submit any
changes don't bother to add changelog entries but rather provide
a nice git commit message that can then end up in the changelog.
It is recommended to build the package with pbuilder using:
gbp buildpackage --git-pbuilder
For information on how to set up a pbuilder environment see the
git-pbuilder(1) manpage. In short:
DIST=sid git-pbuilder create
gbp clone <project-url>
cd <project>
gbp buildpackage --git-pbuilder
-- Guido Günther <agx@sigxcpu.org>, Wed, 2 Dec 2015 18:51:15 +0100
gtherm (0.0.1) amber-phone; urgency=medium
* Initial release
-- Guido Günther <agx@sigxcpu.org> Wed, 16 Oct 2019 21:22:33 +0200
Source: gtherm
Section: x11
Priority: optional
Maintainer: Guido Günther <agx@sigxcpu.org>
Build-Depends:
debhelper-compat (= 12),
dh-sequence-gir,
gtk-doc-tools,
libgirepository1.0-dev,
libglib2.0-dev,
meson,
pkg-config,
valac,
Standards-Version: 4.4.0
Homepage: https://source.puri.sm/Librem5/gthd
Package: gthd
Architecture: any
Depends:
${misc:Depends},
${shlibs:Depends},
Description: DBus service to monitor thermal information
GThd is a DBus activated daemon that provides information
about thermal zones, cooling cells and trip points.
.
This package contains the daemon.
Package: libgtherm-0.0-0
Architecture: any
Section: libs
Depends:
${misc:Depends},
${shlibs:Depends},
libglib2.0-dev,
Description: DBus service to monitor thermal information - shared library
GThd is a DBus activated daemon that provides information
about thermal zones, cooling cells and trip points.
.
This package contains the shared libraries for applications interfacing with
Gthd.
Package: libgtherm-dev
Architecture: any
Section: libdevel
Depends:
${misc:Depends},
${shlibs:Depends},
gir1.2-gtherm-0.0 (= ${binary:Version}),
libgtherm-0.0-0 (= ${binary:Version}),
Description: DBus service to monitor thermal information - development files
GThd is a DBus activated daemon that provides information
about thermal zones, cooling cells and trip points.
.
This package contains development files and Vala bindings to use when writing
applications that interface with GThd.
Package: gir1.2-gtherm-0.0
Architecture: any
Section: introspection
Depends:
${gir:Depends},
${misc:Depends},
${shlibs:Depends},
Description: GObject introspection data for libgtherm
GThd is a DBus activated daemon that provides information
about thermal zones, cooling cells and trip points.
.
This package contains introspection data for the libgtherm library.
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: gtherm
Source: https://source.puri.sm/Librem5/gtherm
Files: *
Copyright: 2019 Purism SPC
License: GPL-3+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
Files: libgtherm/*
Copyright: 2019 Purism SPC
License: LGPL-2.1+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU Lesser General
Public License version 3 can be found in "/usr/share/common-licenses/LGPL-2.1".
[DEFAULT]
debian-branch = master
debian-tag = v%(version)s
debian-tag-msg = %(pkg)s v%(version)s
/usr/lib/*/girepository-1.0
/usr/bin
/usr/share/dbus-1/
[Unit]
Description=Gthd Service
Documentation=https://source.puri.sm/Librem5/gtherm
[Service]
Type=dbus
ExecStart=/usr/bin/gthd
Restart=on-failure
BusName=org.sigxcpu.Thermal
[Install]
WantedBy=default.target
/usr/lib/*/libgtherm-*.so.0
/usr/include
/usr/share/gir-1.0/
/usr/share/vala/
/usr/lib/*/libgtherm-*.so
/usr/lib/*/pkgconfig/libgtherm-*.pc
#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%:
dh $@ --builddirectory=_build
#!/usr/bin/make -f
CFLAGS=$(shell pkg-config --cflags libgtherm-0.0)
LIBS=$(shell pkg-config --libs libgtherm-0.0)
a.out: debian/tests/build-test.c
gcc $(CFLAGS) $< $(LIBS)
@echo "Build test of $< succeeded"
@rm -f a.out
#include <libgtherm.h>
int
main (int argc,
char **argv)
{
gth_manager_new_sync (NULL,
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START,
NULL,
NULL);
}
Tests: build-test
Depends:
build-essential,
libgtherm-dev,
pkg-config,
Restrictions: allow-stderr, superficial
Test-Command: dbus-run-session examples/example.py
Depends:
dbus,
gir1.2-gtherm-0.0,
python3,
python3-gi,
Restrictions: allow-stderr, superficial
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY % gtkdocentities SYSTEM "xml/gtkdocentities.ent">
%gtkdocentities;
]>
<refentry id="build-howto">
<refmeta>
<refentrytitle>Compiling with &package_string;</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>Compiling with &package_string;</refname><refpurpose>Notes on compiling</refpurpose>
</refnamediv>
<refsect2>
<title>Using pkg-config</title>
<para> Like other GNOME libraries,
<application>&package_string;</application> uses
<application>pkg-config</application> to provide compiler options. The
package name is
"<literal>&package_ver_str;</literal>". So in
your <literal>configure.ac</literal> script, you might specify something
like: </para>