LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-06-2023, 08:15 AM   #1
ychaouche
Member
 
Registered: Mar 2017
Distribution: Mint, Debian, Q4OS, Mageia, KDE Neon
Posts: 369
Blog Entries: 1

Rep: Reputation: 49
Keyboard special keys


Dear LQ,

I was just curious to know if any of you had any bindings for the following keys:
- Sys Rq
- Pause/break
- Scroll Lock

I'd like to use one of these keys in my inputrc to start capturing output from the terminal in a tmp file.
Another keypress on same key would toggle the function off.
I'd also like to use a second key combination to paste the content of last command directly in the command line (more here).

I just wanted to make sure that it was ok to bind these keys,
and also curious if anyone had any special keybindings already bound to them.
 
Old 12-06-2023, 08:20 AM   #2
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,680
Blog Entries: 19

Rep: Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492
SysReq does. I have never actually got this thing to work, but apparently you are supposed to be able to get out of keyboard freezes by holding down SysReq and typing reisub.
 
Old 12-06-2023, 10:58 AM   #3
ychaouche
Member
 
Registered: Mar 2017
Distribution: Mint, Debian, Q4OS, Mageia, KDE Neon
Posts: 369

Original Poster
Blog Entries: 1

Rep: Reputation: 49
Ok so here's code to capture output of last command.
The idea is to press C-x C-: to start capturing output,
then issue any command.
You can put the last line of output of that command to the clipboard with C-x C-x,
or paste it to the terminal with C-x C-v.

The only thing that doesn't work is toggling output capture with C-x C-:
I can't seem to use that key combination.
Anyone has an idea?
see code below

Code:
export CAPTUREOUTPUT=-1

sys.capture.output.on(){
    exec > >(tee -a /tmp/output)
    CAPTUREOUTPUT=0
    debug "capture is on"
}

sys.capture.output.off(){
    exec > /dev/tty
    CAPTUREOUTPUT=-1
    debug "capture is off"    
}

sys.capture.output.toggle(){
    if (( $CAPTUREOUTPUT == 0 ))
    then
	debug "turning off output capture"
	sys.capture.output.off
    else
	debug "turning on output capture"
	sys.capture.output.on
    fi
}

sys.capture.output.last(){
    n=${1:-1}
    tail -n"$n" /tmp/output
}

sys.capture.output.last.copy(){
    desktop.clipboard.set "$(sys.capture.output.last)"
}


debug(){
    echo $@ > /dev/stderr
}

sys.capture.output.last.paste(){
    READLINE_LINE="$READLINE_LINE$(sys.capture.output.last)";
    READLINE_POINT=${#READLINE_LINE}
}

bind -x '"\C-x\C-v": sys.capture.output.last.paste'
bind -x '"\C-x\C-x": sys.capture.output.last.copy'
bind -x '"\C-x\C-:": sys.capture.output.toggle'
 
Old 12-06-2023, 11:23 AM   #4
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Salix
Posts: 6,148

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
Quote:
Originally Posted by hazel View Post
I have never actually got this thing to work, but apparently you are supposed to be able to get out of keyboard freezes by holding down SysReq and typing reisub.
You hold down both Alt and SysReq, release SysReq, and then type REISUB for reboot ot REISUO to shut down. Don't press the keys too quickly — each step obviously has to complete before the next one.

If the facility is set, the you should get the reply "1" from
Code:
 cat /proc/sys/kernel/sysrq
If you don't, use
Code:
echo "1" >/proc/sys/kernel/sysrq
 
1 members found this post helpful.
Old 12-06-2023, 11:34 AM   #5
ychaouche
Member
 
Registered: Mar 2017
Distribution: Mint, Debian, Q4OS, Mageia, KDE Neon
Posts: 369

Original Poster
Blog Entries: 1

Rep: Reputation: 49
Quote:
Originally Posted by ychaouche View Post
The only thing that doesn't work is toggling output capture with C-x C-:
For some reason it has to be C-x: instead of C-xC-:.
*It* doesn't tell the difference between the two,
whatever *it* is.


For the complete solution see my updated answer on SO.
 
Old 12-06-2023, 11:48 AM   #6
lvm_
Member
 
Registered: Jul 2020
Posts: 982

Rep: Reputation: 348Reputation: 348Reputation: 348Reputation: 348
Quote:
Originally Posted by ychaouche View Post
I was just curious to know if any of you had any bindings for the following keys:
- Sys Rq
- Pause/break
- Scroll Lock
ScrollLock is one of keyboard layout switching keys for multilingual environments (setxkbmap -option grp:sclk_toggle), and ScrollLock LED can be set up to to indicate the current layout (grp_led:scroll). I always set it up this way.


Quote:
Originally Posted by DavidMcCann View Post
You hold down both Alt and SysReq, release SysReq, and then type REISUB for reboot ot REISUO to shut down.
Actually it's way more complex and flexible than that: https://www.kernel.org/doc/html/late...ide/sysrq.html
 
Old 12-07-2023, 12:06 AM   #7
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,680
Blog Entries: 19

Rep: Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492Reputation: 4492
Quote:
Originally Posted by DavidMcCann View Post
You hold down both Alt and SysReq, release SysReq, and then type REISUB for reboot ot REISUO to shut down. Don't press the keys too quickly — each step obviously has to complete before the next one.
Ah, that explains it! I thought you had to keep the alt+sysReq keys down throughout the sequence. Thanks a lot!
 
Old 12-07-2023, 02:12 AM   #8
ychaouche
Member
 
Registered: Mar 2017
Distribution: Mint, Debian, Q4OS, Mageia, KDE Neon
Posts: 369

Original Poster
Blog Entries: 1

Rep: Reputation: 49
It used to work for me for years until I changed my keyboard -_-
The old keyboard had a clear label on the sysrq key,
but not this one,
so I can't tell which one it is.
Thanks to the kernel.org link,
now I know it's the same as the Print Screen key.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'Special' Keyboard Keys on Linux ninjabob7 Linux - Hardware 4 02-20-2006 03:13 PM
Special keyboard keys rdabra Linux - Newbie 3 01-04-2006 05:01 AM
Mapping Keyboard Special Keys(some success at long last) RedShirt SUSE / openSUSE 0 11-13-2005 09:43 PM
Special Function Keys on a Logitech Keyboard linux-rulz Linux - Hardware 2 07-13-2005 07:16 AM
How to get special keys of a keyboard working? TTL_2 Linux - Hardware 5 03-05-2005 04:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration