Can I launch macros and shortcuts from a second keyboard on Linux?Keyboard macros for X and/or KDEVim markers and macrossecond keyboard to run commandsChange global keyboard shortcutsScientific Linux 6 assigning keyboard shortcutsCan mutt macros obtain properties from the current message?Which module in a Linux distribution is responsible for keyboard shortcuts?How to enable monitor brightness keyboard shortcuts on Samsung 90X3A?Shortcuts for different keyboard languagesWhere are the Linux Mint xfce keyboard shortcuts saved?
How do I create uniquely male characters?
How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)
Patience, young "Padovan"
How can bays and straits be determined in a procedurally generated map?
The use of multiple foreign keys on same column in SQL Server
Prevent a directory in /tmp from being deleted
Can an x86 CPU running in real mode be considered to be basically an 8086 CPU?
black dwarf stars and dark matter
New order #4: World
Set-theoretical foundations of Mathematics with only bounded quantifiers
How to make payment on the internet without leaving a money trail?
Example of a relative pronoun
Why is "Reports" in sentence down without "The"
N.B. ligature in Latex
Are tax years 2016 & 2017 back taxes deductible for tax year 2018?
How is this relation reflexive?
Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)
Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?
Copycat chess is back
A function which translates a sentence to title-case
Possibly bubble sort algorithm
Extreme, but not acceptable situation and I can't start the work tomorrow morning
How much RAM could one put in a typical 80386 setup?
I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine
Can I launch macros and shortcuts from a second keyboard on Linux?
Keyboard macros for X and/or KDEVim markers and macrossecond keyboard to run commandsChange global keyboard shortcutsScientific Linux 6 assigning keyboard shortcutsCan mutt macros obtain properties from the current message?Which module in a Linux distribution is responsible for keyboard shortcuts?How to enable monitor brightness keyboard shortcuts on Samsung 90X3A?Shortcuts for different keyboard languagesWhere are the Linux Mint xfce keyboard shortcuts saved?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a small numpad keyboard which I would like to use for launching macros and shortcuts, along side my regular keyboard. I can attach macros and shortcuts to these keys (i.e, numpad 1 minimises the active window), but my primary keyboard numpad also activates the shortcut.
I would like a way to have the secondary keyboard act completely separately and to then attach shortcuts to it.
Here is the output I get from xinput
.
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ LVT Recon gaming mouse id=10 [slave pointer (2)]
⎜ ↳ LVT Recon gaming mouse id=11 [slave pointer (2)]
⎜ ↳ Corsair Corsair K30A Gaming Keyboard id=13 [slave pointer (2)]
⎜ ↳ SIGMACHIP USB Keyboard id=18 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=12 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=14 [slave keyboard (3)]
↳ LVT Recon gaming mouse id=15 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=16 [slave keyboard (3)]
↳ SIGMACHIP USB Keyboard id=17 [slave keyboard (3)]
↳ SIGMACHIP USB Keyboard id=19 [slave keyboard (3)]
keyboard-shortcuts keyboard macro
add a comment |
I have a small numpad keyboard which I would like to use for launching macros and shortcuts, along side my regular keyboard. I can attach macros and shortcuts to these keys (i.e, numpad 1 minimises the active window), but my primary keyboard numpad also activates the shortcut.
I would like a way to have the secondary keyboard act completely separately and to then attach shortcuts to it.
Here is the output I get from xinput
.
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ LVT Recon gaming mouse id=10 [slave pointer (2)]
⎜ ↳ LVT Recon gaming mouse id=11 [slave pointer (2)]
⎜ ↳ Corsair Corsair K30A Gaming Keyboard id=13 [slave pointer (2)]
⎜ ↳ SIGMACHIP USB Keyboard id=18 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=12 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=14 [slave keyboard (3)]
↳ LVT Recon gaming mouse id=15 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=16 [slave keyboard (3)]
↳ SIGMACHIP USB Keyboard id=17 [slave keyboard (3)]
↳ SIGMACHIP USB Keyboard id=19 [slave keyboard (3)]
keyboard-shortcuts keyboard macro
Interesting question! I look forward to what others can come up with. Welome to UNIX & Linux Stack Exchange.
– 0xSheepdog
Mar 27 at 17:56
add a comment |
I have a small numpad keyboard which I would like to use for launching macros and shortcuts, along side my regular keyboard. I can attach macros and shortcuts to these keys (i.e, numpad 1 minimises the active window), but my primary keyboard numpad also activates the shortcut.
I would like a way to have the secondary keyboard act completely separately and to then attach shortcuts to it.
Here is the output I get from xinput
.
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ LVT Recon gaming mouse id=10 [slave pointer (2)]
⎜ ↳ LVT Recon gaming mouse id=11 [slave pointer (2)]
⎜ ↳ Corsair Corsair K30A Gaming Keyboard id=13 [slave pointer (2)]
⎜ ↳ SIGMACHIP USB Keyboard id=18 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=12 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=14 [slave keyboard (3)]
↳ LVT Recon gaming mouse id=15 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=16 [slave keyboard (3)]
↳ SIGMACHIP USB Keyboard id=17 [slave keyboard (3)]
↳ SIGMACHIP USB Keyboard id=19 [slave keyboard (3)]
keyboard-shortcuts keyboard macro
I have a small numpad keyboard which I would like to use for launching macros and shortcuts, along side my regular keyboard. I can attach macros and shortcuts to these keys (i.e, numpad 1 minimises the active window), but my primary keyboard numpad also activates the shortcut.
I would like a way to have the secondary keyboard act completely separately and to then attach shortcuts to it.
Here is the output I get from xinput
.
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ LVT Recon gaming mouse id=10 [slave pointer (2)]
⎜ ↳ LVT Recon gaming mouse id=11 [slave pointer (2)]
⎜ ↳ Corsair Corsair K30A Gaming Keyboard id=13 [slave pointer (2)]
⎜ ↳ SIGMACHIP USB Keyboard id=18 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=12 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=14 [slave keyboard (3)]
↳ LVT Recon gaming mouse id=15 [slave keyboard (3)]
↳ Corsair Corsair K30A Gaming Keyboard id=16 [slave keyboard (3)]
↳ SIGMACHIP USB Keyboard id=17 [slave keyboard (3)]
↳ SIGMACHIP USB Keyboard id=19 [slave keyboard (3)]
keyboard-shortcuts keyboard macro
keyboard-shortcuts keyboard macro
asked Mar 27 at 14:21
umbro_tracksuitumbro_tracksuit
183
183
Interesting question! I look forward to what others can come up with. Welome to UNIX & Linux Stack Exchange.
– 0xSheepdog
Mar 27 at 17:56
add a comment |
Interesting question! I look forward to what others can come up with. Welome to UNIX & Linux Stack Exchange.
– 0xSheepdog
Mar 27 at 17:56
Interesting question! I look forward to what others can come up with. Welome to UNIX & Linux Stack Exchange.
– 0xSheepdog
Mar 27 at 17:56
Interesting question! I look forward to what others can come up with. Welome to UNIX & Linux Stack Exchange.
– 0xSheepdog
Mar 27 at 17:56
add a comment |
2 Answers
2
active
oldest
votes
While my other answer will probably work on most Linuxes, even if they're many years old, SystemD and udev actually makes things easier:
use
lsusb
to find the vendor and product code of your additional keyboard. (In my case, it's Vendor 145F, Product 0177. Make sure to have the letters in uppercase.)create a file
/etc/udev/hwdb.d/90-extra-keyboard.hwdb
, with contents similar to this:
evdev:input:b0003v145Fp0177*
KEYBOARD_KEY_7005b=stopcd
The first line identifies the device: the four letters after the v is the vendor code, after the p, it's the product code, from the previous step. Every further line maps a scancode to a symbolic name. To get the scancode, run evtest
:
Event: time 1553711252.888538, -------------- SYN_REPORT ------------
Event: time 1553711257.656558, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70059
Event: time 1553711257.656558, type 1 (EV_KEY), code 79 (KEY_KP1), value 1
To find out what to use for the symbolic name, look at the list of #define KEY_…
lines in /usr/include/linux/input-event-codes.h
:
#define KEY_PLAYPAUSE 164
#define KEY_PREVIOUSSONG 165
#define KEY_STOPCD 166
#define KEY_RECORD 167
re-build and load internal databases by running
systemd-hwdb update; udevadm trigger
verify the new settings work by running
evtest
again, or by assigning shortcuts in your settings.
When trying this out in applications, just remember that if your desktop environment already uses that shortcut, the application won't even see the keypress.
Hi, I had another go at this method and managed to remap all the keys! They're now all sending extra function keys!
– umbro_tracksuit
Mar 29 at 8:26
add a comment |
In principle, yes. When I last did this in 2012, the way to go was to try and tell Linux that the second keyboard is very weird and really means XF86VolumeUp when it sends the keypress for Num 1, or whatever. Fortunately, there's quite a few keycodes that don't exist on standard keyboards that you can use in this way.
Let's run through this for a single key:
- use
xev | grep -i key
to find the keycodes of the keys on your extra keyboard. I'll just do keypap 9, as an example, with keycode 81. (NB: my extra keypad has a key labeled "00" but that sends "0" twice, I have no idea how to handle that.)
KeyPress event, serial 38, synthetic NO, window 0x4400001,
state 0x10, keycode 81 (keysym 0xffb9, KP_9), same_screen YES,
KeyRelease event, serial 39, synthetic NO, window 0x4400001,
state 0x10, keycode 81 (keysym 0xffb9, KP_9), same_screen YES,
request MappingKeyboard, first_keycode 8, count 248
- check
setxkbmap -query
for the rules of your (main) keyboard. We'll try to turn your extra keyboard into a dozen or so media keys on that layout. For me, it's
rules: evdev
model: pc105
layout: de
variant: nodeadkeys
- find enough entries in
/usr/share/X11/xkb/symbols/inet
. The right-hand side is what the application will see, possibly with shift key modifiers etc., the left-hand side are scancodes. I'll pick this one, because my keyboard doesn't have a "calculator" key:
key <I148> [ XF86Calculator ] ;
- create a file in
/usr/share/X11/xkb/keycodes/
that maps scancodes to keycodes (from the first step). Yes, this seems backwards. My file is named trustkeypad and looks like this:
default xkb_keycodes "trustkeypad"
minimum= 8;
maximum= 255;
// keypad 9
<I148> = 81;
;
compile this file with
xkbcomp -xkb trustkeypad
try it out with
setxkbmap -v -v -device 17 -keycodes (filename)
. (The 17 is the id from yourxinput
.) The result for me looks like this:
Warning! Multiple definitions of keycodes
Using command line, ignoring rules file
Applied rules from evdev:
rules: evdev
model: pc105
layout: de
variant: nodeadkeys
Trying to build keymap using the following components:
keycodes: trustkeypad
types: complete
compat: complete
symbols: pc+de(nodeadkeys)+inet(evdev)
geometry: pc(pc105)
and that looks good, in particular, the keycodes line.
If you run xev
now, you should see the new symbols being generated. Alas, I get only a half-victory right now:
KeyPress event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043275, (1666,897), root:(1670,950),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043403, (1666,897), root:(1670,950),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043403, (1666,897), root:(1670,950),
state 0x10, keycode 77 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043411, (1666,897), root:(1670,950),
state 0x10, keycode 77 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
but after I crashed X a couple of times by accident (do not think that setting the minimum value in the keycodes file higher will help), that went away. Maybe a simple reboot can help at this point. After you're successful, you should only get something like
KeyPress event, serial 38, synthetic NO, window 0x3e00001,
root 0x168, subw 0x0, time 26443862, (930,972), root:(934,1025),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x3e00001,
root 0x168, subw 0x0, time 26444022, (930,972), root:(934,1025),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
and you can verify in your user settings that you can now assign a shortcut to this key, and it will say it's assigned to the Calculator key.
Still missing here: figuring out how to make this the standard setting, also across reboots. This will probably involve looking at udev, and https://help.ubuntu.com/community/Custom%20keyboard%20layout%20definitions might be useful, even though it has an "outdated" tag dating from 2014.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509000%2fcan-i-launch-macros-and-shortcuts-from-a-second-keyboard-on-linux%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
While my other answer will probably work on most Linuxes, even if they're many years old, SystemD and udev actually makes things easier:
use
lsusb
to find the vendor and product code of your additional keyboard. (In my case, it's Vendor 145F, Product 0177. Make sure to have the letters in uppercase.)create a file
/etc/udev/hwdb.d/90-extra-keyboard.hwdb
, with contents similar to this:
evdev:input:b0003v145Fp0177*
KEYBOARD_KEY_7005b=stopcd
The first line identifies the device: the four letters after the v is the vendor code, after the p, it's the product code, from the previous step. Every further line maps a scancode to a symbolic name. To get the scancode, run evtest
:
Event: time 1553711252.888538, -------------- SYN_REPORT ------------
Event: time 1553711257.656558, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70059
Event: time 1553711257.656558, type 1 (EV_KEY), code 79 (KEY_KP1), value 1
To find out what to use for the symbolic name, look at the list of #define KEY_…
lines in /usr/include/linux/input-event-codes.h
:
#define KEY_PLAYPAUSE 164
#define KEY_PREVIOUSSONG 165
#define KEY_STOPCD 166
#define KEY_RECORD 167
re-build and load internal databases by running
systemd-hwdb update; udevadm trigger
verify the new settings work by running
evtest
again, or by assigning shortcuts in your settings.
When trying this out in applications, just remember that if your desktop environment already uses that shortcut, the application won't even see the keypress.
Hi, I had another go at this method and managed to remap all the keys! They're now all sending extra function keys!
– umbro_tracksuit
Mar 29 at 8:26
add a comment |
While my other answer will probably work on most Linuxes, even if they're many years old, SystemD and udev actually makes things easier:
use
lsusb
to find the vendor and product code of your additional keyboard. (In my case, it's Vendor 145F, Product 0177. Make sure to have the letters in uppercase.)create a file
/etc/udev/hwdb.d/90-extra-keyboard.hwdb
, with contents similar to this:
evdev:input:b0003v145Fp0177*
KEYBOARD_KEY_7005b=stopcd
The first line identifies the device: the four letters after the v is the vendor code, after the p, it's the product code, from the previous step. Every further line maps a scancode to a symbolic name. To get the scancode, run evtest
:
Event: time 1553711252.888538, -------------- SYN_REPORT ------------
Event: time 1553711257.656558, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70059
Event: time 1553711257.656558, type 1 (EV_KEY), code 79 (KEY_KP1), value 1
To find out what to use for the symbolic name, look at the list of #define KEY_…
lines in /usr/include/linux/input-event-codes.h
:
#define KEY_PLAYPAUSE 164
#define KEY_PREVIOUSSONG 165
#define KEY_STOPCD 166
#define KEY_RECORD 167
re-build and load internal databases by running
systemd-hwdb update; udevadm trigger
verify the new settings work by running
evtest
again, or by assigning shortcuts in your settings.
When trying this out in applications, just remember that if your desktop environment already uses that shortcut, the application won't even see the keypress.
Hi, I had another go at this method and managed to remap all the keys! They're now all sending extra function keys!
– umbro_tracksuit
Mar 29 at 8:26
add a comment |
While my other answer will probably work on most Linuxes, even if they're many years old, SystemD and udev actually makes things easier:
use
lsusb
to find the vendor and product code of your additional keyboard. (In my case, it's Vendor 145F, Product 0177. Make sure to have the letters in uppercase.)create a file
/etc/udev/hwdb.d/90-extra-keyboard.hwdb
, with contents similar to this:
evdev:input:b0003v145Fp0177*
KEYBOARD_KEY_7005b=stopcd
The first line identifies the device: the four letters after the v is the vendor code, after the p, it's the product code, from the previous step. Every further line maps a scancode to a symbolic name. To get the scancode, run evtest
:
Event: time 1553711252.888538, -------------- SYN_REPORT ------------
Event: time 1553711257.656558, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70059
Event: time 1553711257.656558, type 1 (EV_KEY), code 79 (KEY_KP1), value 1
To find out what to use for the symbolic name, look at the list of #define KEY_…
lines in /usr/include/linux/input-event-codes.h
:
#define KEY_PLAYPAUSE 164
#define KEY_PREVIOUSSONG 165
#define KEY_STOPCD 166
#define KEY_RECORD 167
re-build and load internal databases by running
systemd-hwdb update; udevadm trigger
verify the new settings work by running
evtest
again, or by assigning shortcuts in your settings.
When trying this out in applications, just remember that if your desktop environment already uses that shortcut, the application won't even see the keypress.
While my other answer will probably work on most Linuxes, even if they're many years old, SystemD and udev actually makes things easier:
use
lsusb
to find the vendor and product code of your additional keyboard. (In my case, it's Vendor 145F, Product 0177. Make sure to have the letters in uppercase.)create a file
/etc/udev/hwdb.d/90-extra-keyboard.hwdb
, with contents similar to this:
evdev:input:b0003v145Fp0177*
KEYBOARD_KEY_7005b=stopcd
The first line identifies the device: the four letters after the v is the vendor code, after the p, it's the product code, from the previous step. Every further line maps a scancode to a symbolic name. To get the scancode, run evtest
:
Event: time 1553711252.888538, -------------- SYN_REPORT ------------
Event: time 1553711257.656558, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70059
Event: time 1553711257.656558, type 1 (EV_KEY), code 79 (KEY_KP1), value 1
To find out what to use for the symbolic name, look at the list of #define KEY_…
lines in /usr/include/linux/input-event-codes.h
:
#define KEY_PLAYPAUSE 164
#define KEY_PREVIOUSSONG 165
#define KEY_STOPCD 166
#define KEY_RECORD 167
re-build and load internal databases by running
systemd-hwdb update; udevadm trigger
verify the new settings work by running
evtest
again, or by assigning shortcuts in your settings.
When trying this out in applications, just remember that if your desktop environment already uses that shortcut, the application won't even see the keypress.
edited Mar 28 at 5:23
answered Mar 27 at 18:40
Ulrich SchwarzUlrich Schwarz
10.1k13148
10.1k13148
Hi, I had another go at this method and managed to remap all the keys! They're now all sending extra function keys!
– umbro_tracksuit
Mar 29 at 8:26
add a comment |
Hi, I had another go at this method and managed to remap all the keys! They're now all sending extra function keys!
– umbro_tracksuit
Mar 29 at 8:26
Hi, I had another go at this method and managed to remap all the keys! They're now all sending extra function keys!
– umbro_tracksuit
Mar 29 at 8:26
Hi, I had another go at this method and managed to remap all the keys! They're now all sending extra function keys!
– umbro_tracksuit
Mar 29 at 8:26
add a comment |
In principle, yes. When I last did this in 2012, the way to go was to try and tell Linux that the second keyboard is very weird and really means XF86VolumeUp when it sends the keypress for Num 1, or whatever. Fortunately, there's quite a few keycodes that don't exist on standard keyboards that you can use in this way.
Let's run through this for a single key:
- use
xev | grep -i key
to find the keycodes of the keys on your extra keyboard. I'll just do keypap 9, as an example, with keycode 81. (NB: my extra keypad has a key labeled "00" but that sends "0" twice, I have no idea how to handle that.)
KeyPress event, serial 38, synthetic NO, window 0x4400001,
state 0x10, keycode 81 (keysym 0xffb9, KP_9), same_screen YES,
KeyRelease event, serial 39, synthetic NO, window 0x4400001,
state 0x10, keycode 81 (keysym 0xffb9, KP_9), same_screen YES,
request MappingKeyboard, first_keycode 8, count 248
- check
setxkbmap -query
for the rules of your (main) keyboard. We'll try to turn your extra keyboard into a dozen or so media keys on that layout. For me, it's
rules: evdev
model: pc105
layout: de
variant: nodeadkeys
- find enough entries in
/usr/share/X11/xkb/symbols/inet
. The right-hand side is what the application will see, possibly with shift key modifiers etc., the left-hand side are scancodes. I'll pick this one, because my keyboard doesn't have a "calculator" key:
key <I148> [ XF86Calculator ] ;
- create a file in
/usr/share/X11/xkb/keycodes/
that maps scancodes to keycodes (from the first step). Yes, this seems backwards. My file is named trustkeypad and looks like this:
default xkb_keycodes "trustkeypad"
minimum= 8;
maximum= 255;
// keypad 9
<I148> = 81;
;
compile this file with
xkbcomp -xkb trustkeypad
try it out with
setxkbmap -v -v -device 17 -keycodes (filename)
. (The 17 is the id from yourxinput
.) The result for me looks like this:
Warning! Multiple definitions of keycodes
Using command line, ignoring rules file
Applied rules from evdev:
rules: evdev
model: pc105
layout: de
variant: nodeadkeys
Trying to build keymap using the following components:
keycodes: trustkeypad
types: complete
compat: complete
symbols: pc+de(nodeadkeys)+inet(evdev)
geometry: pc(pc105)
and that looks good, in particular, the keycodes line.
If you run xev
now, you should see the new symbols being generated. Alas, I get only a half-victory right now:
KeyPress event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043275, (1666,897), root:(1670,950),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043403, (1666,897), root:(1670,950),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043403, (1666,897), root:(1670,950),
state 0x10, keycode 77 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043411, (1666,897), root:(1670,950),
state 0x10, keycode 77 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
but after I crashed X a couple of times by accident (do not think that setting the minimum value in the keycodes file higher will help), that went away. Maybe a simple reboot can help at this point. After you're successful, you should only get something like
KeyPress event, serial 38, synthetic NO, window 0x3e00001,
root 0x168, subw 0x0, time 26443862, (930,972), root:(934,1025),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x3e00001,
root 0x168, subw 0x0, time 26444022, (930,972), root:(934,1025),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
and you can verify in your user settings that you can now assign a shortcut to this key, and it will say it's assigned to the Calculator key.
Still missing here: figuring out how to make this the standard setting, also across reboots. This will probably involve looking at udev, and https://help.ubuntu.com/community/Custom%20keyboard%20layout%20definitions might be useful, even though it has an "outdated" tag dating from 2014.
add a comment |
In principle, yes. When I last did this in 2012, the way to go was to try and tell Linux that the second keyboard is very weird and really means XF86VolumeUp when it sends the keypress for Num 1, or whatever. Fortunately, there's quite a few keycodes that don't exist on standard keyboards that you can use in this way.
Let's run through this for a single key:
- use
xev | grep -i key
to find the keycodes of the keys on your extra keyboard. I'll just do keypap 9, as an example, with keycode 81. (NB: my extra keypad has a key labeled "00" but that sends "0" twice, I have no idea how to handle that.)
KeyPress event, serial 38, synthetic NO, window 0x4400001,
state 0x10, keycode 81 (keysym 0xffb9, KP_9), same_screen YES,
KeyRelease event, serial 39, synthetic NO, window 0x4400001,
state 0x10, keycode 81 (keysym 0xffb9, KP_9), same_screen YES,
request MappingKeyboard, first_keycode 8, count 248
- check
setxkbmap -query
for the rules of your (main) keyboard. We'll try to turn your extra keyboard into a dozen or so media keys on that layout. For me, it's
rules: evdev
model: pc105
layout: de
variant: nodeadkeys
- find enough entries in
/usr/share/X11/xkb/symbols/inet
. The right-hand side is what the application will see, possibly with shift key modifiers etc., the left-hand side are scancodes. I'll pick this one, because my keyboard doesn't have a "calculator" key:
key <I148> [ XF86Calculator ] ;
- create a file in
/usr/share/X11/xkb/keycodes/
that maps scancodes to keycodes (from the first step). Yes, this seems backwards. My file is named trustkeypad and looks like this:
default xkb_keycodes "trustkeypad"
minimum= 8;
maximum= 255;
// keypad 9
<I148> = 81;
;
compile this file with
xkbcomp -xkb trustkeypad
try it out with
setxkbmap -v -v -device 17 -keycodes (filename)
. (The 17 is the id from yourxinput
.) The result for me looks like this:
Warning! Multiple definitions of keycodes
Using command line, ignoring rules file
Applied rules from evdev:
rules: evdev
model: pc105
layout: de
variant: nodeadkeys
Trying to build keymap using the following components:
keycodes: trustkeypad
types: complete
compat: complete
symbols: pc+de(nodeadkeys)+inet(evdev)
geometry: pc(pc105)
and that looks good, in particular, the keycodes line.
If you run xev
now, you should see the new symbols being generated. Alas, I get only a half-victory right now:
KeyPress event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043275, (1666,897), root:(1670,950),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043403, (1666,897), root:(1670,950),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043403, (1666,897), root:(1670,950),
state 0x10, keycode 77 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043411, (1666,897), root:(1670,950),
state 0x10, keycode 77 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
but after I crashed X a couple of times by accident (do not think that setting the minimum value in the keycodes file higher will help), that went away. Maybe a simple reboot can help at this point. After you're successful, you should only get something like
KeyPress event, serial 38, synthetic NO, window 0x3e00001,
root 0x168, subw 0x0, time 26443862, (930,972), root:(934,1025),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x3e00001,
root 0x168, subw 0x0, time 26444022, (930,972), root:(934,1025),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
and you can verify in your user settings that you can now assign a shortcut to this key, and it will say it's assigned to the Calculator key.
Still missing here: figuring out how to make this the standard setting, also across reboots. This will probably involve looking at udev, and https://help.ubuntu.com/community/Custom%20keyboard%20layout%20definitions might be useful, even though it has an "outdated" tag dating from 2014.
add a comment |
In principle, yes. When I last did this in 2012, the way to go was to try and tell Linux that the second keyboard is very weird and really means XF86VolumeUp when it sends the keypress for Num 1, or whatever. Fortunately, there's quite a few keycodes that don't exist on standard keyboards that you can use in this way.
Let's run through this for a single key:
- use
xev | grep -i key
to find the keycodes of the keys on your extra keyboard. I'll just do keypap 9, as an example, with keycode 81. (NB: my extra keypad has a key labeled "00" but that sends "0" twice, I have no idea how to handle that.)
KeyPress event, serial 38, synthetic NO, window 0x4400001,
state 0x10, keycode 81 (keysym 0xffb9, KP_9), same_screen YES,
KeyRelease event, serial 39, synthetic NO, window 0x4400001,
state 0x10, keycode 81 (keysym 0xffb9, KP_9), same_screen YES,
request MappingKeyboard, first_keycode 8, count 248
- check
setxkbmap -query
for the rules of your (main) keyboard. We'll try to turn your extra keyboard into a dozen or so media keys on that layout. For me, it's
rules: evdev
model: pc105
layout: de
variant: nodeadkeys
- find enough entries in
/usr/share/X11/xkb/symbols/inet
. The right-hand side is what the application will see, possibly with shift key modifiers etc., the left-hand side are scancodes. I'll pick this one, because my keyboard doesn't have a "calculator" key:
key <I148> [ XF86Calculator ] ;
- create a file in
/usr/share/X11/xkb/keycodes/
that maps scancodes to keycodes (from the first step). Yes, this seems backwards. My file is named trustkeypad and looks like this:
default xkb_keycodes "trustkeypad"
minimum= 8;
maximum= 255;
// keypad 9
<I148> = 81;
;
compile this file with
xkbcomp -xkb trustkeypad
try it out with
setxkbmap -v -v -device 17 -keycodes (filename)
. (The 17 is the id from yourxinput
.) The result for me looks like this:
Warning! Multiple definitions of keycodes
Using command line, ignoring rules file
Applied rules from evdev:
rules: evdev
model: pc105
layout: de
variant: nodeadkeys
Trying to build keymap using the following components:
keycodes: trustkeypad
types: complete
compat: complete
symbols: pc+de(nodeadkeys)+inet(evdev)
geometry: pc(pc105)
and that looks good, in particular, the keycodes line.
If you run xev
now, you should see the new symbols being generated. Alas, I get only a half-victory right now:
KeyPress event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043275, (1666,897), root:(1670,950),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043403, (1666,897), root:(1670,950),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043403, (1666,897), root:(1670,950),
state 0x10, keycode 77 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043411, (1666,897), root:(1670,950),
state 0x10, keycode 77 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
but after I crashed X a couple of times by accident (do not think that setting the minimum value in the keycodes file higher will help), that went away. Maybe a simple reboot can help at this point. After you're successful, you should only get something like
KeyPress event, serial 38, synthetic NO, window 0x3e00001,
root 0x168, subw 0x0, time 26443862, (930,972), root:(934,1025),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x3e00001,
root 0x168, subw 0x0, time 26444022, (930,972), root:(934,1025),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
and you can verify in your user settings that you can now assign a shortcut to this key, and it will say it's assigned to the Calculator key.
Still missing here: figuring out how to make this the standard setting, also across reboots. This will probably involve looking at udev, and https://help.ubuntu.com/community/Custom%20keyboard%20layout%20definitions might be useful, even though it has an "outdated" tag dating from 2014.
In principle, yes. When I last did this in 2012, the way to go was to try and tell Linux that the second keyboard is very weird and really means XF86VolumeUp when it sends the keypress for Num 1, or whatever. Fortunately, there's quite a few keycodes that don't exist on standard keyboards that you can use in this way.
Let's run through this for a single key:
- use
xev | grep -i key
to find the keycodes of the keys on your extra keyboard. I'll just do keypap 9, as an example, with keycode 81. (NB: my extra keypad has a key labeled "00" but that sends "0" twice, I have no idea how to handle that.)
KeyPress event, serial 38, synthetic NO, window 0x4400001,
state 0x10, keycode 81 (keysym 0xffb9, KP_9), same_screen YES,
KeyRelease event, serial 39, synthetic NO, window 0x4400001,
state 0x10, keycode 81 (keysym 0xffb9, KP_9), same_screen YES,
request MappingKeyboard, first_keycode 8, count 248
- check
setxkbmap -query
for the rules of your (main) keyboard. We'll try to turn your extra keyboard into a dozen or so media keys on that layout. For me, it's
rules: evdev
model: pc105
layout: de
variant: nodeadkeys
- find enough entries in
/usr/share/X11/xkb/symbols/inet
. The right-hand side is what the application will see, possibly with shift key modifiers etc., the left-hand side are scancodes. I'll pick this one, because my keyboard doesn't have a "calculator" key:
key <I148> [ XF86Calculator ] ;
- create a file in
/usr/share/X11/xkb/keycodes/
that maps scancodes to keycodes (from the first step). Yes, this seems backwards. My file is named trustkeypad and looks like this:
default xkb_keycodes "trustkeypad"
minimum= 8;
maximum= 255;
// keypad 9
<I148> = 81;
;
compile this file with
xkbcomp -xkb trustkeypad
try it out with
setxkbmap -v -v -device 17 -keycodes (filename)
. (The 17 is the id from yourxinput
.) The result for me looks like this:
Warning! Multiple definitions of keycodes
Using command line, ignoring rules file
Applied rules from evdev:
rules: evdev
model: pc105
layout: de
variant: nodeadkeys
Trying to build keymap using the following components:
keycodes: trustkeypad
types: complete
compat: complete
symbols: pc+de(nodeadkeys)+inet(evdev)
geometry: pc(pc105)
and that looks good, in particular, the keycodes line.
If you run xev
now, you should see the new symbols being generated. Alas, I get only a half-victory right now:
KeyPress event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043275, (1666,897), root:(1670,950),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043403, (1666,897), root:(1670,950),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043403, (1666,897), root:(1670,950),
state 0x10, keycode 77 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x4600001,
root 0x168, subw 0x0, time 24043411, (1666,897), root:(1670,950),
state 0x10, keycode 77 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
but after I crashed X a couple of times by accident (do not think that setting the minimum value in the keycodes file higher will help), that went away. Maybe a simple reboot can help at this point. After you're successful, you should only get something like
KeyPress event, serial 38, synthetic NO, window 0x3e00001,
root 0x168, subw 0x0, time 26443862, (930,972), root:(934,1025),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 39, synthetic NO, window 0x3e00001,
root 0x168, subw 0x0, time 26444022, (930,972), root:(934,1025),
state 0x10, keycode 81 (keysym 0x1008ff1d, XF86Calculator), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
and you can verify in your user settings that you can now assign a shortcut to this key, and it will say it's assigned to the Calculator key.
Still missing here: figuring out how to make this the standard setting, also across reboots. This will probably involve looking at udev, and https://help.ubuntu.com/community/Custom%20keyboard%20layout%20definitions might be useful, even though it has an "outdated" tag dating from 2014.
edited Mar 27 at 17:11
answered Mar 27 at 15:12
Ulrich SchwarzUlrich Schwarz
10.1k13148
10.1k13148
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f509000%2fcan-i-launch-macros-and-shortcuts-from-a-second-keyboard-on-linux%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
-keyboard, keyboard-shortcuts, macro
Interesting question! I look forward to what others can come up with. Welome to UNIX & Linux Stack Exchange.
– 0xSheepdog
Mar 27 at 17:56