Jump to content

keyboard shortcut to shutdown -c


Recommended Posts

I don't think this post belongs here,but it doesn't appear to fit anywhere else,so here it is.Maybe a mod can move it to the right place.

 

I am trying to get/create a keyboard shortcut to cancel the shutdown,once it is selected using the right click,log out,turn off computer method.

 

Example: A way to still issue the command "shutdown -c" ,when you suddenly realize you don't want to turn off the computer,after selecting the right click,turn off computer.

I believe with the mac OS,you simply launch a app before the shutdown,and the shutdown is cancelled.

Is there a simple solution with linux?

Maybe a additional entry in etc/inittab?

One completely independent of the mouse or GUI.Reason I'm looking for a keyboard shortcut.

 

[moved from Talk-Talk by tyme]

Link to comment
Share on other sites

This is just a rough layout, but I think you'd have to achieve at least the following:

 

1. Trap a key sequence similar to Ctrl-Alt-Del for system shutdown cancelling. This could be done in /etc/inittab. But you'd have to figure out how (special) keys are addressed.

 

2. Write a script that is executed when your own key sequence is pressed. That script should go through the list of active processes (i.e. from "ps -A x") and grep out the process number of the shutdown command. It then should terminate the shutdown process number ("kill -9").

 

Depending on how far the shutdown process has got, you'd also have to go back to runlevel 3 or 5 (init 3/init 5) again.

Link to comment
Share on other sites

scoonma,thanks for the reply.

Even one that says I'm off my rocker and it can't be done,is better than no reply at all.

What you have stated does sound like what I need.

 

First,I have two feet into something here I really do not know much about.

I wouldn't be able to write a script myself.I don't think.

 

I have a seperate install I use for experimenting with things like this unknown to me.So if I screw it up real bad,only takes 15 minutes to re-install,and I'll try it again.Only way I have to learn.

 

First thing I tried,and it failed,was to edit inittab to this:

# Trap CTRL-ALT-DELETE

#ca::ctrlaltdel:/sbin/shutdown -t3 -r now (I commented this out)

# Trap experiment CTRL-ALT-DELETE (And changed this to -c)

ca::ctrlaltdel:/sbin/shutdown -c

 

 

I had the idea,instead of figuring out how the (special) keys are addressed,to first see if -c would work with a set of keys that already was.10 steps backwards for me.

Even with inittab modified as above,(yes,was saved as root)the keys cntr-alt delete still performed exactly as before.That was unexpected.

I anticipated it not working at all,if nothing else.

 

When right clicking to shutdown,the keys have no effect once(for what I believe is the reason)X has recieved the termsignal.

The cntr-alt-delete sequence is calling up a GUI,same as right clicking,log out.

I have to change that.

Seems to be as well,for the immediate execution of the ctrl-alt-delete,it has to be done in console.Not a GUI based login.

 

Well,if I ever get this figured out,I'll probally never use it anyway.

But at least I learned something.

Link to comment
Share on other sites

The cntr-alt-delete sequence is calling up a GUI,same as right clicking,log out.

I have to change that.

In KDE that can be changed in the control center.

System>system menu's?

I have Mandriva Free, so the menu can be a little different, but by running kcontrol from a terminal you will start the control center. Then go to Regional & Accessibility -> Keyboard shortcuts where you search for 'log out'. Change that to none or something else.

 

Then go to Input Actions also under Regional & Accessibility and make a new action (Keyboard shortcut -> Command/URL (simple)).

 

I haven't tried this myself, so it may or may not work, but hopefully it will.

Link to comment
Share on other sites

I tried to use the command /sbin/shutdown -c within a keyboard shortcut.

First created it as a user,than also as root.

Once shutdown,or reboot,is selected from the log out menu,the keyboard input is not accepted.

Maybe the wrong command?If this command is issued in console,no pid of shutdown is found.So it is a valid command.

I have a feeling that,being that I only have a few seconds,3 of them,to issue the command to cancel the shutdown,anything short of a script will not work.

Thanks to all.

Link to comment
Share on other sites

  • 3 weeks later...
I have a feeling that,being that I only have a few seconds,3 of them,to issue the command to cancel the shutdown,anything short of a script will not work.

Thanks to all.

 

You can change that time to ten secondes by editing /etc/inittab:

 

# Trap CTRL-ALT-DELETE

ca::ctrlaltdel:/sbin/shutdown -t10 -r now

 

For your user shutdown abort, you may consider this link.

 

So you'd also have to ad a line like that one:

 

cc::kbrequest:/sbin/shutdown -c "Shutdown cancelled by user"

 

But you'd also have to specify the kbrequest more detaild, I didn't find better docs on that than the above...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...