How do I shutdown a desktop session gracefully from the command line without root, giving programs the option to ask the user to save files or cancel the shutdown? I know shutdown, halt, and other similar methods aren't viable, since they will just ask every process to end and forcibly kill it a few seconds later. They also require root, which I want to avoid. When shutting down, a program with unsaved files should be able to block the shutdown process or cancel it, if the user chooses to do so. I believe the answer has something to do with DBus, but from what I understand every desktop session has a different dbus interface to use. Most results in online searches either point to shutdown/halt or to a Gnome or KDE-specific solution. Is there a method that works for all desktop environments, or will I always need a list of dbus commands to try and cover every desktop?

  • Try DISPLAY=:0 gnome-session-quit --logout – datUser Jul 6 '15 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.