![启动 Ubuntu 系统后恢复应用程序以前的状态](https://linux22.com/image/1162943/%E5%90%AF%E5%8A%A8%20Ubuntu%20%E7%B3%BB%E7%BB%9F%E5%90%8E%E6%81%A2%E5%A4%8D%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E4%BB%A5%E5%89%8D%E7%9A%84%E7%8A%B6%E6%80%81.png)
以前,我习惯sudo shutdown -h now
关闭 macOS。然后开机时,系统会将所有应用程序(如 Chrome、VS Code、PDF)恢复到关机前的状态。
现在,我使用相同的命令sudo shutdown -h now
关闭 Ubuntu。但是,开机后,系统会启动一个全新的状态,而不会将应用程序恢复到关机前的状态。
macOS 使用了哪些功能?我也可以在 Ubuntu 上使用它吗?
答案1
这被称为“会话管理”
我可以在 ubuntu 上使用吗?
不在默认桌面上
但您可以使用Linux 窗口会话管理器或者Gnome 窗口会话管理器扩展适用于 gnome。您将在 Gnome Shell 顶部栏上看到一个指示器,您可以在其中保存和恢复会话。从第二个链接安装(第一个链接具有类似的设置):
设置
确保您已经安装了 nodejs(例如执行 node -v,如果没有输出则安装它)。
通过 npm 安装 lwsm:(
npm install -g linux-window-session-manager
在某些系统上您可能需要使用 sudo)下载或克隆存储库并将所有文件移动到
/home/your-user-name/.local/share/gnome-shell/extensions/[email protected]
在某些情况下 - 尤其是当您使用 nvm 时,您可能需要通过 扩展配置 lwsm 安装路径(成功安装后您可以通过哪个 lwsm 找到)
gnome-shell-extension-prefs
。
设置完成后的安装:
cd tmp
git clone [email protected]:johannesjo/gnome-shell-extension-window-session-manager.git
mv gnome-shell-extension-window-session-manager ~/.local/share/gnome-shell/extensions/[email protected]
答案2
这不是关机,无论如何请看一下以下命令:
pm-action - 暂停或休眠您的计算机
pm-hibernate [--help]
pm-suspend [--quirk-*] [--help]
pm-suspend-hybrid [--quirk-*] [--help]
来自手册页:
These commands can be used to put the machine in a sleep state. The precise way how this
is done can be influenced by installing executables and configuration snippets. For some
options external programs are needed.
These commands will usually be called by UPower or hald when triggered to do so by a
program in a desktop session such as gnome-power-manager. Calling them from the command
line is also possible, but it is not guaranteed that all programs in your desktop session
keep working as expected.
pm-suspend
During suspend most devices are shutdown, and system state is saved in RAM. The system
still requires power in this state. Most modern systems require 3 to 5 seconds to
enter and leave suspend, and most laptops can stay in suspend mode for 1 to 3 days
before exhausting their battery.
pm-hibernate
During hibernate the system is fully powered off, and system state is saved to disk.
The system does not require power, and can stay in hibernate mode indefinitely. Most
modern systems require 15 to 45 seconds to enter and leave hibernate, and entering and
leaving hibernate takes longer when you have more memory.
pm-suspend-hybrid
Hybrid-suspend is the process where the system does everything it needs to hibernate,
but suspends instead of shutting down. This means that your computer can wake up
quicker than for normal hibernation if you do not run out of power, and you can resume
even if you run out of power. s2both(8) is an hybrid-suspend implementation.