从bash脚本检测Ubuntu键盘

前端之家收集整理的这篇文章主要介绍了从bash脚本检测Ubuntu键盘前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
请原谅我对 Linux OS /硬件问题的无知……我只是一个程序员:)

我有一个应用程序调用一些bash脚本来启动外部应用程序,在这种情况下是Firefox.该应用程序在具有触摸屏功能的信息亭上运行.启动Firefox时,我还启动了一个虚拟键盘应用程序,允许用户输入键盘.

但是,自助服务终端还具有PS / 2和USB插槽,允许用户插入键盘.如果插入了键盘,如果我不必启动虚拟键盘并为Firefox窗口提供更多屏幕空间,那就太好了.

有没有办法让我检测是否从bash脚本插入了键盘?它会显示在/ dev中,如果是,它会显示在一致的位置吗?如果用户使用PS / 2或USB键盘会有所不同吗?

谢谢!

@H_404_12@ 对于USB设备,您可以使用lsusb并使用键盘协议(接口协议1)搜索人机接口设备(接口类3),例如,
  1. $lsusb -v
  2. ... loads of stuff deleted ...
  3. Interface Descriptor:
  4. bLength 9
  5. bDescriptorType 4
  6. bInterfaceNumber 0
  7. bAlternateSetting 0
  8. bNumEndpoints 1
  9. bInterfaceClass 3 Human Interface Device
  10. bInterfaceSubClass 1 Boot Interface Subclass
  11. bInterfaceProtocol 1 Keyboard
  12. iInterface 0
  13. ... loads of stuff deleted ...

另外,你可以让udev帮助你.列出/ dev / input / by-path /下的设备,键盘设备以-kdb结尾(至少在Ubuntu中,udev规则指定它),例如

  1. $ls -l /dev/input/by-path/*-kbd
  2. lrwxrwxrwx 1 root root 9 2010-03-25 09:14 /dev/input/by-path/pci-0000:00:1a.2-usb-0:1:1.0-event-kbd -> ../event4
  3.  
  4. $ls -l /dev/input/by-path/*-kbd
  5. lrwxrwxrwx 1 root root 9 2009-08-29 09:46 /dev/input/by-path/platform-i8042-serio-0-event-kbd -> ../event1

猜你在找的Bash相关文章