All Projects → Mihaylov93 → BatMon

Mihaylov93 / BatMon

Licence: GPL-3.0 License
Battery monitoring widget for Clockwork Pi

Programming Languages

C++
36643 projects - #6 most used programming language
QMake
1090 projects
shell
77523 projects

Labels

Projects that are alternatives of or similar to BatMon

godot-launcher
Alternative launcher for single-board computers
Stars: ✭ 107 (+435%)
Mutual labels:  gameshell
caves
2D Cave Exploration Game with Procedurally Generated Levels
Stars: ✭ 29 (+45%)
Mutual labels:  gameshell
gameshell-setup
Enhance your Gameshell 💪
Stars: ✭ 56 (+180%)
Mutual labels:  gameshell
GSP
Central repository for GSPLauncher and GSPGames
Stars: ✭ 14 (-30%)
Mutual labels:  gameshell
godot-gameshell
Godot export templates and instructions for the GameShell portable game console and other single-board computers
Stars: ✭ 34 (+70%)
Mutual labels:  gameshell

Battery monitoring widget

Codacy Badge Build Status

freedoom

BatMon

A widget for Clockwork Pi that displays the battery percentage as a overlay on top of the current window. Clockwork Pi Gameshell has a battery widget on the UI but not while playing games. This is an attempt to solve this.

Features

Initially it read /sys/class/power_supply/axp20x-battery/uevent file and computed a percentage from the data extracted. Currently upower is used to get the percentage from /org/freedesktop/UPower/devices/battery_axp20x_battery

Although old way is still present as a fallback option, if the device doesn´t have upower or running it doesnt give a proper result, percentage display will be built from /sys/class/power_supply/axp20x-battery/uevent like below.

$ cat /sys/class/power_supply/axp20x-battery/uevent

      POWER_SUPPLY_NAME=axp20x-battery
      POWER_SUPPLY_PRESENT=1
      POWER_SUPPLY_ONLINE=1
      POWER_SUPPLY_STATUS=Charging
      POWER_SUPPLY_VOLTAGE_NOW=4186000
      POWER_SUPPLY_CURRENT_NOW=1000
      POWER_SUPPLY_CONSTANT_CHARGE_CURRENT=1200000
      POWER_SUPPLY_CONSTANT_CHARGE_CURRENT_MAX=1200000
      POWER_SUPPLY_HEALTH=Good
      POWER_SUPPLY_VOLTAGE_MAX_DESIGN=4200000
      POWER_SUPPLY_VOLTAGE_MIN_DESIGN=2900000
      POWER_SUPPLY_CAPACITY=100

It gets the percentage as follows:

(voltage_now-voltage_min)/(voltage_max-voltage_min)) * 100

Issues

  • twm does not appear to implement extended window manager hints (EWMH). Some flags like Qt::WA_X11NetWmWindowTypeDock might not work for that reason.

  • For the same reason, the hint Qt::WindowStaysOnTopHint also doesn´t work, widget doesn´t stay always on top (It does on other window manager), a new opened window re-paints on top of it and it gets hidden. A workaround to this is having a timer to hide the widget, update it and repaint it on top of the current active window.

Building and installation

This project was made with C++ and Qt5 in order to compile it from source you need to have Qt5 and QMake.

Building from source

qmake BatMon.pro
make

Downloading binary

You can get a precompiled package from releases.

It has Qt5 dependencies that should be preinstalled in the latest OS, if for some reason it doesn´t run because of a library missing you can check with readelf -f the required libraries.

$ readelf -d BatMon

Dynamic section at offset 0x5ed0 contains 34 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libQt5Widgets.so.5]
 0x00000001 (NEEDED)                     Shared library: [libQt5Gui.so.5]
 0x00000001 (NEEDED)                     Shared library: [libQt5Core.so.5]
 0x00000001 (NEEDED)                     Shared library: [libGLESv2.so.2]
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libstdc++.so.6]
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
sudo apt-get install libqtcore5 libqtgui5 

Installation

To add it to the launcher:

tar -zxvf BatMon-0.5.tar.gz -C /home/cpi/apps/Menu/
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].