Deepin休眠,


系统休眠,可以让平时的工作环境保存到硬盘中,以便开机后便可立即进入工作状态.

提醒:
分有swap分区的,先验证休眠功能是否正常
终端输入:
systemctl hibernate
能正常休眠,并开机后正常,在按本教程操作!

准备的东西
1. 系统分有swap空间
2. 需要创建desktop文件的需要自己找一个图标
3. 需要添加验证权限,以免误点击后,系统立刻休眠,无法阻止.

开始创建

1. 在/usr/bin目录下创建执行文件-记得修改为可执行权限
创建Hiber.sh文件(名字随意,不要和别的重名,需要是shell脚本)
内容为下:

#!/bin/bash
if pkexec /bin/bash;then
systemctl hibernate
fi

功能解析:
systemctl hibernate是系统休眠命令
利用系统bash提权的功能,在添加上if判断命令是否执行

2. 在/usr/share/polkit-1/actions目录下创建提权配置文件
创建com.deepin.hiber.policy文件(名字随意,不要重名,最好统一风格)
内容为下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
  <vendor>Deepin</vendor>
  <action id="com.deepin.hiber">
    <icon_name></icon_name>
    <message>Authentication is required to switch graphics driver</message>
    <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
    <message xml:lang="zh_CN">系统休眠需要验证权限</message>
    <annotate key="org.freedesktop.policykit.exec.path">/bin/bash</annotate>
    <annotate key="org.freedesktop.policykit.exec.argv1">/usr/bin/Hiber.sh</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
  </action>

</policyconfig>

修改点和注意点
<action id="com.deepin.hiber"> ---需要唯一id,不可重复
<message xml:lang="zh_CN">系统休眠需要验证权限</message> ---提示信息,可随意设置
<annotate key="org.freedesktop.policykit.exec.path">/bin/bash</annotate> ---bash提权,不用修改
<annotate key="org.freedesktop.policykit.exec.argv1">/usr/bin/Hiber.sh</annotate> ---可执行文件路径

<icon_name></icon_name> ---此处图标为空,不要设置,设置后为显卡的验证提示和图标,问题未知...

3. 创建桌面图标--图标自行下载
在/usr/share/applications/目录下创建desktop文件
创建hiber.desktop文件
内容为下:

[Desktop Entry]
Name=Hiber
Name[zh_CN]=电脑休眠
Exec=Hiber.sh
Icon=/usr/share/Hiber/hiber.png
Terminal=false
StartupNotify=true
Type=Application
Categories=other

修改点:
Name=Hiber ---英文名字
Name[zh_CN]=电脑休眠 ---中文名字
Exec=Hiber.sh ---可执行文件名
Icon=/usr/share/Hiber/hiber.png ---图标路径

4. 在桌面空白区域右键菜单中添加快捷方式
在/home/user/.config/deepin/dde-file-manager/menuextensions目录下创建Extend.json文件
内容为下:

[            
          {        
              "MenuType": "EmptyArea",        
              "Icon": "",        
              "Text[zh_CN]": "休眠",        
              "Exec": "Hiber.sh"    
           }
]

修改点:
text:显示文本
exec:可执行文件名

示例图如下:


休眠-右键.png 验证.png 错误提示.png

相关内容

    暂无相关文章