Skip to content

Simple Python script to display the current power consumption in the status bat within Ubuntu/Unity.

License

Notifications You must be signed in to change notification settings

metalevel-tech/powerNow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Power Now - Power Consumption Indicator

The script display the current power consumption of your laptop. The initial attention was to be just Power Consumption Indicator. But now it has menu which call few tool within gnome-terminal window. Thats are htop, powertop, tlp stat. If any of the tools is not installed on the system, the script will ask you to install it.

Examples of usages 1.

The script works with Ubuntu 16.04 and probably the only system specific thing is the file where the value of the current power consumption is stored. In my case I found it by the help of tlp:

$ sudo tlp stat | grep -P '\[m(W|A)\]'       # Output on Lenovo ThinkPad X230 Laptop-Tablet
/sys/class/power_supply/BAT0/power_now                      =  11246 [mW]

$ sudo tlp stat | grep -P '\[m(W|A)\]'       # Output on Dell Vostro 3350 Laptop
/sys/class/power_supply/BAT0/power_now                      =  6700 [mA]

Note some devices provide the current power consumption in watts, but some devices provide the current values of the voltage and the current (amps) and - we must calculate the current power. The script covers these cases.

Installation

  • Copy the script to /usr/local/bin to make it accessible as shell command system wide:

    sudo wget https://raw.githubusercontent.com/metalevel-tech/powerNow/master/powerNow.py -O /usr/local/bin/powerNow
    sudo chmod +x /usr/local/bin/powerNow
  • Copy the script to ~/bin to make it accessible only for the current user:

    wget https://raw.githubusercontent.com/metalevel-tech/powerNow/master/powerNow.py -O $HOME/bin/powerNow
    chmod +x $HOME/bin/powerNow
  • Copy the desktop file to ~/Desktop (the script is required):

    wget https://raw.githubusercontent.com/metalevel-tech/powerNow/master/powerNow.desktop -O $HOME/Desktop/powerNow.desktop
    chmod +x $HOME/Desktop/powerNow.desktop
  • Copy the desktop file to ~/.config/autostart (the script is required):

    wget https://raw.githubusercontent.com/metalevel-tech/powerNow/master/powerNow.desktop -O $HOME/.config/autostart/powerNow.desktop
    chmod +x $HOME/.config/autostart/powerNow.desktop

Installation update 2022

Right now I'm using Kali Linux 2022 on my ThinkPad. To get the tool operational, I was needed to download and manually install the .deb package gir1.2-appindicator3-0.1_0.4.92-7_amd64.deb

cd ~/Downloads
wget http://ftp.de.debian.org/debian/pool/main/liba/libappindicator/gir1.2-appindicator3-0.1_0.4.92-7_amd64.deb
sudo apt install ./gir1.2-appindicator3-0.1_0.4.92-7_amd64.deb

Some things used in the script are deprecated, but it still works, so I will fix them in the future. Also the icons used in the desktop launcher and in the indicator itself are not available in Kali.

Usage

Examples of usages 2.

Tests

The application is tested on:

  • Lenovo ThinkPad X230 Laptop-Tablet with Ubuntu 16.04

  • Dell Vostro 3350 Laptop with Ubuntu 16.04

References

Note: This is my very first Python attempt so I've used couple of references:

In Addition

I can call this simple tool also my laptop power management bundle, so here are few specifics according the usage of tlp and powertop on my Lenovo Lenovo ThinkPad X230 Laptop-Tablet:

  • Installation and basic usage of tlp:

    • Install the package: sudo apt update && sudo apt install tlp.

    • If you are using tp-smapi the better way to install the package is:

      sudo add-apt-repository ppa:linrunner/tlp
      sudo apt-get update
      sudo apt-get install tlp tlp-rdw
      sudo apt-get install tp-smapi-dkms acpi-call-dkms
  • There are two services that will be installed tlp.service and tlp-sleep.service.

  • Use sudo tlp stat to check the current settings.

  • Use nano /etc/default/tlp to tweak the configuration.

  • Use sudo tlp start to apply the configuration.

The tool powertop is not just a monitoring tool it has also a calibrating option: powertop -c, and manual handling of the power management for the peripheral devices.

See also:

About

Simple Python script to display the current power consumption in the status bat within Ubuntu/Unity.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages