I know there is already a similar question about this topic. But that question was only about how to get the shutdown dialog in general. I need to get back the countdown of the old shutdown dialog (Ubuntu <= 12.10) which shutdown the system after 60sec.

geobuntu suggested this dbus call in his answer:

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

qdbus indicate that third argument is max_wait which should (in my opinion) set and start the countdown:

~$ qdbus org.gnome.Shell /org/gnome/SessionManager/EndSessionDialog
[...]
method void org.gnome.SessionManager.EndSessionDialog.Open(uint type, uint arg_1, uint max_wait, QList<QDBusObjectPath> inhibitors)

But it doesn't. I already tried various values for type and arg_1 without luck.


EDIT: Actually the countdown is more 'nice to have'. What I really need is that the system WILL shutdown without any extra user action. It should work without sudo (including any no-password sudoers).

I would prefer dbus calls cause I already have a nice list of dbus calls which will shutdown all DE's except Unity >= 13.04


EDIT2: I had a look into Unity source. I don't know C++ but for me it looks like arg1 and timeout_length are not handled in source (can someone with C++ knowledge please confirm this?). Maybe this will be added in later releases.


EDIT3: I reported this as bug #1256703 on Launchpad.

  • In command line, sudo shutdown +1 would work, but that will just shutdown in a minute unless cancelled (Either by Ctrl-C, or sudo shutdown -c). I know this is not what you asked, but it may be useful anyway. – Wilf Nov 25 '13 at 21:45
  • That will also need sudo. I'm trying to avoid that. – Germar Nov 25 '13 at 21:53
  • You don't have to include sudo - see here and here. But, one of the problems is, with Linux, with doing things via command line, it often has to be done as root... (e.g. controlling internet connection). As for the opening the old dialog, I ain't got any idea on how to do it. – Wilf Nov 25 '13 at 23:05
up vote 3 down vote accepted

There was a great answer from Majal Mirasol about this. He suggested to use

/usr/bin/dbus-send --system --print-reply \
--dest="org.freedesktop.ConsoleKit" \
/org/freedesktop/ConsoleKit/Manager \
org.freedesktop.ConsoleKit.Manager.Stop

This will work perfectly for me.

If you like this solution please send kudos to Majal's answer and not this one.

Run sudo visudo in the terminal and add the following line:

%user_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown

This allows you to run the above three commands, using sudo, however with no password.

So, sudo poweroff will now result in a password less shutdown.

then create an alias by putting the following at the end of ~/.bashrc_aliases by opening it as -

gedit ~/.bash_aliases

and add the following in the last -

alias shutdown='sudo shutdown -h now'

Now lets load the changes to the .bash_aliases file.

source ~/.bash_aliases

Try shutdown . hope it will work.

  • Thanks @Sushantp606. Sure this will work on my own system. But I need this for OSS project BackInTime (launchpad.net/backintime) and I don't want to mess around in users sudoers file for this. – Germar Nov 28 '13 at 19:27

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.