3

I have bought new battery for my laptop. It is running Ubuntu MATE 16.04.5 LTS.

This new battery have normal capacity, charging and provides long life :)

But I have small problem: when battery level goes under some level - the laptop shutdowns immediately. I remember, that it normally went to the suspend with old battery.

With new battery I can suspend manually and all suspend-related tests (such as pm-is-supported --suspend, pm-is-supported --hibernate, pm-is-supported --suspend-hybrid) returns 0, so these actions are supported.

For more predictive results I have reseted all settings with

gsettings reset-recursively org.mate.power-manager

So my GSettings reports the following:

$ gsettings list-recursively | egrep "critical|action|low|time" | grep -i power | sort -u
org.mate.power-manager action-critical-battery 'hibernate'
org.mate.power-manager action-critical-ups 'shutdown'
org.mate.power-manager action-low-ups 'hibernate'
org.mate.power-manager action-sleep-type-ac 'suspend'
org.mate.power-manager action-sleep-type-battery 'hibernate'
org.mate.power-manager idle-dim-time 10
org.mate.power-manager info-history-time 21600
org.mate.power-manager notify-low-capacity true
org.mate.power-manager notify-low-power true
org.mate.power-manager percentage-action 2
org.mate.power-manager percentage-critical 3
org.mate.power-manager percentage-low 10
org.mate.power-manager show-actions true
org.mate.power-manager time-action 120
org.mate.power-manager time-critical 300
org.mate.power-manager time-low 1200
org.mate.power-manager use-time-for-policy true

In /etc/UPower/UPower.conf I have default values:

$ cat /etc/UPower/UPower.conf | grep -v ^# | egrep "Critical|Low|Action|Time"
PercentageLow=10
PercentageCritical=3
PercentageAction=2
TimeLow=1200
TimeCritical=300
TimeAction=120
CriticalPowerAction=HybridSleep

The MATE Power Management Preferences (mate-power-preferences) does not have GUI element to set critical battery level:

mate-power-preferences

Where should I set critical battery level for hibernate or suspend from MATE GUI?
Will changing value via GSettings or Dconf change value in UPower.conf?
Where else should I set the action on critical battery level?


Updates:
1. Laptop model is Asustek UX32A.
Output of cat /sys/class/power_supply/BAT0/uevent:

POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=481
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=7400000
POWER_SUPPLY_VOLTAGE_NOW=7400000
POWER_SUPPLY_POWER_NOW=11151000
POWER_SUPPLY_ENERGY_FULL_DESIGN=48248000
POWER_SUPPLY_ENERGY_FULL=50038000
POWER_SUPPLY_ENERGY_NOW=46346000
POWER_SUPPLY_CAPACITY=92
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=UX32-65
POWER_SUPPLY_MANUFACTURER=ASUSTeK
POWER_SUPPLY_SERIAL_NUMBER= 

and output of upower --dump:

Device: /org/freedesktop/UPower/devices/line_power_AC0
  native-path:          AC0
  power supply:         yes
  updated:              Sun Nov  4 12:43:52 2018 (233 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              no
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               ASUSTeK
  model:                UX32-65
  power supply:         yes
  updated:              Sun Nov  4 12:45:52 2018 (113 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    energy:              46.509 Wh
    energy-empty:        0 Wh
    energy-full:         46.916 Wh
    energy-full-design:  48.248 Wh
    energy-rate:         11.514 W
    voltage:             7.4 V
    time to empty:       4.0 hours
    percentage:          92%
    capacity:            81.4562%
    technology:          lithium-ion
    icon-name:          'battery-full-symbolic'
  History (charge):
    1541324752  92.000  discharging
  History (rate):
    1541324752  11.514  discharging

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         yes
  updated:              Sun Nov  4 12:45:52 2018 (113 seconds ago)
  has history:          no
  has statistics:       no
  battery
    present:             yes
    state:               discharging
    warning-level:       none
    energy:              46.509 Wh
    energy-full:         46.916 Wh
    energy-rate:         11.514 W
    time to empty:       4.0 hours
    percentage:          92%
    icon-name:          'battery-full-symbolic'

Daemon:
  daemon-version:  0.99.4
  on-battery:      yes
  lid-is-closed:   no
  lid-is-present:  yes
  critical-action: HybridSleep

2. TLP is not installed on my system.
3. I have reseted all settings with no luck. Todat I asked question on Ubuntu-MATE.community.

  • What make and model of laptop? Does /sys/class/power_supply/BAT1/* report correct readings for battery? – WinEunuuchs2Unix Nov 4 '18 at 1:22
  • @WinEunuuchs2Unix updated. My main question - where can I adjust critical level? Am I missed some other settings location? – N0rbert Nov 4 '18 at 9:53
  • Critical Battery is normally about 3%. There should be warnings popping up around 5 to 10% I think. Are you using tlp or any other third-party power management tools? – WinEunuuchs2Unix Nov 4 '18 at 13:06
  • Tlp is not installed on my system. Currently MATE shows warning about critical battery level then starting shutdown procedure instead of Suspend. – N0rbert Nov 4 '18 at 13:15
2

GUI method

From: Change Critical Battery Level and Action in Linux Mint 18 Cinnamon you can install dconf-editor using:

$ sudo apt-get install dconf-editor

Then go to org -> cinnamon -> settings-daemon -> plugins -> power

mate gsettings power.png

  • Default settings are (in %):
  • Critical battery action: hibernate
  • Critical: 2
  • Action: 2
  • Low: 10

Exercise caution and tweak to your heart’s content 🙂


Original Answer and edits below

Review your current settings with:

$ gsettings list-recursively | grep critical
org.gnome.settings-daemon.plugins.power critical-battery-action 'shutdown'
org.gnome.settings-daemon.plugins.power percentage-critical 3
org.gnome.settings-daemon.plugins.power time-critical 300

Change your critical-battery-action

$ gsettings set org.gnome.settings-daemon.plugins.power critical-battery-action 'suspend'

Linux Mate differences

When using Linux Mate you need to substitute org.gnome with org.mate and possibly change your keys. From ArchWiki:

Battery discharge

To disable the notification on battery discharge, run:

$ gsettings set org.mate.power-manager.notify-discharging false

However in Ubuntu there is no equivalent.

Find all Mate power settings

To find all Mate power settings use:

$ gsettings list-recursively | grep power-manager

In Ubuntu you would use:

$ gsettings list-recursively | grep plugins.power
|improve this answer|||||
  • I'm using MATE, dear @WinEunuuchs2Unix. So /usr/bin/gnome-settings-daemon is not running on my system. – N0rbert Nov 4 '18 at 14:12
  • Yikes I though all roads led to gnome :( From: mate-desktop.org it says: "The MATE Desktop Environment is the continuation of GNOME 2. It provides an intuitive and attractive desktop environment using traditional metaphors for Linux and other Unix-like operating systems." – WinEunuuchs2Unix Nov 4 '18 at 14:36
  • I've updated answer by reading Archwiki which gave me enough hints without installing Mate (a last resort). Let me know if it helps. – WinEunuuchs2Unix Nov 4 '18 at 14:50
  • OK I found the GUI method which SHOULD work for you now :) – WinEunuuchs2Unix Nov 4 '18 at 14:57
  • 2
    Replace author's cinnamon reference with mate inside dconf-editor. Using the GUI editor you should be able to easily navigate among all possible settings a lot quicker than using gsettings. – WinEunuuchs2Unix Nov 4 '18 at 15:26
1

I still can't find GUI solution for my problem. So I switched to semi-GUI solution.

I fixed this issue by using other battery level indicator - it is named fdpowermon:

Description-en: simple battery power monitor for laptops with ACPI

fdpowermon is a simple perl script that installs an icon in a system tray compatible with the freedesktop.org specification.
Every three seconds, fdpowermon calls acpi to find out what the current battery level is. It will set the output of the acpi command as a tooltip text, and will update the used icon as appropriate.
In addition, fdpowermon can optionally call perl subroutines when the power reaches a given level. No such subroutines are provided or enabled by default, however.

So I have installed it

sudo apt-get install fdpowermon

and created configuration folder for this application with:

mkdir -p ~/.config/fdpowermon/

and placed here two files:

1. file with my modified theme (in discharging array note the 3rd element 20:battery-low.png, it will be used to suspend in Perl script):

cat << \EOF > ~/.config/fdpowermon/theme.cfg 
[mytheme]
steps = 8
dir = /usr/share/icons/oxygen/22x22/status
# The below line makes fdpowermon not show an icon when the power is
# connected and the battery is completely full. This is by design,
# because that's how the author likes to use the software, and he is of
# the opinion that it's easier to ship software configured just the way
# he likes it rather than to have to reconfigure things.
#
# Requests are often made to change this default. This will not happen,
# but it's an easy change: just change the last entry in this "charging"
# configuration so that it says "100:battery-charging.png" rather than
# "99:battery-charging.png", and you're done!
charging = 0:battery-charging-low.png, 10:battery-charging-low.png, 20:battery-charging-caution.png, 30:battery-charging-caution.png, 50:battery-charging-040.png, 70:battery-charging-060.png, 90:battery-charging-080.png,100:battery-charging.png
discharging = 2:battery-missing.png:battery-low.png,10:battery-low.png, 20:battery-low.png,30:battery-caution.png,50:battery-040.png,70:battery-060.png,90:battery-080.png,100:battery-100.png
EOF

2. Perl script file with dbus suspend action:

cat << \EOF > ~/.config/fdpowermon/theme.pl
# Copy this file to ~/.config/fdpowermon/theme.pl.
#
# If you don't like the 'default' theme, define a new one by copying
# /etc/fdpowermon/theme.cfg to ~/.config/fdpowermon/theme.cfg and
# renaming/adjusting the 'default' theme there to something new.
# Don't forget to replace "default" below with your new theme name.
#
# See the manpage fdpowermon(1) for full details on what you can do
# here.

# define a suspend action
sub suspend {
    system("dbus-send --print-reply --system --dest=org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.Suspend boolean:true");
}

# initialize our theme, from /etc/fdpowermon/theme.cfg or
# ~/.config/fdpowermon/theme.cfg
my $theme = fdpowermon::theme::get_theme("mytheme");

# on the discharge event for the lowest element in the list of steps (0 = first
# in the index, "d" for discharge), call the "suspend" sub defined above
$theme->set_event( 2, \&suspend, 'd' );
EOF

(the DBus suspend command came from this great answer).

And finally I have disabled MATE Power Manager battery indicator with

gsettings set org.mate.power-manager icon-policy 'never'

and created auto-start desktop file to have fdpowermon shown in the tray instead:

mkdir -p ~/.config/autostart

cat << EOF > ~/.config/autostart/fdpowermon.desktop 
[Desktop Entry]
Type=Application
Exec=fdpowermon
Hidden=false
X-MATE-Autostart-enabled=true
Name[en_US]=fdpowermon
Name=fdpowermon
Comment[en_US]=
Comment=
EOF

As the result I have nice-looking battery icon in the tray from battery-charging to battery-caution and battery-low and system automatically suspends on 20% battery level (the level is configurable, but my new battery seems to report low values wrongly).

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.