GithubHelp home page GithubHelp logo

isabella232 / gnome-battery-bench Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gnome/gnome-battery-bench

0.0 0.0 0.0 255 KB

Read-only mirror of https://gitlab.gnome.org/GNOME/gnome-battery-bench

Home Page: https://gitlab.gnome.org/GNOME/gnome-battery-bench

License: GNU General Public License v2.0

Shell 0.37% C 92.12% Makefile 1.17% M4 1.04% Python 5.30%

gnome-battery-bench's Introduction

About
=====
This application is designed for measuring power usage. It does it by
recording the reported battery statistics as it replays recorded event
histories, and then using that to estimate power consumption and total
battery lifetime.

Usage
=====
The basic operation of gnome-battery-bench is:

 1) Select the test and test options such as duration
 2) Make sure the laptop is running on battery
 3) Hit the Start button
 4) Wait for the test to end

To end early you can use a global Control-Alt-Q global shortcut or
hit the Stop button. It may take a while for the test to end after
being stopped since gnome-battery-bench plays the "epilogue" event
history to try and clean up from the test.

The most relevant displayed statistics are:

 Average power: average power during the test
 Estimated battery life: how long the battery would last from full
   at that power rate.

Each test run is saved on disk in  ~/.local/share/gnome-battery-bench/logs,
and older tests can be viewed by switching to the Logs view using the
control in the title bar.

You will want to stop as many extraneous programs as possible when
running the tests. (Unless you are trying to test how much power those
programs take!) Browsers in particular will add a lot of noise.

gnome-battery-bench tries to disable the keyboard backlight when
running tests - if this doesn't work, you should disable the keyboard
backlight in BIOS settings to get consistent results - the keyboard
backlight can take a quite surprising amount of power.

Adding new tests
================
A test consists of a number of files, which can either be installed
systemwide in /usr/share/gnome-battery-bench/tests or per-user in
~/.config/gnome-battery-bench:

 <test-id>.batterytest
 <test-id>.prologue    # optional
 <test-id>.loop
 <test-id>.epilogue    # optional

The .batterytest file contains meta-information about the test such
as the name of the test. The other files are event log files that are
replayed during the test:

 1) prologue filed is played
 2) power logging is started
 3) the loop file is played repeatedly until the test time is finished
    or the user ends the test.
 4) power logging is terminated
 5) epilogue file is played

To record a event log file you can use the gbb command line tool supplied
with gnome-battery-bench:

 gbb --record > mytest.loop

Recording is terminated with Super-Q. You currently will have to edit the
to remove parts of the Super-Q shortcut at the end. (A bug.)

Installation
============
Because of the root-level helper daemon it uses, gnome-battery-bench needs
to be installed system-wide. This is done as:

 ./autogen.sh --prefix=/usr --sysconfdir=/etc [--libdir=/usr/lib64]
 # The libdir setting is only correct on some distros such as Fedora.)
 make
 sudo make install

The configure script will complain about missing libraries - which are
too numerous to be listed here, but should be available on any system
with GNOME 3.14 or newer installed.

Security
========
A helper daemon that runs with root privileges is used to simulate an
attached keyboard and mouse and replay events at a low level. Since
arbitrary events can be replayed, this could in theory be used to
attack another user's account on a multi-user system.

To eliminate any security risk, Polkit is configured by default so that
an admin password has to be entered when starting gnome-battery-bench.

To allow gnome-battery-bench to be run by admin users without entering
a password, you can create a file /etc/polkit-1/rules.d/10-gnome-battery-bench-local.rules
with contents:

---
polkit.addRule(function(action, subject) {
    if (action.id == "org.gnome.BatteryBench.Helper.SimulateEvents" &&
         subject.isInGroup("wheel")) {
             return polkit.Result.YES;
    }
});
---

It probably would be possible to enhance the helper daemon sufficiently
so that events can only be played back to the originating session of playback
requests, but this would require quite detailed understanding of the mechanisms
for binding input devices to seats and tracking active sessions per each seat.



gnome-battery-bench's People

Contributors

gicmo avatar owtaylor avatar rworkman avatar mar-v-in avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.