You are not logged in.
I have a Honor laptop without a 'SysRq' key (or print screen or F13). On my pc I use the SysRq key for occasional debugging and recovering from an unresponsive system.
On the pc I followed this guide https://wiki.archlinux.org/title/Keyboa … l_(SysRq)] and all good.
I'd like to enable this on the laptop, but finding it's not a simple matter of just mapping the key, from what I've discovered it needs to be done at 'kernel level', or the missing key should be mapped 'low level'.
Can anyone help and point me to a guide where I can achieve this? I don't mind which key I substitute, but lets say I make it the obvious one to the right of F12 which is 'Ins'.
I keep up to date and currently kernel is
6.6.58-1-lts
Offline
You could go through /proc/sysrq-trigger but that assumes the system is still responsive enough to provide an interactive shell / act on generic keyboard shortcuts in user space.
Otherwise kernel documentation describes how to map another key to be Sysrq:
https://www.kernel.org/doc/html/latest/ … at-s-wrong
You could put that in a startup script or an udev rule.
PS: did you go through all possible keys, like Fn-F11 and the like? Also magic sysrq itself has to be enabled to work.
Last edited by frostschutz (2024-10-27 10:04:28)
Offline
You could go through /proc/sysrq-trigger but that assumes the system is still responsive enough to provide an interactive shell / act on generic keyboard shortcuts in user space.
Otherwise kernel documentation describes how to map another key to be Sysrq:
https://www.kernel.org/doc/html/latest/ … at-s-wrong
You could put that in a startup script or an udev rule.
PS: did you go through all possible keys, like Fn-F11 and the like? Also magic sysrq itself has to be enabled to work.
Thank you.
First, yes I've tried many possible key combinations, since I already use this 'magic key' successfully on my pc many times, I'd say I'm familiar with how to enable it when the 'SysRq' key exists and the how to use it. Iv'e also enabled it on the laptop and rebooted. In fact I've been trying for months to get it working!
I've seen the link you posted, and have read that page before, but it isn't detailed enough for me to follow, I'm happy to try hard and make this work, I'll have to go through it slowly, one step at a time.
So to begin, first step
There are some keyboards that produce a different keycode for SysRq than the pre-defined value of 99 (see KEY_SYSRQ in include/uapi/linux/input-event-codes.h), or which don’t have a SysRq key at all. In these cases, run showkey -s to find an appropriate scancode sequence, and use setkeycodes <sequence> 99 to map this sequence to the usual SysRq code (e.g., setkeycodes e05b 99). It’s probably best to put this command in a boot script. Oh, and by the way, you exit showkey by not typing anything for ten seconds.
When use showkey and press 'Ins' key I get
^[[2~0xe0 0x52 0xe0 0xd2
To begin with I need to put a sequence into a boot script. (from above setkeycodes eo5b 99), I get ''0xe0 0x52 0xe0 0xd' when I press Ins, which one of these do I use, and how do I make a 'boot script'
You can see I'm happy to follow a guide, but very much out of my depth
Last edited by btb45 (2024-10-27 10:29:27)
Offline
I've never remapped the Sysrq key myself (on PC, with full keyboard, it was never necessary) so as for the detailed steps I'm also not too sure.
Before using showkeys, you should disable sysrq (echo 0 > /proc/sys/kernel/sysrq). This is because when Sysrq is enabled, and you press Alt-Sysrq, the kernel will "eat" it so it won't actually be shown by showkeys. Disabling sysrq makes sure showkeys will actually show it to you.
Then you can use showkeys without -s first, to get a more human readable display. And then add -s when you need the hexadecimal codes.
Once you're sure you got the correct code, you can re-enable sysrq, and give it a try (like the documentation suggests). Try to make it work manually first; once you have the command that works, you can automate it so it will be activated on startup.
There's also a post here that suggests using hwdb: Remapping SysRq in Linux (the links within that answer are unfortunately broken atm, maybe it can help you anyhow)
Good luck
Last edited by frostschutz (2024-10-27 10:47:59)
Offline
Thank you the tips.
I also read that page on 'superuser', it seems to be useful, 9 years old though and I can't correlate the folders/files mentioned to archlinux, and as you say links within are broken, so I can't follow what to.
I'd like to make it work, but I think its beyond my level of expertise.
Offline
I made it work using the 'NumLock' key
setkeycodes 0x45 99
That was all I had to do! It doesn't stick after a reboot, I'll work on that now!
Edited to add
Now I have this working. I was wrong or misunderstood all I read about 'low level' or 'kernel level' mapping, and the complicated instructions about kernel modules etc.
I put a script in /usr/local/bin setting the keycode as above, then a service module in /usr/lib/systemd/system to run it at boot, and it's up an running.
Last edited by btb45 (2024-10-27 12:02:05)
Offline