[Solved] Seeking direct shutdown command

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
markfilipak
Level 6
Level 6
Posts: 1174
Joined: Sun Mar 10, 2013 8:08 pm
Location: Mansfield, Ohio

[Solved] Seeking direct shutdown command

Post by markfilipak »

===== Begin Solution =====
WinterTroubles wrote:Not exactly answering your question, but.. if you right click the panel and find 'add new items' ( or go to panel settings in the menu and click the 'add item' button on the items tab) you can add 'action buttons', that would allow you to have any or all of the following buttons in the panel.. Lock screen, switch user, suspend, hibernate, shut down, restart, log out and 'log out...' (which takes you to a window offering several of the choices).

Personally I find having action buttons in the panel even simpler than a button in the menu.

Hope this is of interest
WT
Thanks WT.

It does work. And if the only thing [X]'ed is 'Shut Down', then it takes up very little 'Panel' space.
===== End Solution =====

Hi All,

I'm looking for a terminal command that will directly and immediately perform a shutdown. Or, as a fine alternative, is there a way to compel '/usr/bin/xfce4-session-logout' to shutdown -- Note that I already tried '/usr/bin/xfce4-session-logout --logout'.

(If such a shutdown command can be combined with a command to close all applications prior to shutdown, I'd really like that!)

Background:
When I use the "G"-looking button in the lower-right of the 'Whisker Menu', after a pause, a different-looking sorta-"desktop" (slide show of nature scenes) appears and a "Login" dialog is displayed in which I'm prompted for my username. In order to shut down I have to then click an upside-down "Q"-looking thingy in the upper-right of the sorta-"desktop" and choose "Shutdown".

Now, in the 'Commands' section of the 'Behavior' tab of the 'Whisker Menu' (that is: 'Panel' > 'Items' tab > 'Whisker Menu' > [icon showing what appears to be a stack of 3 exclamation marks lying down] > 'Behavior' tab > 'Commands' section > ) there is found a '[X] Log Out' selection. It currently points to '/usr/bin/xfce4-session-logout'. I'd like it to point to some command that performs shutdown directly.

Is there such a direct shutdown command?

Thank You.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
all41
Level 19
Level 19
Posts: 9520
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: Seeking direct shutdown command

Post by all41 »

terminal command that will directly and immediately perform a shutdown

Code: Select all

sudo shutdown -P now
Everything in life was difficult before it became easy.
markfilipak
Level 6
Level 6
Posts: 1174
Joined: Sun Mar 10, 2013 8:08 pm
Location: Mansfield, Ohio

Re: Seeking direct shutdown command

Post by markfilipak »

all41 wrote:
terminal command that will directly and immediately perform a shutdown

Code: Select all

sudo shutdown -P now
Thank you, but it doesn't work when invoked by the "G"-looking button in the lower-right of the 'Whiskers Menu'. I replaced '/usr/bin/xfce4-session-logout' with 'sudo shutdown -P now' and nothing happens when I push the button. I suppose that somewhere in some invisible dialog I'm being prompted for the 'root' password...

Is there an alternative that can be "button"-ized?

Thank You.

PS: I tried this:

Code: Select all

echo <mypassword>|sudo shutdown -P now
but that didn't even work in a terminal session.
Habitual

Re: Seeking direct shutdown command

Post by Habitual »

markfilipak wrote:I'm looking for a terminal command that will directly and immediately perform a shutdown.

Code: Select all

dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
Don't blink, you'll miss it.
markfilipak
Level 6
Level 6
Posts: 1174
Joined: Sun Mar 10, 2013 8:08 pm
Location: Mansfield, Ohio

Re: Seeking direct shutdown command

Post by markfilipak »

Habitual wrote:
markfilipak wrote:I'm looking for a terminal command that will directly and immediately perform a shutdown.

Code: Select all

dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
Don't blink, you'll miss it.
Result in terminal:

Code: Select all

Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Hal was not provided by any .service files
I submitted "dbus-send" to Synaptic's 'Quick Search' and got back results, but I don't know how to interpret the results and there doesn't seem to be any way that I can copy them to paste here.

Thanks for the try. The penguin wins again.
Habitual

Re: Seeking direct shutdown command

Post by Habitual »

Try this then:

Code: Select all

dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.ConsoleKit.Manager.Shutdown int32:0
markfilipak
Level 6
Level 6
Posts: 1174
Joined: Sun Mar 10, 2013 8:08 pm
Location: Mansfield, Ohio

Re: Seeking direct shutdown command

Post by markfilipak »

Habitual wrote:Try this then:

Code: Select all

dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.ConsoleKit.Manager.Shutdown int32:0
Result in terminal:

Code: Select all

Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Hal was not provided by any .service files
PS: I think that means it's objecting to the '--dest=' argument.
WinterTroubles

Re: Seeking direct shutdown command

Post by WinterTroubles »

Not exactly answering your question, but.. if you right click the panel and find 'add new items' ( or go to panel settings in the menu and click the 'add item' button on the items tab) you can add 'action buttons', that would allow you to have any or all of the following buttons in the panel.. Lock screen, switch user, suspend, hibernate, shut down, restart, log out and 'log out...' (which takes you to a window offering several of the choices).

Personally I find having action buttons in the panel even simpler than a button in the menu.

Hope this is of interest
WT
Habitual

Re: Seeking direct shutdown command

Post by Habitual »

markfilipak wrote:
Habitual wrote:Try this then:

Code: Select all

dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.ConsoleKit.Manager.Shutdown int32:0
Result in terminal:

Code: Select all

Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Hal was not provided by any .service files
PS: I think that means it's objecting to the '--dest=' argument.
You may be right, other posts on the net show

Code: Select all

dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.ConsoleKit.Manager.Shutdown int32:0
Quotes around "org.freedesktop.Hal"
markfilipak
Level 6
Level 6
Posts: 1174
Joined: Sun Mar 10, 2013 8:08 pm
Location: Mansfield, Ohio

Re: Seeking direct shutdown command

Post by markfilipak »

WinterTroubles wrote:Not exactly answering your question, but..
Thanks WT.

It does work. And if the only thing [X]'ed is 'Shut Down', then it takes up very little 'Panel' space. But I would prefer it as a 'Whisker Menu' item that consequentially doesn't take up any 'Panel' space ....

.... Got any idea what the 'Shut Down' action is submitting? I assume that whatever it is, it's being submitted to '/usr/bin/xfce4-session'. Now that would be an API I'd really like to be able to sniff.

This _is_ a solution, but I'd really like to put the button in the 'Whisker Menu', not on the 'Panel'. Perhaps I'll find a way. Or perhaps someone knows how to get it done.

Thank you so much, WT.
WinterTroubles

Re: Seeking direct shutdown command

Post by WinterTroubles »

Your welcome markfilipak.

Unfortunately I've only been 'playing' with Xfce for about a week, cinnamon is my regular desktop, and I've so far been unable to locate the relevant files for 'action buttons' to try and find which commands it uses (I'm probably missing something obvious :lol: ).

As curiosity demands and time permits I will probably take another look around, but, as I'm still learning about Xfce there no certainty I'll locate the relevant files.. and even if I do someone else may have already found you a solution.

If I do find anything relevant I will post back and let you know.

Regards
WT
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Seeking direct shutdown command

Post by Flemur »

$ sudo chmod u+s /sbin/shutdown

See: "Are there consequences to running 'sudo chmod u+s /sbin/shutdown"
http://askubuntu.com/questions/91397/ar ... n-shutdown
I don't see anything wrong with it - and it makes life easier.

Then make a one-line script named Shutdown in your ~/bin directory (IN YOUR $PATH):
/sbin/shutdown -h now

Use "Shutdown" where you're trying to make it work. If it fails, try
xterm -e Shutdown
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
markfilipak
Level 6
Level 6
Posts: 1174
Joined: Sun Mar 10, 2013 8:08 pm
Location: Mansfield, Ohio

Re: Seeking direct shutdown command

Post by markfilipak »

Habitual wrote:

Code: Select all

dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.ConsoleKit.Manager.Shutdown int32:0
Quotes around "org.freedesktop.Hal"
Result in terminal:

Code: Select all

Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Hal was not provided by any .service files
This is a horse that doesn't want to be ridden.

I found this: 'http://freedesktop.org/wiki/Software/hal/', that might interest you -- it interests me.

I'm going with the suggested Action Button for now. But thank you very much for helping me, Habitual. Ciao.
Habitual

Re: Seeking direct shutdown command

Post by Habitual »

markfilipak wrote:
Habitual wrote:

Code: Select all

dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.ConsoleKit.Manager.Shutdown int32:0
Quotes around "org.freedesktop.Hal"
Result in terminal:

Code: Select all

Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Hal was not provided by any .service files
This is a horse that doesn't want to be ridden.

I found this: 'http://freedesktop.org/wiki/Software/hal/', that might interest you -- it interests me.

I'm going with the suggested Action Button for now. But thank you very much for helping me, Habitual. Ciao.
Always glad to be of help. Bummer that the old c-line cheat has been deprecated somehow.
Locked

Return to “Xfce”