You are not logged in.

#1 2009-05-22 11:26:47

brazzmonkey
Member
From: between keyboard and chair
Registered: 2006-03-16
Posts: 818

How to setup a system-wide keyboard shortcut to shutdown computer?

Hello there.
I hide my box in a cupboard (!)
I've got an external power switch to bring it to life.
But I need to open the cupboard and push my computer power button to switch it off.

Is there a way to set up a system-wide keyboard shortcut? I'd like to power off my computer when I hit, say, Ctrl+Alt+End.

Thanks.

Last edited by brazzmonkey (2009-05-22 18:11:44)


what goes up must come down

Offline

#2 2009-05-22 12:21:57

hcjl
Member
From: berlin
Registered: 2007-06-29
Posts: 330

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

for instance

gnome-terminal -x poweroff

with gnome terminal

urxvt -e poweroff

with urxvt

...

you can create a shortcut or a hot key.

Last edited by hcjl (2009-05-22 12:25:17)

Offline

#3 2009-05-22 19:09:25

brazzmonkey
Member
From: between keyboard and chair
Registered: 2006-03-16
Posts: 818

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

Thanks, but that's not exactely what I'm looking for...
First of all, I use LXDE on this machine. But I want to set up a hot key in a way that is not LXDE (or any other DE) related. I want it to work in console mode as well, and, if possible, not rely on a specific program. That's what I meant by system-wide.


what goes up must come down

Offline

#4 2009-05-22 19:30:42

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

brazzmonkey wrote:

Thanks, but that's not exactely what I'm looking for...
First of all, I use LXDE on this machine. But I want to set up a hot key in a way that is not LXDE (or any other DE) related. I want it to work in console mode as well, and, if possible, not rely on a specific program. That's what I meant by system-wide.

Put this in your sudoers:

your_username ALL=(ALL) NOPASSWD: /sbin/shutdown -h now

Then just make a shortcut for "sudo shutdown -h now". The NOPASSWD: is the important part here.

Check out /etc/inittab. There is a shortcut defined for alt+ctrl+del (it reboots the system, you can change that so it shuts down, perhaps you can add your alt+ctrl+home keybind there but I'm not sure, haven't fiddled with it)

Last edited by moljac024 (2009-05-22 19:41:24)


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#5 2009-05-22 19:36:57

whoops
Member
Registered: 2009-03-19
Posts: 891

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

Hi!

I saw reset/strg+alt+rm being set in some config file I browsed not long ago (I think I was fooling around with "sudo cat $(sudo find /etc -type f -readable) | grep stuff") and somewhere I read something about how to disable that in a very old xorg.conf. It don't recall where, don't know if one can put those things together (setting shortcut for shutdown + disable xorg disabling the shurtcut) but maybe that reminds someone of something useful wink

good luck!

Offline

#6 2009-05-22 19:43:41

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

Check this out: http://wiki.archlinux.org/index.php/Ext … in_Console

I believe you will have to define the key combinations in X as well.

I'll throw in this as well: http://linuxgazette.net/issue55/henderson.html

Last edited by Ashren (2009-05-22 19:46:19)

Offline

#7 2009-05-22 22:17:25

brazzmonkey
Member
From: between keyboard and chair
Registered: 2006-03-16
Posts: 818

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

@moljac024
I know I can set Ctrl+Alt+Del to shutdown in inittab, but that's not the point, because I'd like to keep for reboots. I hoped I could find a way to add other combinations and actions, but so far I haven't found anything relevant.

@Ashren
I think we're getting closer here. Stille have to investigate a bit, I guess.


what goes up must come down

Offline

#8 2009-06-19 08:40:36

brazzmonkey
Member
From: between keyboard and chair
Registered: 2006-03-16
Posts: 818

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

I still haven't found a proper way to set a keyboard shortcut. I need it to work with no user being logged on the machine.
Any guidance would be appreciated.

Thanks.


what goes up must come down

Offline

#9 2009-06-19 13:03:49

theapodan
Member
From: Virginia, USA
Registered: 2008-10-21
Posts: 116

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

You can use xbindkeys to set a shortcut for X.  X controls the keyboard  while it runs, so a console keyboard definition like in Ashren's post won't work under X.

As to the console, Ashren's links look promising??  Did it not work?

Offline

#10 2009-06-19 19:48:19

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

How about "extending" the computer power button to the outside?


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#11 2009-06-19 20:31:04

gazj
Member
From: /home/gazj -> /uk/cambs
Registered: 2007-02-09
Posts: 681
Website

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

R00KIE wrote:

How about "extending" the computer power button to the outside?

Don't extend it, leave it there and then wire a second power button in parralell with the existing one.

Offline

#12 2009-06-19 21:26:21

kazuo
Member
From: São Paulo/Brazil
Registered: 2008-03-18
Posts: 413
Website

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

I use actkbd (it is in aur) with it you can have a system-wide keyboard shortcut

Last edited by kazuo (2009-06-19 21:27:22)

Offline

#13 2009-06-19 22:43:47

brazzmonkey
Member
From: between keyboard and chair
Registered: 2006-03-16
Posts: 818

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

I'm a bit concerned about allowing shutdown in my /etc/sudoers. My PC is also a server so it can be a security flaw.

About Readline, it's such a pain for me... I understood I would have to add something like this:

C-M-[End key here]: "/sbin/shutdown -h now"

in /etc/inputrc.
But I don't know what I should write to specify the "End" key.

In X, I did not achieved a success either. I set

"sudo /sbin/shutdown -h now"
Control+Alt+Mod2 + End

in .xbindkeysrc and added xbindkeys to my ~/.xinitrc. Doesn't work.

Last edited by brazzmonkey (2009-06-19 22:46:20)


what goes up must come down

Offline

#14 2009-06-20 18:00:32

dmartins
Member
Registered: 2006-09-23
Posts: 360

Re: How to setup a system-wide keyboard shortcut to shutdown computer?

For readline, try:

"\C-\M-\x6B": /sbin/halt

Make sure you keep the quotes. This is the "keyseq": function-name format shown in man readline. I'm not sure if hex 6B is the right code for the End key, I got the keycode from http://www.comptechdoc.org/os/linux/how … codes.html and converted it to hex.

You could also try:

"\C-\M-\e[4~": /sbin/halt

Reference: http://www.comptechdoc.org/os/linux/how … progs.html

Offline

Board footer

Powered by FluxBB