我有一台装有最新版本 Linux Mint 的笔记本电脑。我设置了一个交换分区并且运行pm-hibernate
正常(启动时关闭并恢复)。但是,在电源管理设置中,“当电池电量严重不足时”休眠不是一个选项。
我查看了 Python 配置程序 ( /usr/share/cinnamon/cinnamon-settings/modules/cs_power.py
),似乎有一段代码可以检查是否可以休眠:
def get_available_options(up_client):
can_suspend = False
can_hibernate = False
can_hybrid_sleep = False
# Try logind first
try:
connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
proxy = Gio.DBusProxy.new_sync(
connection,
Gio.DBusProxyFlags.NONE,
None,
"org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
None)
can_suspend = proxy.CanSuspend() == "yes"
can_hibernate = proxy.CanHibernate() == "yes"
can_hybrid_sleep = proxy.CanHybridSleep() == "yes"
except:
pass
# Next try ConsoleKit
try:
connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
proxy = Gio.DBusProxy.new_sync(
connection,
Gio.DBusProxyFlags.NONE,
None,
"org.freedesktop.ConsoleKit",
"/org/freedesktop/ConsoleKit/Manager",
"org.freedesktop.ConsoleKit.Manager",
None)
can_suspend = can_suspend or (proxy.CanSuspend() == "yes")
can_hibernate = can_hibernate or (proxy.CanHybridSleep() == "yes")
can_hybrid_sleep = can_hybrid_sleep or (proxy.CanHybridSleep() == "yes")
except:
pass
def remove(options, item):
for option in options:
if option[0] == item:
options.remove(option)
break
lid_options = [
("suspend", _("Suspend")),
("shutdown", _("Shutdown immediately")),
("hibernate", _("Hibernate")),
("blank", _("Lock Screen")),
("nothing", _("Do nothing"))
]
button_power_options = [
("blank", _("Lock Screen")),
("suspend", _("Suspend")),
("shutdown", _("Shutdown immediately")),
("hibernate", _("Hibernate")),
("interactive", _("Ask")),
("nothing", _("Do nothing"))
]
critical_options = [
("shutdown", _("Shutdown immediately")),
("hibernate", _("Hibernate")),
("nothing", _("Do nothing"))
]
if not can_suspend:
for options in lid_options, button_power_options, critical_options:
remove(options, "suspend")
if not can_hibernate:
for options in lid_options, button_power_options, critical_options:
remove(options, "hibernate")
return lid_options, button_power_options, critical_options, can_suspend, can_hybrid_sleep
如果我在此代码之后设置can_hibernate
为True
,则会出现该选项,但它不起作用。电量不足时如何设置休眠?
我刚刚处理了在我的 Linux Mint 19.3 Cinnamon 设置上启用休眠功能。
A)我首先遵循这个tuto,https: //www.reddit.com/r/linuxmint/comments/93ta9u/enable_hibernation_in_linux_mint_19_tara/
它使休眠与
systemctl hibernate
命令一起工作。但是休眠按钮没有显示在关机窗口中,也没有显示在电源管理设置中的休眠选项(这是您似乎感兴趣的;))
B)然后我
/var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
按照本教程中的描述创建了文件,http ://linuxg.net/how-to-enable-hibernation-and-add-the-hibernate-button-to-the-shutdown-menu-on-ubuntu -14-04-trusty-tahr/。为了更清楚,我编辑了引用的某些部分。
希望这可以帮助。
您可能会发现我的小指南很有帮助!我一直在冬眠中挣扎一段时间。