關機命令是什麼?

關機命令是什麼?

我想在 13.04 中為啟動器建立一個關機圖示。在先前版本的 Ubuntu 中,我使用了這個桌面檔案並將其放入啟動器中:

.local/共享/應用程式/指示器-會話-shutdown.desktop

[Desktop Entry]
Name=Shut Down
TryExec=/usr/lib/indicator-session/gtk-logout-helper
Exec=/usr/lib/indicator-session/gtk-logout-helper --shutdown
Icon=system-shutdown
Terminal=false
Type=Application
OnlyShowIn=Unity;
Categories=System;
Version=1.0
X-Ubuntu-Gettext-Domain=indicator-session

我懷疑是否

/usr/lib/indicator-session/gtk-logout-helper --shutdown

在 13.04 中仍然是正確的命令。

這是舊的關閉對話框的螢幕截圖:

在此輸入影像描述

這是帶有新關閉對話框的螢幕截圖:

在此輸入影像描述

答案1

嘗試:

gnome-session-quit

如需更多選擇:

gnome-session-quit --help

根據手冊,支援以下選項:

   --logout
          Prompt the user to confirm logout. This is the default behavior.

   --power-off
          Prompt the user to confirm system power off.

   --reboot
          Prompt the user to confirm system reboot.

   --force
          Ignore any inhibitors.

   --no-prompt
          End the session without user interaction. This only  works  with
          --logout.

或查看 dbus-monitor,這是命令:

dbus-send --print-reply --dest="org.gnome.Shell" /org/gnome/SessionManager/EndSessionDialog org.gnome.SessionManager.EndSessionDialog.Open uint32:2 uint32:0 uint32:60 array:objpath:/org/gnome/SessionManager/EndSessionDialog

答案2

要獲得確切的對話框,唯一的方法是透過 dbus,因為gnome-sesion-quit只顯示通用的四個選項對話框。我通過查看得到了這個dbus-monitor。這是命令:

dbus-send --print-reply --dest="org.gnome.Shell" /org/gnome/SessionManager/EndSessionDialog org.gnome.SessionManager.EndSessionDialog.Open uint32:2 uint32:0 uint32:60 array:objpath:/org/gnome/SessionManager/EndSessionDialog

相關內容