• Re: X11 and hot-plugged keyboards and multiple layouts

    From Nicolas George@21:1/5 to All on Thu Dec 29 15:00:01 2022
    Nicolas George (12020-02-19):
    ----8<----8<----8<----8<---- xi2watch.c ---->8---->8---->8---->8----

    Hi.

    I am replying to my own mail of three years ago where I explained how to configure X11 to set different layouts on different keyboards and handle hot-plugging without root privileges. Since a standard tool did not
    exist yet, I had attached a small program of mine to do it.

    I have seen this code reproduced on the web, so at least somebody is
    using it. Good.

    Then it might interest you that I have made an extended version of it
    and published it:

    https://gitlab.com/Cigaes/xi2bind

    It has the ability to run a command when a device is plugged or
    unplugged, and now it allows to define keyboard shortcuts attached to
    only a specific keyboard.

    (By the way, do you know a mailing list or website dedicated to
    announcing initial releases of small projects like that?)

    Regards,

    --
    Nicolas George

    -----BEGIN PGP SIGNATURE-----

    iQIzBAEBCgAdFiEE6ooRQGBoNzw0KnwPcZVLI8pNxgwFAmOtnPIACgkQcZVLI8pN xgwB5g//aI1o0a33/JXZpzBI9wTVgBfb7pWK9V2M/gszjQm7laJ9l6X3X1hdc+3v sMIegRUtcdT0f6h5HRn7en8jATz9YdVLiMC434skwvdMXpM0L3IiAd/QALnduJXl +kjN/VyTrLKwrWXFDPVpeGsgW+oKIJ2TWH6/WwllpGFUlGiAATCnUDy7FvH3dNzg PYgppvsGuXxQgOsjOfcSLpIJUzfSuv2wkKM5ZBQ55iDZebfffQ62Mnwu2fniB+rP gAmEo2YsHrJvXx5h82nXctOK4BMukY2L1cm8sSHMkuRLnwevEarF8qCAUByPBL4e 4qaV5T6dqZLf/L30Fhg4dnOFog3OeyLZViJ06EivKnW5hUGFBSx4uFVqDcKgH4iC S9E/ayCIqgRZ3weJtoblqKFyr+KffXdhijU0SlzjU8w/OiyHKUaLp6v0yNOwyGjN YMP+RcoyxLd2DVwi3VpJzZ3z+Yi9P4MHHGO47gB1EjRC+EfRgrxj2QvB2jLABVP5 Or+55vS6smkC5ncIEQgM8jR46RAbYy1JzFXM2q31eMcHoLqcZkvAkqu+4e3CPbIO 2m2ZNhuZkwWPAW1woWEUjiZiJnNuPUlRAUXBqeRI3M+ksqWQIyI6eA3oIDlGR9OF She0opbj2kEN2IeA1Me3ZnvI5gNQOCZuJOpThyKYQ+TY69uKQfg=
    =6099
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anssi Saari@21:1/5 to Nicolas George on Mon Jan 9 23:50:01 2023
    Nicolas George <george@nsup.org> writes:

    Nicolas George (12020-02-19):
    ----8<----8<----8<----8<---- xi2watch.c ---->8---->8---->8---->8----

    Hi.

    I am replying to my own mail of three years ago where I explained how to configure X11 to set different layouts on different keyboards and handle hot-plugging without root privileges. Since a standard tool did not
    exist yet, I had attached a small program of mine to do it.

    Wow. It's exactly what I need since I've started to use a USB switch in
    my home office. Assuming it works for me of course. I've thought about
    writing a udev rule but haven't gotten around to it.

    I've tried to run xmodmap after the keyboard is hot plugged (via telling
    the USB switch to switch) but it's like the xmodmap doesn't take even
    after I added a delay. Although it seems it worked sometimes. Maybe the
    issue is I've tried to run xmodmap from the other computer over ssh, I
    don't know.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas George@21:1/5 to I hope the program I on Tue Jan 10 09:10:01 2023
    Anssi Saari (12023-01-09):
    Wow. It's exactly what I need since I've started to use a USB switch in
    my home office. Assuming it works for me of course. I've thought about writing a udev rule but haven't gotten around to it.

    I hope the program I wrote can help you.

    I've tried to run xmodmap after the keyboard is hot plugged (via telling
    the USB switch to switch) but it's like the xmodmap doesn't take even
    after I added a delay. Although it seems it worked sometimes. Maybe the
    issue is I've tried to run xmodmap from the other computer over ssh, I
    don't know.

    Does the xmodmap effect stay if you run it manually after the keyboard
    is hot-plugged?

    If so, then you probably already something watching for new devices and applying a layout. Maybe your desktop manager, they have a habit of
    ruining simple things.

    If not, then you need to get it to work reliably before you can consider automating it.

    Regards,

    --
    Nicolas George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anssi Saari@21:1/5 to Nicolas George on Sun Jan 15 19:20:01 2023
    Nicolas George <george@nsup.org> writes:

    Does the xmodmap effect stay if you run it manually after the keyboard
    is hot-plugged?

    Yes. I don't have a desktop environment in use on my desktop computer
    either so this should work for me.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anssi Saari@21:1/5 to Nicolas George on Tue Feb 14 13:20:01 2023
    Nicolas George <george@nsup.org> writes:

    Nicolas George (12020-02-19):
    ----8<----8<----8<----8<---- xi2watch.c ---->8---->8---->8---->8----

    Hi.

    I am replying to my own mail of three years ago where I explained how to configure X11 to set different layouts on different keyboards and handle hot-plugging without root privileges. Since a standard tool did not
    exist yet, I had attached a small program of mine to do it.

    I have seen this code reproduced on the web, so at least somebody is
    using it. Good.

    Then it might interest you that I have made an extended version of it
    and published it:

    https://gitlab.com/Cigaes/xi2bind

    I finally gave xi2bind a try, using the hierarchy option to do something
    (run xmodmap) when a keyboard is plugged in. Or in my case, I have a USB
    switch which connects or disconnects a USB hub with my mouse and
    keyboard connected to the hub.

    It works fine but usage was a little baffling and it doesn't help the
    example on how to use the hierarchy command doesn't work due to wrong
    quoting.

    With some work I think I've worked out which event when the keyboard is
    plugged in I should use to run xmodmap, out of the six that happen when
    my keyboard is plugged in. With the mouse and hub the total number of
    events is actually 16!

    For sure it doesn't really matter if xmodmap runs sixteen or six times
    or only once but it feels right.

    So for adding my extra keys to my quite normal US layout keyboard this
    works fine. Unfortunately something weird happens with the modifier keys
    and my extra keys working depend on setting Alt_R to mode_switch and
    that's not something I can automate currently. Nothing to do with
    xi2bind though.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)