Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2678  / 2 Years ago, wed, may 11, 2022, 7:16:50

I use Ubuntu 12.04 in my laptop. I'm trying to configure to hibernate when lid is closed. However, not is working.
I did the following steps to solve the problem:




  • I enable in /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

  • System Settings - Power

  • I used the dconf Editor.



When I lid closed instead hibernate is suspend. I try run sudo pm-hibernate and works fine.



Any suggestion ?


More From » 12.04

 Answers
7

Note: try pm-hibernate in a shell before trying this. If it works, go ahead.



I fixed it by...




  • Using cinnamon-settings / Power to set the event to Hibernate. This sets the dconf values /org/gnome/settings-daemon/plugins/power/lid-close-ac-action and /org/gnome/settings-daemon/plugins/power/lid-close-battery-action to what you want


  • Editing /etc/acpi/events/lm_lid (gksudo gedit /etc/acpi/events/lm_lid) and filling it with





event=button/lid.*
action=/etc/acpi/lid.sh




  • Editing /etc/acpi/lid.sh (gksudo gedit /etc/acpi/lid.sh). If it's empty, fill it with




grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ]
then
su - gabriel -c 'gsettings get org.cinnamon.settings-daemon.plugins.power lid-close-ac-action' | grep hibernate
if [ $? = 0 ]
then
pm-hibernate
fi
fi



Otherwise, look for the right place to put the code above



Replace gabriel by your username. You have to do the su thing before calling gsettings get because this script is ran as root, and running gsettings get as root would return the preferences for root instead of your user.



You could just call pm-hibernate but then changing options in cinnamon-settings would not work anymore. I did not care to check whether my notebook is on AC or battery, because it's irrelevant: I want the same behaviour always anyway. Maybe someone wants to add an if there?


[#31336] Thursday, May 12, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
algicuade

Total Points: 317
Total Questions: 89
Total Answers: 106

Location: Saint Pierre and Miquelon
Member since Fri, Jan 28, 2022
2 Years ago
;