4

So I have an Alienware 17R4 that has 6 Macrokeys on the left side named: x,1,2,3,4,5
and 4 macrokeys on top of the keypad to the right side named: 6,7,8,9
On windows I can use the x macrokey to toggle macrokeys numbered 1 through 5 between three different modes. So basically there are 15 macrokeys instead of 5.
My question is how can I do the same on Ubuntu?

Things Worth mentioning:

Using the command showkey I cannot even get a scancode for the macrokeys when I press them. Also in the output of xmodmap -pke there are some empty lines for certain keys which makes my assumption correct. So how can I enable them? Because once they are enabled, I can use their scan code to assign macros to them. Also _How can I use the x macrokey to toggle their modes?

user746434
  • 41
  • 1
  • 3

1 Answers1

3

I have the same problem on my AW15R3 and solved it

first install the following packages on ubuntu

sudo apt install  ghc libusb-1.0-0-dev cabal-install git pkg-config python-usb -y

then get the scan code of each key from the following command:

dmesg | grep -i code

for example when I press the macro key 4 the following message is printed that indicate the scancode is e015

[ 1737.342249] atkbd serio0: Unknown key released (translated set 2, code 0x95 on isa0060/serio0).

Now the "e015" is the scan code and you need to map that to a free keycode in the system. This could happen by running sudo setkeycodes e011 204 so create a script under /etc/init.d to map the scan codes to a free keycodes available for all keys.

Please note that you need to execute the below commands on Linux console not on the x-server (Ctrl+Shift+F3 to switch to Linux console from X). Use sudo vim /etc/init.d/keyremap and map the codes to the keycodes:

sudo setkeycodes e011 146
sudo setkeycodes e012 148
sudo setkeycodes e013 149
sudo setkeycodes e014 203
sudo setkeycodes e015 204
sudo setkeycodes e016 184

Then make the script executable by chmod +x keyremap

Finally use xmodmap utility to map the keycodes to keysym so your Xorg can understand and catch the key events using vim ~/.Xmodmap:

  keycode 154 = XF86Launch0
  keycode 156 = XF86Launch1
  keycode 157 = XF86Launch2
  keycode 211 = XF86Launch3
  keycode 212 = XF86Launch4
  keycode 172 = XF86Launch5

Then run sudo xmodmap ~/.Xmodmap

Now you can map the XF86Launchx to any action by using the keyboard shortcuts:

enter image description here

You can create an entry in rc.local so these scripts are executed automatically when machine boot up.