M1-M5 are in fact regular keys - they just need to be specifically enabled before pressing them will generate a scancode. tux_mark_5 developed a small Haskell program which sends the correct SET_REPORT message to Razer keyboards to enable these keys, and ex-parrot ported the same code to Python.
On Arch Linux systems the Python port has been packaged and is available from https://aur.archlinux.org/packages.php?ID=60518.
On Debian or Ubuntu systems setting up the Python port of the code is relatively easy. You need to install PyUSB and libusb (as root):
aptitude install python-usb
Then grab the blackwidow_enable.py
file from http://finch.am/projects/blackwidow/ and execute it (also as root):
chmod +x blackwidow_enable.py
./blackwidow_enable.py
This will enable the keys until the keyboard is unplugged or the machine is rebooted. To make this permanent call the script from whatever style of startup script you most prefer. For instructions on how to set this up in Debian have a look at the Debian documentation.
To use tux_mark_5's Haskell code you'll need to install Haskell and compile the code yourself. These instructions are for a Debian-like system (including Ubuntu).
Install GHC, libusb-1.0-0-dev and cabal (as root):
aptitude install ghc libusb-1.0-0-dev cabal-install git pkg-config
Fetch the list of packages:
cabal update
Install USB bindings for Haskell (no need for root):
cabal install usb
Download the utility:
git clone git://github.com/tuxmark5/EnableRazer.git
Build the utility:
cabal configure
cabal build
Run the utility (also as root):
./dist/build/EnableRazer/EnableRazer
After this you can copy EnableRazer binary anywhere you want and run it at startup.
Immediately after execution, X server should see M1 as XF86Tools, M2 as XF86Launch5, M3 as XF86Launch6, M4 as XF86Launch7 and M5 as XF86Launch8. Events for FN are emitted as well.
These keys can be bound within xbindkeys or KDE's system settings to arbitrary actions.
Since your keyboard might be different, you might need to change the product ID in Main.hs line 64:
withDevice 0x1532 0x<HERE GOES YOUR KEYBOARD's PRODUCT ID> $ \dev -> do
Press and hold the Fn key and press the gaming key (F13), this will put it in 'gaming mode' (the G
light should light up on the top right of the keyboard. All the F keys will then work as F keys. Press the same keys to take it back out of 'gaming mode' if you want the media keys back.
Best Answer
There are no official Razer drivers available on their site. It seems they announced drivers 6 months ago though.
(user comment on a Razer facebook page)
Try using USB Overdrive, a commercial third-party USB device utility.
(emphasis by me)