I'm using Ubuntu at home, for both studying and entertaining. I play Dota 2 as a hobby, and it works just fine on Ubuntu. I have a Razer BlackWidow classic keyboard and Hex Naga mouse. When I install the OpenRazer driver, my mouse worked out of the box, but keyboard needs some extra work.
After spent 9,999 times to Google, finally I found an easy way.
The main issue is, M1-M5 actually work when OpenRazer daemon running, but they don't map to any key, (or macro.) I don't use any complex macro for Dota 2, so in this post I will talk about map the M1-M5 keys to regular keys.
I use Xmodmap, it's already packed on Ubuntu 16.04 (or maybe :)) but if you don't have, install it.
Install OpenRazer and GUI (optional)
It's quite easy, just follow the default installation guide on their site.
But the OpenRazer offers only daemon and drivers, if you don't know how to handle it, time to install some GUI. I chose polychromatic.
Little note, keep the Polychromatic Tray applet running at startup, it helps.
Get the M1-M5 keycode
xev to get keycode, simply run in terminal, and you will get something like this:
KeyPress event, serial 37, synthetic NO, window 0x5000001, root 0x1de, subw 0x0, time 962553, (364,668), root:(364,716), state 0x0, keycode 38 (keysym 0x61, a), same_screen YES, XLookupString gives 1 bytes: (61) "a" XmbLookupString gives 1 bytes: (61) "a" XFilterEvent returns: False KeyRelease event, serial 37, synthetic NO, window 0x5000001, root 0x1de, subw 0x0, time 962623, (364,668), root:(364,716), state 0x0, keycode 38 (keysym 0x61, a), same_screen YES, XLookupString gives 1 bytes: (61) "a" XFilterEvent returns: False
In this example, I used "a" button to test. Notice the pair
KeyRelease, you will see the
keycode nn inside them.
In my keyboard, M1-M5 keys have code from 191-195. I'm not sure how it works on your keyboard, maybe it's different.
Note the code down.
Use Xmodmap to make it works
~/ folder, it should have
.Xmodmap file, if not, create it. Open it and add the code:
pointer = 1 2 3 4 5 6 7 8 9 10 11 12 13 keycode 191 = p keycode 192 = o keycode 193 = i keycode 194 = u keycode 195 = y
By default, there was only 1 row of pointer, and if you notice, it's only up to 12. I added 13 because Hex Naga has 1 extra button.
The five lines below are mapped with my regular keys, just for Dota.
Now if you run
xmodmap ~/.Xmodmap, your M1-M5 keys should be mapped.
Read more about Xmodmap here if you want.
Make Xmodmap run at startup
This part is varies. Trust me, if you search on Google or StackOverflow, you will get 999 versions, and I still don't know how
Xblahblahblah actually works.
Some say the Ubuntu system will automatically load all
".X" files at startup, some say create
.xinitrc, but not in my case, I don't know why.
.xsession and add
xmodmap ~/.Xmodmap line into it. Wooalaah, it works!
So, the idea here, let OpenRazer daemon run first, then let Xmodmap do the rest.
If you need any help, just ask, I'm happy to explain. If you want to contribute something, you are more than welcome!
I'm a graphic designer, but recent years I fall in love with Nodejs and right now I'm learning so hard to become a front end developer. I use this blog to write note for myself and share some interesting things I found on the study journey.
I'm living in Vantaa, Finland with my beautiful little family, taking care 2 ant queens and play Dota 2 in my spare time.
Drop me a message at Twitter @sangdth for more.
Subscribe to Sang's blog
Get the latest posts delivered right to your inbox