6

The designers of my new keyboard decided that for some f:in reason the PrintScreen key must sit between AltGr and RCtrl.

So now I have this problem: I like having the magic SysRq key available because it has been useful every now and then. But now I have, for example, AltGr+k mapped to downarrow and a moment ago when I wanted to use this downarrow combination, I accidentally pressed AltGr+PrintScreen+k and all programs were killed. This is extremely annoying.

Is there any way to remap sysrq somewhere else? Like AltGr+delete or something.

1

I just ran into this problem on my new laptop. My solution was to patch drivers/tty/sysrq.c in the kernel to add

#undef KEY_SYSRQ
#define KEY_SYSRQ KEY_VOLUMEDOWN

right after all the #includes. If volume-down is not an appropriate key for you, you can find other keycodes in include/uapi/linux/input-event-codes.h.

I don't see any way to do this remapping without modifying the kernel. If that's not an option, one can at least use /proc/sys/kernel/sysrq as described in the kernel's sysrq documentation to disable the more dangerous requests:

echo 0x1A >/proc/sys/kernel/sysrq

This only enables control of logging levels, process dumps and sync. Most of the other categories will probably interrupt your work after an accidential trigger.

-1

The answer depends on whether you are running X (a current generation gui desktop) or not. You didn't specify.

Running X:

There are several ways to handle this.

The most precise/limited way is to use xmodmap. I haven't used it, so I'm not familiar with the details. It will remap keys with specific key codes to specific key symbols.

If you have trouble sorting things out, run xev. When you press any key combination (or do other X things), xev will tell you what the system saw which will give you the values you need for xmodmap.

Once you get the command to work, you can run it from your ~/.login script so it's there when you start an interactive shell. Or, you can add it as a bash script into your desktop environment's autostart system.

If you want to do more, you may want to check out AutoKey which is a desktop automation tool. Among other things, you can define a macro which will be triggered by a simple or compound keypress which can do anything from just emitting another keypress to running a complex macro coded in Python which can do almost anything you can think of - if you know enough Python.

I use it every day and love it.

For simpler things along the same lines, check out xdotool. It can also do a few things which AutoKey currently can't do - like emit mouse events.

Not running X (server installation, etc.):

This is a lot harder to find information on because it's a much less common case.

I've never tried it, but I did find some information on it here yesterday answering another question.

2
  • 4
    Actually I already remapped the key but it seems the kernel captures the sysrq combinations before X sees them or something. – nonpop Feb 17 '15 at 9:04
  • Upon rereading your question, I see that I missed that you had already done that. – Joe Sep 1 '15 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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