X
X
xverizex2020-07-08 19:42:09
linux
xverizex, 2020-07-08 19:42:09

How to assign an action to a key in the console?

I have an ubuntu server without X. I take pictures with fbgrab. I would like to set the print screen key to an action, for example, a bash script, so that the script is executed when pressed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2020-07-09
@saboteur_kiev

man bind
I'm not sure about the printscreen.
I don’t remember when I was sitting at the iron console, but it may simply not be transmitted via ssh.
create a function, hang it for example on Ctrl+p :

$ function hello_world
{
  echo "Hello world"
}
$ bind -x '"\C-p":hello_world'

and just press Ctrl+p
for permanent access write it in .bashrc or .profile

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question