当前位置: 首页>>技术教程>>正文


保存 Unity 桌面会话

,

问题描述

有没有办法在Unity中保存当前会话(应用程序+桌面窗口的组织)并在需要时加载它?

最佳办法

我做了一个解决方法,它是一个有助于配置会话的脚本。

下载它 here 。\n使其可执行并从终端 ./session.config 运行

可以查看脚本代码(https://www.dropbox.com/s/w1btmead93q6hze/session.config?dl=0),每部分都有解释。它将创建一个启动脚本,该脚本将移动到每个视口并打开指定的应用程序。

您也可以随时运行它,只需按 Alt + F2 并粘贴 ~/.sessionconf 即可。

删除

要删除我的脚本所做的任何更改,只需删除以下文件:

  • ~/session.config

  • ~/会话配置

  • ~/sessionconf.bak

  • ~/.config/autostart/sessionconf.desktop

或者在终端运行:

rm ~/session.config ; rm ~/sessionconf ; rm ~/sessionconf.bak ; rm ~/.config/autostart/sessionconf.desktop  

次佳办法

你可以这样做: killall gnome-session 。众所周知,输入命令 sudo gnome-session-save --logout 将注销系统。这将在 Unity 上保存当前会话。我试过这个。

或者您可以阅读有关 how to make a program auto-start everytime you log in 的信息。

或者您可以试试这个 gconf-editor 键:

/apps/gnome-session/options/auto_save_session = true

第三种办法

不 – 正如您所描述的,目前在 Ubuntu 11.04 及更高版本上是不可能的。

您可以阅读此错误报告,特别是评论 24

https://bugs.launchpad.net/ubuntu/+source/gnome-session/+bug/771896

还是这里有更完整的解释(太长了,无法在此处复制)?

https://lists.ubuntu.com/archives/ubuntu-desktop/2011-January/002734.html

第四种办法

This script 在 Xubuntu 上非常适合我。它或多或少是 desktop-agnostic,理论上也应该支持 Unity。来自 Arnon Weinberg 的原始博客文章:

\\n

GNOME session save and restore

\\n

This script is used to save and restore a desktop session.

\\n

Why this script?

\\n

Some desktop managers do offer some session management features.\\n Under GNOME it may be possible to run gnome-session-properties manually and turn on \\u201cAutomatically remember running applications when logging out\\u201d.\\n However, some GNOME implementations (notably Ubuntu\\u2019s) appear to be deemphasizing or deprecating this feature in favour of the Suspend or Hibernate feature.

\\n

Both the automated session save and suspend feature however are limited to saving/restoring sessions only on clean logout/login.

\\n

I use this script because sometimes I just need to reboot, and sometimes I like to restore my session to a previous state.

\\n

How to use:

\\n

Download the script, place it on your PATH, and be sure to give it executable permissions.

\\n

To save the current session:

\\n

session save\\n

\\n

To restore the saved session:

\\n

session restore\\n

\\n

在 Ubuntu 上安装

博文中提供的安装说明适用于 Fedora。在 Ubuntu 上,您必须安装以下依赖项:

sudo apt-get install perl wmctrl xdotool x11-utils

请务必查看 original blog post 的 ‘Details’ 部分,以了解有关不同会话恢复级别的更多信息。


更新:另一位用户报告说该脚本仅适用于第一行 #!/usr/bin/perl 而不是 #!/bin/perl

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/13613.html,未经允许,请勿转载。