MSI’s X-Slim laptops are slowly gaining popularity because they are affordable, lightweight, and very mobile. I purchased an X340 from TigerDirect recently because I couldn’t pass up the great price Mostly, I purchased this laptop for the excellent battery life — the laptop uses a high-density lithium polymer battery and has a ton of power-saving features that shut off peripherals when you don’t want them. It’s an excellent 13″ laptop with plenty of power for my mobile computing needs (SSH and Firefox).
Installing Linux on just about any hardware nowadays is easy. Things have changed a lot since I first started with kernel 2.4 — I remember spending countless hours trying to configure my hardware to work properly. But now, you rarely need to get under the hood to get your hardware running flawlessly, no matter the distribution that you run. The thing is, I like getting under the hood and fortunately, this laptop has given me a chance to do a little bit of that.
MSI is just enough of an off-brand name that some of the hardware they use is only partially supported by Linux. The laptop is built on an Intel platform, so all the most important devices work perfectly well out of the box, but a few things: ACPI, the touchpad, and the keyboard, need a little tweaking to work effectively.
This is a short guide with scripts, configs, etc. attached that aims to get as much of the hardware on the X340 working as possible. I’ll start by describing the really broken stuff and then later provide suggestions for improving battery performance, etc. I’m writing from the Arch Linux point of view (BSD-style init vs. SysV-style, etc.), but everything should apply to all distributions, possibly with some minor changes.
Brightness
Immediately after installing Linux, you’ll probably notice that the brightness keys don’t work. I think what’s happening is that when your computer boots up, ACPI hands over brightness control to the operating system. Some laptops (e.g. Dell) still have hardware support for changing brightness, so no matter what OS you’re running, you can always press the brightness up/down keys to adjust your screen. The X340 doesn’t seem to support that, so we’ll have to create a script to adjust the brightness from within the operating system.
You can get and set the current brightness setting in /sys/class/backlight/acpi_video0/brightness. So, I wrote a quick script that sets the brightness in different ways:
http://jwcxz.com/other/msi/brightness.sh
I stuck this script in /etc/brightness/brightness.sh. Supported functions: bup (increase brightness level by 1), bdn (decrease it), blo (set to minimum brightness), bhi (maximum brightness), bset # (set to some value #), badj # (increase or decrease by #), bget (return the current brightness). You could source this file as root and run the functions, or you can just give them as arguments to the script.
I’ll get to configuring the brightness keys to work with this script in a minute, but if you would also like to be able to use the functions as a regular user, you can modify sudo to let you issue brightness commands without a password by doing sudo visudo and adding the following line:
yourusername ALL = NOPASSWD: /etc/brightness/brightness.sh
Then, you can define some aliases in your profile:
alias bup="sudo /etc/brightness/brightness.sh bup"
alias bdn="sudo /etc/brightness/brightness.sh bdn"
alias blo="sudo /etc/brightness/brightness.sh blo"
alias bhi="sudo /etc/brightness/brightness.sh bhi"
alias bset="sudo /etc/brightness/brightness.sh bset"
alias badj="sudo /etc/brightness/brightness.sh badj"
alias bget="sudo /etc/brightness/brightness.sh bget"
Keyboard
The keyboard is a bit trickier — there are several things to do. First, we need to get HAL to recognize the extra keys on the keyboard. For example, if you press the brightness up key (Fn-Up) and then do dmesg | tail, you’ll see an error message telling you that the scancode hasn’t been mapped to a keycode.
Working off of the keymap entries for other MSI computers, I built an almost-fully-working keymap for the X340. It might work for other X-Slim laptops too, especially for the X320, X350, and X360. You can grab that here:
http://jwcxz.com/other/msi/10-keymap-msi.fdi
Stick that in /etc/hal/fdi/information/10-keymap-msi.fdi and restart HAL. I was able to get all of the special keys working with a few caveats:
- The keys labeled with [hw] have a hardware action. For example, the bluetooth key actually turns the bluetooth module on and off. So, if you choose to bind something to that key, make sure that you are willing to toggle bluetooth on and off. A good thing to bind to these keys are status indicators so that when you toggle bluetooth on, an icon or something lights up.
- The same thing applies to WLAN. It toggles the RFKILL bit in hardware.
- Fn-F2 (video mode switch) and Fn-F11 (some other WiFi button — maybe for bringing up the connection window?) seem to be “missing” — when I press either one of them, I don’t get an error about a missing keycode, but I don’t get a keycode either. After I look into this issue, I plan to submit a patch to HAL in order to get this keymap included.
- Fn-F5 (economy mode) currently maps to keycode 126, which is plusminus. I need to remap that scancode to “battery” when I find it.
The next thing to do is to install some software to handle system-wide key bindings. I like actkbd (AUR package) because it operates as a system service and therefore works even when you aren’t using X. My /etc/actkbd.conf file is here:
http://jwcxz.com/other/msi/actkbd.conf
Finally, you may want to define some user-level keybindings. For example, I switch escape with caps-lock and I also define the \| key (which is really less than/greater than when you press the key) that’s right next to the Alt key to be Super_R because I use the Windows key a lot and I think it’s more comfortable next to the space bar. The xmodmap configuration file I use is as follows.
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
keycode 94 = Super_R
I’ve also turned the menu key into left-click, but I’ll get to that in the next section.
Touchpad
I have to say, the touchpad sucks. It really sucks. I thought it wouldn’t be as bad as the reviews said — I assumed it would be possible to fine-tune things and so forth — but I was completely wrong. First of all, it’s not made by Synaptics, but rather by a company called Sentelic. The touchpad’s operation is really ugly. Unlike with the Synaptics touchpads, you cannot move your finger on the sides of the touchpad to scroll; you have to place your finger at the corners and hold it. That wouldn’t be so bad, but it’s not accurate at all; I can’t scroll for more than a few seconds even when holding my finger perfectly still. Also, there seems to be no control over the sensitivity of the pad, and there’s definitely no “palm check” feature. Supposedly, you can adjust the acceleration rate, but I haven’t been able to do that yet in Linux.
What I have been able to do is get rid of tap-to-click. I didn’t want to get rid of it because I use it a lot–it’s much easier than pressing the mouse button. But, because the touchpad is big and very sensitive, it’s easy to accidentally start clicking when you’re typing.
To get rid of tap-to-click, issue the following command as root:
echo 'c' > /sys/devices/platform/i8042/serio1/flags
I put this in /etc/rc.local so that it runs every time I start my system up.
I also used xbindkeys and xmacroplay (AUR package) to rebind the menu key to left-click by creating the following ~/.xbindkeysrc:
http://jwcxz.com/other/msi/xbindkeysrc
Other Stuff
The brightness settings, keyboard, and touchpad are the three big things to fix on the X340. Everything else pretty much works out of the box. A few minor points:
And that’s about it. Everything else is just a matter of minor configuration to your preferences. It’s not like the old days when you had to research all sorts of minor points in the kernel configuration and build your own kernels to support the hardware you needed, but for almost everyone, it’s probably best that those days are behind us. Still, the opportunity to contribute even a few small improvements or findings to the open-source community is quite a valuable experience.
Up next: I finally start describing the plans for my FPGA-based audio visualization project. I have them all written down in my notebook; I just need to formalize them a bit and start building.