1

I want to make a driver for an information panel. One of the planned features is to indicate which terminal is active (the machine is Linux 4.9.x with no GUI or display manager of any kind).

Does there exist a kernel hook or event that triggers upon switching the active tty with Ctrl+Alt+F# (where F# is any function key in the range of F1 to F5) that I could use to send a signal to my driver? Or, alternatively, how could I set up a server to listen for any Ctrl+Alt+F# key combination entered?

0

The currently active tty is given by:

cat /sys/class/tty/tty0/active

You could probably use the inotify(7) API to watch for changes in this file.

  • thanks. I am looking for something lower level, that I could safely and reliably call in a loaded kernel module. – Jebus Feb 15 '18 at 4:36
  • I don't write kernel modules, but sysfs is a filesystem view of kernel structures. /sys/class/tty/tty0/ appears to be a symlink to /sys/devices/virtual/tty/tty0/. If you can access the device structure for tty0, you'll have access to its active member – Fox Feb 15 '18 at 12:04

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.