我有一台带有最新版本Linux的笔记本电脑。我设置了一个交换分区,并正常运行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,则会出现该选项,但它不起作用。当电池电量不足时,我如何将其设置为hibernate?
发布于 2020-05-21 16:35:26
我刚刚处理了在LinuxMint19.3肉桂设置上启用休眠的问题。
( A)我第一次学习这门课,https://www.reddit.com/r/linuxmint/comments/93ta9u/enable_冬眠_在……里面_linux_薄荷_19_塔拉/
注意:请确保您有足够大的交换分区。1.)在"/etc/polkit-1/localauthority/50-local.d“中创建名为"com.ubuntu.enable-hibernate.pkla”的文件:
sudo touch /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla2)。用您最喜欢的编辑器打开这个文件(在根特权下),并将这些行粘贴到其中并保存它:默认情况下重新启用hibernate Identity=unix-user:* Action=org.freedesktop.upower.hibernate ResultActive=yes 默认情况下,在logind中重新启用hibernate. Identity=unix-user:* Action=org.freedesktop.login1.hibernate ResultActive=yes 3。在文件"/etc/default/grub“中编辑这一行,这样看起来如下所示:GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=swap_partition_uuid"swap_partition_uuid-您可以在文件"/etc/fstab”中找到这个UUID,所以用交换分区4的实际uuid替换该字符串。通过执行以下命令更新grub配置:sudo update-grub
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/所述。
为了更清晰起见,我编辑了引文的一些部分。
1.)在"/var/lib/polkit-1/localauthority/50-local.d“中创建名为"com.ubuntu.enable-hibernate.pkla”的文件:
sudo touch /var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla2)。用您最喜欢的编辑器打开这个文件(在root特权下),并将这些行粘贴到其中并保存它:默认情况下,在upower中重新启用hibernate Identity=unix-user:* Action=org.freedesktop.upower.hibernate ResultActive=yes 默认情况下,在logind中重新启用hibernate. Identity=unix-user:* Action=org.freedesktop.login1.hibernate ResultActive=yes
希望这能有所帮助。
发布于 2020-08-01 18:48:47
你可能会发现我的小向导很有用!我在冬眠中挣扎了一段时间。
https://unix.stackexchange.com/questions/568093
复制相似问题