Xfce Forum

Sub domains
 

You are not logged in.

#1 2017-07-06 07:30:30

eddie3000
Member
Registered: 2017-07-06
Posts: 8

Can I change the default shutdown confirmation menu option?

Hello. I am new in this forum and I would like an answer to this question as I have now found an answer over the internet yet. I've been looking for about a couple of weeks, it's not urgent in any way but it would be nice to get the answer.

When I press the shutdown button on my laptop, I get a liitle window with buttons allowing me to choose between restarting, shutting down, suspending, logging out, etc... The default option is always log out, so I have to click the shutdown option with the mouse. I would like the shutdown option to be selected by default so I could just press the power button and enter to shutdown the computer. If it were possible to actually have the last option used remembered by the OS I would be even happier.

I am currently using ubuntu studio 16 with xfce 4.12 destop.

Thank you.

Offline

#2 2017-07-06 09:23:56

PaperNick
Member
Registered: 2013-05-26
Posts: 106

Re: Can I change the default shutdown confirmation menu option?

I tend to favour the keyboard over the mouse and I understand you issue. I personally don't know if it's possible to rearrange those buttons, but you can select the desired option, using your arrow keys.

My typical flow consists of pressing the power button, then clicking the right arrow button twice for Shut Down or one time for Restart. If I want to Suspend, I press the down arrow key once.

Last edited by PaperNick (2017-07-06 09:31:03)

Offline

#3 2017-07-06 09:55:29

eddie3000
Member
Registered: 2017-07-06
Posts: 8

Re: Can I change the default shutdown confirmation menu option?

That is a good tip. I hadn't thought of it and it is simple and easy to get used to. Thank you PaperNick.

Anyhow, anybody know how to do what I want? Or maybe even run a custom script when the power button is pressed?

Offline

#4 2017-07-06 12:05:28

MountainDewManiac
Member
From: Where Mr. Bankruptcy is Prez
Registered: 2013-03-24
Posts: 1,115

Re: Can I change the default shutdown confirmation menu option?

Menu / Settings / Power Manager, "When power button is pressed:" Shutdown.

Regards,
MDM


Mountain Dew Maniac

How to Ask for Help <=== Click on this link

Offline

#5 2017-07-08 18:54:35

MountainDewManiac
Member
From: Where Mr. Bankruptcy is Prez
Registered: 2013-03-24
Posts: 1,115

Re: Can I change the default shutdown confirmation menu option?

MountainDewManiac wrote:

Menu / Settings / Power Manager, "When power button is pressed:" Shutdown.

Did that work for you? I would assume so, but you have not edited the thread title (by editing the first post in this thread) to add [SOLVED] to the beginning of it, so I am left to wonder.

Regards,
MDM


Mountain Dew Maniac

How to Ask for Help <=== Click on this link

Offline

#6 2017-07-08 20:28:13

PaperNick
Member
Registered: 2013-05-26
Posts: 106

Re: Can I change the default shutdown confirmation menu option?

That would work for one of the selected options, not for the last selected from "Ask".
Anyway, if that's what the author wants, I guess we should consider it as solved.

Offline

#7 2017-07-08 20:32:05

Jerry3904
Member
Registered: 2013-11-09
Posts: 850

Re: Can I change the default shutdown confirmation menu option?

So: Menu / Settings / Power Manager, "When power button is pressed:" Ask.


MX-23 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

#8 2017-07-09 08:52:40

eddie3000
Member
Registered: 2017-07-06
Posts: 8

Re: Can I change the default shutdown confirmation menu option?

Hello and thank you all for your answers.
Selecting the option in "Menu / Settings / Power Manager, "When power button is pressed:shutdown"", is extremely dangerous. I had a pen fall on my laptop shutdown button effectively shutting the computer down making me lose all unsaved projects and it also stopped recording an event I was recording.
At home, my toddlers love pressing the shutdown button (other buttons and keys too).
I like the convenience of having to press two buttons, either powerbutton + escape(to cancel) or powerbutton + enter(to shutdown).
The option PaperNick suggested is in fact the best option so far, but it is certainly not what I asked for initially. It would be nice to have the button do what I want, I am not the only one who as already asked about this subject (on many other forums and flavours of linux). And I would still like the solution.
Cheers!

Offline

#9 2017-07-09 11:31:55

Jerry3904
Member
Registered: 2013-11-09
Posts: 850

Re: Can I change the default shutdown confirmation menu option?

What about doing this:

  • Alt-F3

  • enter "logout" in the search box

  • right-click the Log Out entry > Edit

  • Change the command to this: xfce4-session-logout --halt

  • save and exit

Does that do what you want?


MX-23 (based on Debian Stable) with our flagship Xfce 4.18.

Offline

#10 2017-07-09 20:17:38

eddie3000
Member
Registered: 2017-07-06
Posts: 8

Re: Can I change the default shutdown confirmation menu option?

No, that does not work.

If I press alt-f3 I can edit the log out command as you suggested. But it did not work. I tried editing it to "shutdown -h now", but for that to work I had to also edit the /etc/sudoers file. But in spite of editing the logout command and the sudoers file, the logout button in the menu window that appears when pressing the shutdown button does not seem to be affected by that at all. So I have only just restored my sudoers and about to go off to bed sadly. It was a good idea worth trying though. Thanks for the idea.

Offline

#11 2017-07-09 22:18:41

MountainDewManiac
Member
From: Where Mr. Bankruptcy is Prez
Registered: 2013-03-24
Posts: 1,115

Re: Can I change the default shutdown confirmation menu option?

I do not have young children here, and my laptop's power button requires at least a little force. I tried a couple of times, but was unable to hit the target when I attempted to throw a pen at it. But I did tap repeatedly on the button to no effect, so I assume that I'm okay in that regard.

But it does explain why you'd like the extra step (press power button and then press the Enter key).

This requires a little more than just pressing a power button, but couldn't you create a script for shutdown (along with any of the other options you wish to have handy), save and make it executable, and then add a launcher for it to one of your panels? Or, if you wish to have multiple options, create a new panel that is just large enough to hold an equal number of launchers? You could set that to auto-hide. You would have to move your mouse cursor over to the launcher and left-click on it, of course. And there wouldn't be a second step (unless the shutdown command can be configured to require confirmation, I suppose). But it seems somewhat less likely that a toddler could inadvertently activate the script that way.

Regards,
MDM


Mountain Dew Maniac

How to Ask for Help <=== Click on this link

Offline

#12 2017-07-10 01:01:27

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Can I change the default shutdown confirmation menu option?

eddie3000 wrote:

I would like the shutdown option to be selected by default so I could just press the power button and enter to shutdown the computer.

You can try this workaround (which overrides the regular xfce4-session-logout command and uses xdotool to force a couple of tab presses after the dialog loads).

First, with root privileges, create the file /usr/local/bin/xfce4-session-logout with the following content:

#!/bin/bash

/usr/bin/xfce4-session-logout
sleep 0.25
xdotool key Tab key Tab

...and make the file executable. Then test to see it if works properly.

If the dialog loads slowly on your computer, you may need to adjust the sleep command to pause for more time. Also, note that the xdotool package needs to be installed.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#13 2017-07-10 07:13:49

eddie3000
Member
Registered: 2017-07-06
Posts: 8

Re: Can I change the default shutdown confirmation menu option?

Yes. Having a launcher that runs a scripts is a very viable solution. I have that at home, a shutdown launcher that also runs rsync beforhand. But I have a power button on my laptop that I would like to use. It is fortunately not a matter of life or death. It'd just be nice to do.

I'm still looking around for solutions without success yet.

By the way, the xdotool looks very interesting. Is it a safe package to install on one's computer? I might play around with it later on.

Thank you all.

Offline

#14 2017-07-10 08:03:29

MountainDewManiac
Member
From: Where Mr. Bankruptcy is Prez
Registered: 2013-03-24
Posts: 1,115

Re: Can I change the default shutdown confirmation menu option?

eddie3000 wrote:

xdotool looks very interesting. Is it a safe package to install on one's computer?

It is in my distro's (Mint's) repos, so I assume that it isn't malicious software. And it appears to be in widespread use, so it probably isn't likely to accidentally format your hard drive (for example).

Because it allows one to fake keyboard input, I suppose that you could say that it is possible to use it as part of some scheme to cause harm to your computer's data, et cetera. But that does not make the thing dangerous. It'd be like stating that a bullet is dangerous. A bullet is generally perfectly safe - unless someone loads it into a gun and fires it at you, the cabinet that it is stored in catches on fire and the bullet spontaneously "cooks off," et cetera.

In other words, I wouldn't worry about it.

Regards,
MDM


Mountain Dew Maniac

How to Ask for Help <=== Click on this link

Offline

#15 2017-07-10 12:12:49

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Can I change the default shutdown confirmation menu option?

eddie3000 wrote:

Yes. Having a launcher that runs a scripts is a very viable solution. I have that at home, a shutdown launcher that also runs rsync beforhand. But I have a power button on my laptop that I would like to use. It is fortunately not a matter of life or death. It'd just be nice to do.

This isn't a launcher solution. It's extending the existing command that runs the shutdown to add 2 keyboard tab presses to take the default focus to the Shutdown button. Because the script is placed in the /usr/local/bin directory, it will be executed before the real xfce4-session-logout command. It does 3 things:
1. execute the real command
2. pause to give it time to display
3. simulate the pressing of the tab key twice to move the focus over

I'm still looking around for solutions without success yet.

Give it a try - it will meet your initial reqiurement. Just create the script file and make it executable. If it doesn't work, just delete that file and everything will be back to normal.

By the way, the xdotool looks very interesting. Is it a safe package to install on one's computer? I might play around with it later on.

Thank you all.

Yes, it is safe to use. And very useful. It's a command line automation tool.

Edit: My bad. This doesn't work with pressing the power button, but rather only with using the menu logout option as the power button action uses another internal method to perform the actual shutdown. Let me see what I can find.

Last edited by ToZ (2017-07-10 12:26:46)


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#16 2017-07-10 12:43:23

eddie3000
Member
Registered: 2017-07-06
Posts: 8

Re: Can I change the default shutdown confirmation menu option?

I already "broke" my shutdown process, thankfully I made backups of the files I was tampering with and managed to restore everything. But I still haven't got it working. It's a pity that everything I have found related to other flavours of ubuntu does not seem to apply here. Why do developers bother to change the way things are done, and still leave the old files behind that seem to be no good for anything? powerbtn.sh or logind.conf don't seem to do anything because they seem to be bypassed by something else (xfce-power-manager maybe?). From what I have read, disabling xfce-power-manager should let me configure the powerbtn.sh and let it do it's thing, but I'm either not disabling it properly or it's not working either.

Offline

#17 2017-07-10 16:38:28

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,948

Re: Can I change the default shutdown confirmation menu option?

Okay, so xfce4-power-manager ends up using libxfce4ui internals to manage the shutdown process, so no go there. I was able to get it to work using devilspie and the following xfce4-session.ds file:

( if
( is ( window_class ) "Xfce4-session" )
( begin
( spawn_async
( str "xdotool key --delay 100 Tab key Tab" ))
( println "match" )
)
)

This does the same as above - basically catching the logout window displaying and simulating the pressing of the Tab key twice.

From what I have read, disabling xfce-power-manager should let me configure the powerbtn.sh and let it do it's thing, but I'm either not disabling it properly or it's not working either.

I think this is probably because Ubuntu 16.x uses systemd to manage alot of these functions. If you disable xfce4-power-manager or set the shutdown to "Do nothing", then systemd will take over and do the default action as specified in /etc/systemd/logind.conf for HandlePowerKey (which is power off). Apparently you can create hooks that will process systemd powerbutton events (see: https://wiki.archlinux.org/index.php/Power_management and specifically at the /usr/lib/systemd/system-shutdown/ directory.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#18 2017-07-11 06:52:07

eddie3000
Member
Registered: 2017-07-06
Posts: 8

Re: Can I change the default shutdown confirmation menu option?

Well this still needs further investigation. In the mean time I have settled for a launcher on the task bar that runs the following script in terminal:

#!/bin/bash

read -p "Are you sure? " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
    shutdown -h now
fi

It's not ideal, but it'll have to do for the time being. The sudoers file needs editing for it to run the shutdown command without prompting for a password.

Thanks for your answers guys, I'm still hunting for the solution.

Last edited by eddie3000 (2017-07-11 06:54:07)

Offline

#19 2017-07-11 16:15:51

MountainDewManiac
Member
From: Where Mr. Bankruptcy is Prez
Registered: 2013-03-24
Posts: 1,115

Re: Can I change the default shutdown confirmation menu option?

If, as things are now, you have to enter a password to get the shutdown command to function... You don't really need the "Y/N" confirmation dialog, do you? If you change your mind, just don't type the password.

Regards,
MDM


Mountain Dew Maniac

How to Ask for Help <=== Click on this link

Offline

#20 2017-07-12 11:57:46

eddie3000
Member
Registered: 2017-07-06
Posts: 8

Re: Can I change the default shutdown confirmation menu option?

Having to type my password would be a bit too much hassle as it's pretty long. Just clicking the icon and pressing "y" is convenient enough. But I still prefer the power button. At the moment I using both the shutdown icon and the power button + 2xRightArrow + enter.

Offline

#21 2017-09-05 16:11:49

herbie643
Member
Registered: 2013-04-05
Posts: 137

Re: Can I change the default shutdown confirmation menu option?

I know this is an older post but I was just cruising the forum and saw this post.
I used the Power Manager in the configuration window and in the General tab it has what to do when Power Button is pressed.
I set it to Shutdown and BAM, shutdown time.

Offline

#22 2017-09-06 11:42:37

aorith
Member
Registered: 2017-09-06
Posts: 1

Re: Can I change the default shutdown confirmation menu option?

I have rofi installed and a script that calls it with a shutdown/reboot menu, very fast and convenient.

Offline

#23 2020-12-30 20:21:28

filip
Member
Registered: 2020-12-30
Posts: 1

Re: Can I change the default shutdown confirmation menu option?

If you know how and are comfortable with compiling from source, here's a patch for:

/xfce4-session/xfsm-logout-dialog.c

https://gist.github.com/cofi89/50516ab1 … ef3113e12a

In action: https://www.dropbox.com/s/525e6j00o94ka … 1.mkv?dl=0

Tested and verified on 4.16, but works for 4.14, 4.12 and probably older versions (I only checked back to 4.12). smile

----------

Editing the source/recompiling or using scripts to automate Tab or Arrow key presses to move the focus are the only options as of 4.16.0.

Also, worth noting is that it wouldn't be hard to implement xfconf channel/entry to make this configurable. I might make a pull request some day past this lazy time of the year....

Cheers! smile

Last edited by filip (2020-12-30 20:30:24)

Offline

Board footer

Powered by FluxBB