Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Jan 2020 08:40:41 +0000
From:      Kralj Karlo <karlo@klarinet.osamsb.hr>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Read usage codes from a specific USB keyboard
Message-ID:  <20200126084044.252483067415@mailuser.nyi.internal>

next in thread | raw e-mail | index | archive | help
How can I do this?

1. Prevent X from using a specific USB keyboard.
   (I can identify the keyboard by name or by device.)
2. In a different program, read usage codes coming from that specific
   keyboard.

In case that is not clear, here is some context. I have a keyboard
next to my bed. When I press a button on the keyboard, my computer plays
the time, out of the speakers. This way, I can determine what time it is
without turning on the lights and without maintaining a separate clock.
This is the only purpose of the keyboard.

The present implementation is with xbindkeys. The xbindkeysrc looks like
this.

  "speak-date" 
    KP_0

  "speak-date" 
    KP_1

  "speak-date" 
    KP_2

  "speak-date"
    KP_3

  "speak-date"
    KP_4

  "speak-date"
    KP_5

  "speak-date"
    KP_6

  "speak-date"
    KP_7

  "speak-date"
    KP_8

  "speak-date"
    KP_9

  "speak-date"
    KP_Delete

  "speak-date"
    KP_Add

  "speak-date"
    KP_Subtract

  "speak-date"
    KP_Multiply

  "speak-date" 
    KP_Divide

  "speak-date"
    KP_Enter

The attached keyboard is a number pad, and I don't use a number pad
otherwise, so it is fine for me to assign all of these keys in
xbindkeys. But there is still a problem with this approach: If I lock
my screen with slock, then the keypresses are not sent to xbindkeys,
so I can't check the time.

I would like to configure my computer so that presses of this keyboard
are ignored by X and so that I can read the presses in a separate
program that just watches for keypresses and runs speak-date when it
receives them.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200126084044.252483067415>