My Viral Box Logo
Ad image
  • Funny Stories
  • Weird Stories
  • Scary Stories
  • Ghost Stories
  • Funny Riddles
  • Short Jokes
Reading: Laptop Battery Monitor on Ubuntu / Geektimes
Share
MYVIRALBOX MYVIRALBOX
Font ResizerAa
  • Funny Stories
  • Weird Stories
  • Funny Riddles
  • Ghost Stories
  • Scary Stories
Search
  • Funny Stories
  • Weird Stories
  • Scary Stories
  • Ghost Stories
  • Funny Riddles
  • Short Jokes
Have an existing account? Sign In
Follow US
© Foxiz News Network. Ruby Design Company. All Rights Reserved.
MYVIRALBOX > Funny Stories > Laptop Battery Monitor on Ubuntu / Geektimes
Funny StoriesWeird Stories

Laptop Battery Monitor on Ubuntu / Geektimes

MyViralBox Staff
Last updated: April 25, 2024 3:36 pm
MyViralBox Staff
Published: April 11, 2017
Share
5 Min Read
SHARE

Laptop

It has long seemed strange to me that modern operating systems do not distinguish desktop PC from laptop. But the laptop is a mobile device and its batteries are not always enough for a full working day. Of course, there are basic functions like showing the remaining battery charge in percent and calculating the remaining time until the full discharge. But it is not clear how it is calculated and whether it can be trusted. In general, I decided to write my battery monitor for Ubuntu.

As an inspiration source, I took the battery monitor on Android:

  • icon with battery level in the tray, number next (charge level in percent)
  • click on the icon to pop up a menu with a simplified schedule of two parts: the last few hours of operation of the device and the expected discharge time

Later it turned out that embedding the picture in the drop-down menu is an impossible task for me. Therefore, I decided to display the graph in a separate window instead of the drop-down menu.

The program consists of the following parts:

  • Receiving data about the battery charge and recording them in the logs
  • Extracting data from logs
  • Grouping of data on continuous work sessions
  • Conversion of absolute time into relative device operation time
  • Smoothing discrete data within a session
  • Calculation of time to full charge / discharge
  • Image generation
  • GUI: tray icon, drop-down menu, battery status graph, color theme

I wanted to write the program with a minimum of external dependencies. Currently, only Python GI is used for the graphical interface (tray indicator, window).

The data is retrieved by reading the corresponding files from the directory / sys / class / power_supply / BAT0 / . Here you can find everything that relates to the power supply of the device: the current values ​​of voltage and current, the remaining charge in percent, etc.

Logs are recorded every time the charge level changes, but at least every 3-5 minutes. Records at intervals more than this will be determined as periods of laptop disconnection and will not be shown on the graph. To take into account these interruptions, we need to convert the absolute time into a virtual device operating time.

Another feature of the input data is that they are discrete. The battery charge level is displayed in percentages and stored as a natural number. Therefore, steps that are 1% high are inevitable on the graph.

I tried to do the smoothing of the graphs in different ways. I started with a simple moving average filter, but it does not work. Introduces an undesirable delay.

Then I tried the Gaussian filter, but it does not fit what greatly distorts the values ​​at the beginning and at the end of the data set, which is important for the correct display of periods of constant work Laptop. Otherwise, the beginning and end of the glued sessions get an artificial gap.

As a result, I invented the bike and made a filter based on the evaluation of the derivative and the change in the sampling frequency (first a decrease, then an increase). A controversial moment. I think the fans of digital signal processing throw me stones, in general, I’m open to discussion.

Time Calculation Up to a full charge / discharge is realized through linear extrapolation along the tangent. The most simple solution to get started.

Since I did not want to add external dependencies, I wrote my own SVG image generator.

Automatic color theme detection It did not work, so just added the switch to the drop-down menu.

This is, in general, everything.

→ Link to GitHub

MyViralBox Staff
MyViralBox Staff

You Might Also Like

A Definitive Timeline of Shawn Mendes and Charlie Puth’s Bromance
Women play the violin during brain surgery
13 Television Characters Who Desperately Need a Jackpot
Chicago’s Famous ‘Rat Hole’ Sidewalk Imprint Vanishes
You’ll Never Guess How Mom-of-two Transforms Ugly House
Leave a Comment Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search Posts

‎‎‎‎‎Explore Our Categories

  • Funny Riddles9
  • Funny Stories524
  • Ghost Stories3
  • Scary Stories20
  • Short Jokes1
  • Weird Stories479
Ad image

Latest added

weird football rivalries
Weird Stories

Weird Football Rivalries: Strange Stories Behind the Game’s Fiercest Feuds

May 14, 2025
most dangerous football derbies
Scary Stories

7 Most Dangerous Football Derbies Worldwide: Intense Rivalries and Risks

May 13, 2025
wonderful Scottish football
Weird Stories

9 weird and wonderful Scottish football moments

May 12, 2025
Weirdest Players in Arsenal FC History
Weird Stories

14 Weirdest Players in Arsenal FC History: Strange Stories and Quirky Characters

May 11, 2025
weird football formations
Weird Stories

7 Weird Football Formations That Actually Worked

May 11, 2025
weird business ideas
Weird Stories

15 Weird Business Ideas That Actually Work

May 3, 2025

Explore More

  • Privacy Policy
  • Submit Your Silly Stories

Follow US on Social Media

Facebook Instagram Pinterest Envelope-open

My Viral Box Logo

About My Viral Box

MyViralBox brings together all the weird, wacky, scary and funny news from around the web in one place to brighten your day. You might scratch your head; you might laugh out loud; you might glance over your shoulder; but you’re gonna have fun whenever you drop by. Funny news, weird news, chill-inducing spookiness, jokes and riddles of all kinds, plus whatever else we come across that we think just has to go viral; you’ll find it all right here!

© My Viral Box. All Rights Reserved.

Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?