TLP is a framework that controls lots of power management options for laptops and works for all laptops (except that Thinkpads require specific configuration). Without TLP, you may still be using some of your laptop's power management options: TLP is just a package that offers fairly comprehensive control over a wide range of laptop power management features all in one place and its default configuration is good for battery life.
Your tlp-stat output indicates that TLP is active, with this section
+++ System Status
TLP power save = enabled
power source = battery
And you can also see all the devices whose power consumption it is controlling.
As for why the battery current did not update between two runs, I don't know the answer. It is possible that the battery hardware in your laptop doesn't report this statistic correctly or averages it over a specific time period. This in itself is not an indication that TLP is not working; a proper test should involve giving the laptop a known workload and timing how long it is until the battery depletes. Of course this takes time.
Introduction
The script below is modified version of my previous scripts, written in python and using dbus exclusively for polling ac_adapter presence and setting the screen brightness.
Usage
Usage is simple: call from command line as
python ./brightness_control.py
The script defaults to 100% brightness on AC , 10% on battery. Users can use -a
and -b
to set their desired brightness levels on ac and battery respectively.
AS given by -h
option:
$ ./brightness_control.py -h
usage: brightness_control.py [-h] [-a ADAPTER] [-b BATTERY]
Simple brightness control for laptops,
depending on presense of AC power supply
optional arguments:
-h, --help show this help message and exit
-a ADAPTER, --adapter ADAPTER
brightness on ac
-b BATTERY, --battery BATTERY
brightness on battery
For example, one can do any of the following:
# set non default for brightness on ac
$ ./brightness_control.py -a 80
# set non-default value for brightness on battery
$ ./brightness_control.py -b 20
# set non-default values for both
$ ./brightness_control.py -a 80 -b 20
Source
Also available on GitHub
#!/usr/bin/env python
"""
Author: Serg Kolo <1047481448@qq.com>
Date: Nov 3rd , 2016
Purpose:Brightness control depending on
presence of ac adapter
Written for: http://askubuntu.com/q/844193/295286
"""
import argparse
import dbus
import time
import sys
def get_dbus_property(bus_type, obj, path, iface, prop):
""" utility:reads properties defined on specific dbus interface"""
if bus_type == "session":
bus = dbus.SessionBus()
if bus_type == "system":
bus = dbus.SystemBus()
proxy = bus.get_object(obj, path)
aux = 'org.freedesktop.DBus.Properties'
props_iface = dbus.Interface(proxy, aux)
props = props_iface.Get(iface, prop)
return props
def get_dbus_method(bus_type, obj, path, interface, method, arg):
""" utility: executes dbus method on specific interface"""
if bus_type == "session":
bus = dbus.SessionBus()
if bus_type == "system":
bus = dbus.SystemBus()
proxy = bus.get_object(obj, path)
method = proxy.get_dbus_method(method, interface)
if arg:
return method(arg)
else:
return method()
def on_ac_power():
adapter = get_adapter_path()
call = ['system','org.freedesktop.UPower',adapter,
'org.freedesktop.UPower.Device','Online'
]
if get_dbus_property(*call): return True
def get_adapter_path():
""" Finds dbus path of the ac adapter device """
call = ['system', 'org.freedesktop.UPower',
'/org/freedesktop/UPower','org.freedesktop.UPower',
'EnumerateDevices',None
]
devices = get_dbus_method(*call)
for dev in devices:
call = ['system','org.freedesktop.UPower',dev,
'org.freedesktop.UPower.Device','Type'
]
if get_dbus_property(*call) == 1:
return dev
def set_brightness(*args):
call = ['session','org.gnome.SettingsDaemon.Power', '/org/gnome/SettingsDaemon/Power',
'org.gnome.SettingsDaemon.Power.Screen', 'SetPercentage', args[-1]
]
get_dbus_method(*call)
def parse_args():
info = """
Simple brightness control for laptops,
depending on presense of AC power supply
"""
arg_parser = argparse.ArgumentParser(
description=info,
formatter_class=argparse.RawTextHelpFormatter)
arg_parser.add_argument(
'-a','--adapter',action='store',
type=int, help='brightness on ac',
default=100,
required=False)
arg_parser.add_argument(
'-b','--battery',action='store',
type=int, help='brightness on battery',
default=10,
required=False)
return arg_parser.parse_args()
def main():
args = parse_args()
while True:
if on_ac_power():
set_brightness(args.adapter)
while on_ac_power():
time.sleep(1)
else:
set_brightness(args.battery)
while not on_ac_power():
time.sleep(1)
if __name__ == "__main__": main()
Best Answer
You may use a GNOME shell extension called Dim On Battery Power.
It lets you set two separate brightness levels, one for AC, another for battery.