Hibernate/suspend on critical battery level - where should I set it from MATE GUI?
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
- 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
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
callsacpi
to find out what the current battery level is. It will set the output of theacpi
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 to and and system automatically suspends on 20% battery level (the level is configurable, but my new battery seems to report low values wrongly).