0

I use Raspbian lite. I'm trying to map a hotkey to start the service or a script. I do not use a graphical user interface, only a text console with a local attached display. I'm not using ssh.

I tried using xbindkeys, but:

> xbindkeys -k
Could not open display, check shell DISPLAY variable, and export or setenv it!

How can I map a key to start a script?

Ingo
  • 42,097
  • 20
  • 85
  • 197

1 Answers1

1

You do not use a graphical user interface (GUI) so I guess you are using Raspbian Stretch Lite. With a default installation of it there is no xbindkeys installed for good reasons. With apt show xbindkeys you will find:

xbindkeys is a program that allows you to launch shell commands with your keyboard or your mouse under the X Window System.

The X Window System is the default GUI on Linux so it is unsurprising that xbindkeys complains it cannot find a DISPLAY for graphical output.

On the default bash shell you can use the builtin command bind. Look for help with help bind. I have found an answer at How to execute a script in shell when a shortcut key is pressed.

Ingo
  • 42,097
  • 20
  • 85
  • 197
  • I tried BIND. He can not bind a button. Power button . maybe there are other ways? – Pasha Geronimo Nov 01 '18 at 19:22
  • @PashaGeronimo So far we only talked about keyboard keys as guessed when you talk about hotkey and xbindkeys. The power button is not a keyboard key so neither xbindkeys nor bind can manage it. What are you trying to do with the power button? Running a script before shutdown? – Ingo Nov 01 '18 at 19:31
  • Ingo, i use this remote link . It work like as keyboard. When i press Power nothing happens (linux not shutdown). I need to map Power some script to button Power. – Pasha Geronimo Nov 02 '18 at 08:41