How to remap keys only for a particular keyboard in Linux?How to prevent xbindkeys from consuming keyboard...

Do living authors still get paid royalties for their old work?

Can sulfuric acid itself be electrolysed?

Is there such a thing as too inconvenient?

Polar contour plot in Mathematica?

Have made several mistakes during the course of my PhD. Can't help but feel resentment. Can I get some advice about how to move forward?

Check disk usage of files returned with spaces

Which basis does the wavefunction collapse to?

Why should care be taken while closing a capacitive circuit?

Why do aircraft leave the cruising altitude long before landing just to circle?

iPad or iPhone doesn't charge until unlocked?

Why was ramjet fuel used as hydraulic fluid during Saturn V checkout?

Gofer work in exchange for Letter of Recommendation

Are there any OR challenges that are similar to kaggle's competitions?

Saying something to a foreign coworker who uses "you people"

Metal that glows when near pieces of itself

Can I check a small array of bools in one go?

How to shade a polygon with curved lines in tikz?

!I!n!s!e!r!t! !b!e!t!w!e!e!n!

Land Registry Clause

Would it be illegal for Facebook to actively promote a political agenda?

Reducing contention in thread-safe LruCache

Using は before 欲しい instead が

Can others monetize my project with GPLv3?

Wristwatches in the cockpit



How to remap keys only for a particular keyboard in Linux?


How to prevent xbindkeys from consuming keyboard messages?How to determine optimal settings for a Synaptic touchpad?How to remap xinput inputs to other keys?How to configure a mouse in linux?Aside from 'xinput' how does linux know to use a touchscreen on startup?How to map extra mice buttons with Linux nicely in 2019?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I have a numpad connected via USB and my goal is to be able to remap keys on that numpad so they can run custom commands or be mapped to other key combinations.



I have this in my .xbindkeysrc file:



~ $ cat .xbindkeysrc
"xte 'keydown Super_L' 'key Left' 'keyup Super_L'"
m:0x10 + c:79 + Release
Mod2 + KP_Home


This remaps the NUM 7 key (which normally prints 7) to Super_L + Left Arrow. That's great and it works, BUT FOR ALL KEYBOARDS, while my goal is to make it work only for the numpad.



Been searching how to do it, but the closest I got was to use xinput set-button-map. Unfortunately, this seems to only work for devices like mouses. I like tried fetching what the button map is for the numpad with xinput get-button-map [device id] but it just prints numbers from 1 to 7 and I definitely have more buttons on my keypad, so it doesn't necessarily make sense.



Any advice?










share|improve this question































    1















    I have a numpad connected via USB and my goal is to be able to remap keys on that numpad so they can run custom commands or be mapped to other key combinations.



    I have this in my .xbindkeysrc file:



    ~ $ cat .xbindkeysrc
    "xte 'keydown Super_L' 'key Left' 'keyup Super_L'"
    m:0x10 + c:79 + Release
    Mod2 + KP_Home


    This remaps the NUM 7 key (which normally prints 7) to Super_L + Left Arrow. That's great and it works, BUT FOR ALL KEYBOARDS, while my goal is to make it work only for the numpad.



    Been searching how to do it, but the closest I got was to use xinput set-button-map. Unfortunately, this seems to only work for devices like mouses. I like tried fetching what the button map is for the numpad with xinput get-button-map [device id] but it just prints numbers from 1 to 7 and I definitely have more buttons on my keypad, so it doesn't necessarily make sense.



    Any advice?










    share|improve this question



























      1












      1








      1








      I have a numpad connected via USB and my goal is to be able to remap keys on that numpad so they can run custom commands or be mapped to other key combinations.



      I have this in my .xbindkeysrc file:



      ~ $ cat .xbindkeysrc
      "xte 'keydown Super_L' 'key Left' 'keyup Super_L'"
      m:0x10 + c:79 + Release
      Mod2 + KP_Home


      This remaps the NUM 7 key (which normally prints 7) to Super_L + Left Arrow. That's great and it works, BUT FOR ALL KEYBOARDS, while my goal is to make it work only for the numpad.



      Been searching how to do it, but the closest I got was to use xinput set-button-map. Unfortunately, this seems to only work for devices like mouses. I like tried fetching what the button map is for the numpad with xinput get-button-map [device id] but it just prints numbers from 1 to 7 and I definitely have more buttons on my keypad, so it doesn't necessarily make sense.



      Any advice?










      share|improve this question














      I have a numpad connected via USB and my goal is to be able to remap keys on that numpad so they can run custom commands or be mapped to other key combinations.



      I have this in my .xbindkeysrc file:



      ~ $ cat .xbindkeysrc
      "xte 'keydown Super_L' 'key Left' 'keyup Super_L'"
      m:0x10 + c:79 + Release
      Mod2 + KP_Home


      This remaps the NUM 7 key (which normally prints 7) to Super_L + Left Arrow. That's great and it works, BUT FOR ALL KEYBOARDS, while my goal is to make it work only for the numpad.



      Been searching how to do it, but the closest I got was to use xinput set-button-map. Unfortunately, this seems to only work for devices like mouses. I like tried fetching what the button map is for the numpad with xinput get-button-map [device id] but it just prints numbers from 1 to 7 and I definitely have more buttons on my keypad, so it doesn't necessarily make sense.



      Any advice?







      xinput xbindkeys xte






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 days ago









      snitkosnitko

      1314 bronze badges




      1314 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0














          setxkbmap has the option to target a specific device (keyboard).



          So you need to find the deviceID first, using xinput list



          $ xinput list

          ⎣ Virtual core keyboard
          ...
          ↳ USB Keyboard id=19 [slave keyboard (3)]


          Then query the setxkbmap config to see your device settings (I will use '19'):



          $ setxkbmap -device 19 -print
          xkb_keymap {
          xkb_keycodes { include "evdev+aliases(qwerty)" };
          xkb_types { include "complete" };
          xkb_compat { include "complete" };
          xkb_symbols { include "pc+us(euro)+us(intl):2+inet(evdev)" };
          xkb_geometry { include "pc(pc105)" };
          };


          The symbols is what we're looking for; these can be found in ls /usr/share/X11/xkb/symbols. The arguments refer to a subsection in the file, for example xkb_symbols "intl" {




          To add any of the available options like for example, rupeesign, you
          could do setxkbmap -device 19 -option rupeesign:4



          to reset the options, use setxkbmap -device 19 -option without further arguments.




          However, you want some custom configuration, and that is a bit more tricky, because simply adding a custom file in that folder and using it does not work.



          So create some folders and create a tempfile with the current config.



          mkdir -p ~/.config/xkb/symbols
          cd ~/.config/xkb
          setxkbmap -device 19 -print > tempfile.txt
          touch symbols/mysymbol


          Edit tempfile.txt so it contains mysymbol(mymapping)



          ...
          xkb_symbols { include "pc+us(euro)+us(intl):2+inet(evdev)+mysymbol(mymapping)"


          Edit symbol/mysymbol any way you want, see /usr/share/X11/xkb/symbols for examples.
          This one adds a Bitcoin symbol to num 7 key .



          partial
          xkb_symbols "mymapping" {
          key <AE07> { [ 7, &, U20BF ] };

          };


          Now, finally, to activate this mapping, use xkbcomp ( note -i 19 to set the device)



          xkbcomp -i 19 -I$HOME/.config/xkb tempfile.txt $DISPLAY


          (This will probably show some warning messages, but it still works)






          share|improve this answer




























          • No need for creating all those dirs - xkbcomp works in both directions; simply xkbcomp -i 19 $DISPLAY foo.xkb, edit foo.xkb, xkbcomp -i 19 foo.xkb $DISPLAY should do. It even works in a single shot xkbcomp -i dev $DISPLAY - | some_filter | xkbcomp -i dev - $DISPLAY, though the xkb format is too "structured" for awk or sed.

            – mosvy
            yesterday













          • @mosvy you're right, that returns the full layout (~2000lines), but might not be as easy to edit for anyone new to the format.

            – Alex
            yesterday














          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535853%2fhow-to-remap-keys-only-for-a-particular-keyboard-in-linux%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          setxkbmap has the option to target a specific device (keyboard).



          So you need to find the deviceID first, using xinput list



          $ xinput list

          ⎣ Virtual core keyboard
          ...
          ↳ USB Keyboard id=19 [slave keyboard (3)]


          Then query the setxkbmap config to see your device settings (I will use '19'):



          $ setxkbmap -device 19 -print
          xkb_keymap {
          xkb_keycodes { include "evdev+aliases(qwerty)" };
          xkb_types { include "complete" };
          xkb_compat { include "complete" };
          xkb_symbols { include "pc+us(euro)+us(intl):2+inet(evdev)" };
          xkb_geometry { include "pc(pc105)" };
          };


          The symbols is what we're looking for; these can be found in ls /usr/share/X11/xkb/symbols. The arguments refer to a subsection in the file, for example xkb_symbols "intl" {




          To add any of the available options like for example, rupeesign, you
          could do setxkbmap -device 19 -option rupeesign:4



          to reset the options, use setxkbmap -device 19 -option without further arguments.




          However, you want some custom configuration, and that is a bit more tricky, because simply adding a custom file in that folder and using it does not work.



          So create some folders and create a tempfile with the current config.



          mkdir -p ~/.config/xkb/symbols
          cd ~/.config/xkb
          setxkbmap -device 19 -print > tempfile.txt
          touch symbols/mysymbol


          Edit tempfile.txt so it contains mysymbol(mymapping)



          ...
          xkb_symbols { include "pc+us(euro)+us(intl):2+inet(evdev)+mysymbol(mymapping)"


          Edit symbol/mysymbol any way you want, see /usr/share/X11/xkb/symbols for examples.
          This one adds a Bitcoin symbol to num 7 key .



          partial
          xkb_symbols "mymapping" {
          key <AE07> { [ 7, &, U20BF ] };

          };


          Now, finally, to activate this mapping, use xkbcomp ( note -i 19 to set the device)



          xkbcomp -i 19 -I$HOME/.config/xkb tempfile.txt $DISPLAY


          (This will probably show some warning messages, but it still works)






          share|improve this answer




























          • No need for creating all those dirs - xkbcomp works in both directions; simply xkbcomp -i 19 $DISPLAY foo.xkb, edit foo.xkb, xkbcomp -i 19 foo.xkb $DISPLAY should do. It even works in a single shot xkbcomp -i dev $DISPLAY - | some_filter | xkbcomp -i dev - $DISPLAY, though the xkb format is too "structured" for awk or sed.

            – mosvy
            yesterday













          • @mosvy you're right, that returns the full layout (~2000lines), but might not be as easy to edit for anyone new to the format.

            – Alex
            yesterday
















          0














          setxkbmap has the option to target a specific device (keyboard).



          So you need to find the deviceID first, using xinput list



          $ xinput list

          ⎣ Virtual core keyboard
          ...
          ↳ USB Keyboard id=19 [slave keyboard (3)]


          Then query the setxkbmap config to see your device settings (I will use '19'):



          $ setxkbmap -device 19 -print
          xkb_keymap {
          xkb_keycodes { include "evdev+aliases(qwerty)" };
          xkb_types { include "complete" };
          xkb_compat { include "complete" };
          xkb_symbols { include "pc+us(euro)+us(intl):2+inet(evdev)" };
          xkb_geometry { include "pc(pc105)" };
          };


          The symbols is what we're looking for; these can be found in ls /usr/share/X11/xkb/symbols. The arguments refer to a subsection in the file, for example xkb_symbols "intl" {




          To add any of the available options like for example, rupeesign, you
          could do setxkbmap -device 19 -option rupeesign:4



          to reset the options, use setxkbmap -device 19 -option without further arguments.




          However, you want some custom configuration, and that is a bit more tricky, because simply adding a custom file in that folder and using it does not work.



          So create some folders and create a tempfile with the current config.



          mkdir -p ~/.config/xkb/symbols
          cd ~/.config/xkb
          setxkbmap -device 19 -print > tempfile.txt
          touch symbols/mysymbol


          Edit tempfile.txt so it contains mysymbol(mymapping)



          ...
          xkb_symbols { include "pc+us(euro)+us(intl):2+inet(evdev)+mysymbol(mymapping)"


          Edit symbol/mysymbol any way you want, see /usr/share/X11/xkb/symbols for examples.
          This one adds a Bitcoin symbol to num 7 key .



          partial
          xkb_symbols "mymapping" {
          key <AE07> { [ 7, &, U20BF ] };

          };


          Now, finally, to activate this mapping, use xkbcomp ( note -i 19 to set the device)



          xkbcomp -i 19 -I$HOME/.config/xkb tempfile.txt $DISPLAY


          (This will probably show some warning messages, but it still works)






          share|improve this answer




























          • No need for creating all those dirs - xkbcomp works in both directions; simply xkbcomp -i 19 $DISPLAY foo.xkb, edit foo.xkb, xkbcomp -i 19 foo.xkb $DISPLAY should do. It even works in a single shot xkbcomp -i dev $DISPLAY - | some_filter | xkbcomp -i dev - $DISPLAY, though the xkb format is too "structured" for awk or sed.

            – mosvy
            yesterday













          • @mosvy you're right, that returns the full layout (~2000lines), but might not be as easy to edit for anyone new to the format.

            – Alex
            yesterday














          0












          0








          0







          setxkbmap has the option to target a specific device (keyboard).



          So you need to find the deviceID first, using xinput list



          $ xinput list

          ⎣ Virtual core keyboard
          ...
          ↳ USB Keyboard id=19 [slave keyboard (3)]


          Then query the setxkbmap config to see your device settings (I will use '19'):



          $ setxkbmap -device 19 -print
          xkb_keymap {
          xkb_keycodes { include "evdev+aliases(qwerty)" };
          xkb_types { include "complete" };
          xkb_compat { include "complete" };
          xkb_symbols { include "pc+us(euro)+us(intl):2+inet(evdev)" };
          xkb_geometry { include "pc(pc105)" };
          };


          The symbols is what we're looking for; these can be found in ls /usr/share/X11/xkb/symbols. The arguments refer to a subsection in the file, for example xkb_symbols "intl" {




          To add any of the available options like for example, rupeesign, you
          could do setxkbmap -device 19 -option rupeesign:4



          to reset the options, use setxkbmap -device 19 -option without further arguments.




          However, you want some custom configuration, and that is a bit more tricky, because simply adding a custom file in that folder and using it does not work.



          So create some folders and create a tempfile with the current config.



          mkdir -p ~/.config/xkb/symbols
          cd ~/.config/xkb
          setxkbmap -device 19 -print > tempfile.txt
          touch symbols/mysymbol


          Edit tempfile.txt so it contains mysymbol(mymapping)



          ...
          xkb_symbols { include "pc+us(euro)+us(intl):2+inet(evdev)+mysymbol(mymapping)"


          Edit symbol/mysymbol any way you want, see /usr/share/X11/xkb/symbols for examples.
          This one adds a Bitcoin symbol to num 7 key .



          partial
          xkb_symbols "mymapping" {
          key <AE07> { [ 7, &, U20BF ] };

          };


          Now, finally, to activate this mapping, use xkbcomp ( note -i 19 to set the device)



          xkbcomp -i 19 -I$HOME/.config/xkb tempfile.txt $DISPLAY


          (This will probably show some warning messages, but it still works)






          share|improve this answer















          setxkbmap has the option to target a specific device (keyboard).



          So you need to find the deviceID first, using xinput list



          $ xinput list

          ⎣ Virtual core keyboard
          ...
          ↳ USB Keyboard id=19 [slave keyboard (3)]


          Then query the setxkbmap config to see your device settings (I will use '19'):



          $ setxkbmap -device 19 -print
          xkb_keymap {
          xkb_keycodes { include "evdev+aliases(qwerty)" };
          xkb_types { include "complete" };
          xkb_compat { include "complete" };
          xkb_symbols { include "pc+us(euro)+us(intl):2+inet(evdev)" };
          xkb_geometry { include "pc(pc105)" };
          };


          The symbols is what we're looking for; these can be found in ls /usr/share/X11/xkb/symbols. The arguments refer to a subsection in the file, for example xkb_symbols "intl" {




          To add any of the available options like for example, rupeesign, you
          could do setxkbmap -device 19 -option rupeesign:4



          to reset the options, use setxkbmap -device 19 -option without further arguments.




          However, you want some custom configuration, and that is a bit more tricky, because simply adding a custom file in that folder and using it does not work.



          So create some folders and create a tempfile with the current config.



          mkdir -p ~/.config/xkb/symbols
          cd ~/.config/xkb
          setxkbmap -device 19 -print > tempfile.txt
          touch symbols/mysymbol


          Edit tempfile.txt so it contains mysymbol(mymapping)



          ...
          xkb_symbols { include "pc+us(euro)+us(intl):2+inet(evdev)+mysymbol(mymapping)"


          Edit symbol/mysymbol any way you want, see /usr/share/X11/xkb/symbols for examples.
          This one adds a Bitcoin symbol to num 7 key .



          partial
          xkb_symbols "mymapping" {
          key <AE07> { [ 7, &, U20BF ] };

          };


          Now, finally, to activate this mapping, use xkbcomp ( note -i 19 to set the device)



          xkbcomp -i 19 -I$HOME/.config/xkb tempfile.txt $DISPLAY


          (This will probably show some warning messages, but it still works)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited yesterday

























          answered yesterday









          AlexAlex

          1285 bronze badges




          1285 bronze badges
















          • No need for creating all those dirs - xkbcomp works in both directions; simply xkbcomp -i 19 $DISPLAY foo.xkb, edit foo.xkb, xkbcomp -i 19 foo.xkb $DISPLAY should do. It even works in a single shot xkbcomp -i dev $DISPLAY - | some_filter | xkbcomp -i dev - $DISPLAY, though the xkb format is too "structured" for awk or sed.

            – mosvy
            yesterday













          • @mosvy you're right, that returns the full layout (~2000lines), but might not be as easy to edit for anyone new to the format.

            – Alex
            yesterday



















          • No need for creating all those dirs - xkbcomp works in both directions; simply xkbcomp -i 19 $DISPLAY foo.xkb, edit foo.xkb, xkbcomp -i 19 foo.xkb $DISPLAY should do. It even works in a single shot xkbcomp -i dev $DISPLAY - | some_filter | xkbcomp -i dev - $DISPLAY, though the xkb format is too "structured" for awk or sed.

            – mosvy
            yesterday













          • @mosvy you're right, that returns the full layout (~2000lines), but might not be as easy to edit for anyone new to the format.

            – Alex
            yesterday

















          No need for creating all those dirs - xkbcomp works in both directions; simply xkbcomp -i 19 $DISPLAY foo.xkb, edit foo.xkb, xkbcomp -i 19 foo.xkb $DISPLAY should do. It even works in a single shot xkbcomp -i dev $DISPLAY - | some_filter | xkbcomp -i dev - $DISPLAY, though the xkb format is too "structured" for awk or sed.

          – mosvy
          yesterday







          No need for creating all those dirs - xkbcomp works in both directions; simply xkbcomp -i 19 $DISPLAY foo.xkb, edit foo.xkb, xkbcomp -i 19 foo.xkb $DISPLAY should do. It even works in a single shot xkbcomp -i dev $DISPLAY - | some_filter | xkbcomp -i dev - $DISPLAY, though the xkb format is too "structured" for awk or sed.

          – mosvy
          yesterday















          @mosvy you're right, that returns the full layout (~2000lines), but might not be as easy to edit for anyone new to the format.

          – Alex
          yesterday





          @mosvy you're right, that returns the full layout (~2000lines), but might not be as easy to edit for anyone new to the format.

          – Alex
          yesterday


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f535853%2fhow-to-remap-keys-only-for-a-particular-keyboard-in-linux%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

          Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

          Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...