Friday, 4 January 2013

Disabling the optical drive tray button

I use a ThinkPad T420. A great machine. The shit. I love it. But, there's a tiny annoyance. These laptops' optical drives have a protruding eject button, that's very easy to press accidentally when you grab the laptop to move it, or even just bump against it when moving your mouse. It happens quite often, too often in fact. Imagine your optical tray popping open every now and again at the most unexpected moments. Now this is really annoying. Something has to be done.

The easiest way to disable the eject button is to use the eject utility (on linux, of course). Simply saying

$ eject

will - eject the tray, you guessed it. Using it with the -i option however, will disable or enable the eject button, depending on the option argument.


$ eject -i on

disables the device button, and

$ eject -i off

enables it. If on and off aren't recognised as valid arguments, use 0 and 1.

If I recall correctly, this worked flawlessly on openSUSE 11.4. When I switched to Chakra Linux, it didn't anymore. After extensive research I found there was an UDEV rule overriding (or working around, shall I say) the eject utility. What the solution took, was simply commenting out the conflicting UDEV rule. In my case the rule was in /lib/udev/rules.d/60-cdrom_id.rules.

I commented out the line

and reloaded UDEV rules with

$ sudo udevadm control --reload-rules.

It worked. It also works on Kubuntu 12.04 LTS, which I'm currently using, after getting too annoyed with Chakra's updates constantly breaking my system.

To lock the tray automatically (magical word) on system boot, put eject -i on in one of the startup scripts; a good place would be in /etc/rc.local. This way your optical drive will be locked on startup, and if/when you want to use it, you can unlock it saying $ eject -i off.

There you go. Another annoyance eliminated.

No comments:

Post a Comment