8

I use the icon in the upper right corner of GNOME Shell to shut down my system.

Which command is used to shutdown the system?

  • halt
  • shutdown -h now
  • Something completely different?

enter image description here

A.B.
  • 90,397
  • which version - gnome 3.16? You may get an idea of which bit to look at from the code of this extension (which works on 3.14 and earlier...) – Wilf May 30 '15 at 17:58
  • EDIT: much better extension to examine, as it can replace the shutdown button (albeit with a suspend button) - gnome probably uses a backend, or system call (or something...) to tell the system to shutdown - extensions can to some extent execute commands, though privileged shutdown ones may cause issues. What problems if any make you need to do this? – Wilf May 30 '15 at 18:14
  • @Wilf I do not want to install an extension. I want to intervene in the existing system. – A.B. May 31 '15 at 18:21
  • OK (sorry, thought replacing the button was easiest :). Problem is it may make some system call to a backend or something - you could search through the source to see what it does, but I can't see anything obvious. Or you could remove the permission to allow users, apps etc to shut the system down - probably similar to the reverse of enabling hibernation – Wilf May 31 '15 at 21:48
  • 1
    I think that the command used is a message to dbus. The problem is that it changes with gnome versions and underneath system and so on. Maybe http://ubuntuforums.org/showthread.php?t=1660987 can help. You can use http://vidner.net/martin/software/dbus-spy/ to see what's happening... – Rmano Jun 02 '15 at 17:51
  • 1
    @Rmano This is an interesting approach. – A.B. Jun 02 '15 at 18:09
  • Use this command "gnome-session-save --shutdown-dialog" – BDRSuite Jun 08 '15 at 16:32

1 Answers1

9

The command used to shutdown is:

dbus-send --system --print-reply --dest=org.freedesktop.login1 /org/freedesktop/login1 "org.freedesktop.login1.Manager.PowerOff" boolean:true

For understanding

man systemd-logind

systemd-logind is a system service that manages user logins. It is
       responsible for:
   ·   Keeping track of users and sessions, their processes and their idle
       state

   ·   Providing PolicyKit-based access for users to operations such as
       system shutdown or sleep

   ·   Implementing a shutdown/sleep inhibition logic for applications

   ·   Handling of power/sleep hardware keys

   ·   Multi-seat management

   ·   Session switch management

   ·   Device access management for users

   ·   Automatic spawning of text logins (gettys) on virtual console
       activation and user runtime directory management

Now read to the systemd/logind wiki http://www.freedesktop.org/wiki/Software/systemd/logind/

Maythux
  • 84,289