从 Openbox 关闭计算机

从 Openbox 关闭计算机

我最近安装了 Openbox,并阅读了一份指南,其中指出应通过以下命令关闭 PC:

gdm-control --shutdown && openbox --exit

然而,这似乎有点违反直觉。为什么我要先关闭计算机然后退出 Openbox?这怎么可能呢?

或者可能gdm-control --shutdown只是在某个地方发送消息?如果计算机在 Openbox 退出之前关闭怎么办?这真的是“正确的方法”吗?

信息:

Openbox 指南链接:http://urukrama.wordpress.com/openbox-guide/
操作系统:Debian Linux 7.0

答案1

像这样创建一个别名。然后只需输入shut.

alias shut="su -c 'shutdown -h now'"

您需要是 root 才能执行此操作,这就是为什么您首先将用户设置为超级用户 ( su),然后发出命令 ( -c)。用于-h关闭后“停止”,即不要重新启动(或执行任何其他操作)。

答案2

我参加聚会有点晚了,但是为了回答这怎么可能的问题,gdm-control 的手册页说明了一切:

DESCRIPTION
       gdm-control lets you control gdm from within an X session.  It enables
       you to change GDM's behaviour for when you end the current sesson.  For
       instance, you can tell GDM to reboot, and then immediately log out of
       the current session, and the computer will be rebooted
OPTIONS

       ...<snip>...

       --shutdown
            Shutdown the computer when the current session ends.

因此,您告诉 gdm 在会话结束时关闭,然后结束会话。

对于我自己来说,我尝试了什么在这个问题中建议并发现这systemctl poweroff对我来说效果很好。

相关内容