LF Tip: USB 鼠标和笔记本电脑

ArticleCategory:

SystemAdministration

AuthorImage:[Here we need a little image from you]

[Photo of the Author]

TranslationInfo:[Author + translation history. mailto: or http://homepage]

original in en Guido Socher

en to zh_CN 小汪

AboutTheAuthor:[A small biography about the author]

Guido 真的喜欢让电脑用起来如自己定制的那样,而看起来则如自己所想的那样. 这,正是他选择使用Linux的原因.

Abstract:

这是一个小技巧,从现在开始,LinuxFocus每月都会至少提供一个这样的技巧。 如果你有有关这些小技巧的新想法,请发邮件到:guido(at)linuxfocus.org。

ArticleIllustration:

idea

ArticleBody:

Introduction

我最近注意到当我插入 USB 鼠标到我运行着 Linux 的笔记本电脑而无须重启 X11 时,我的朋友会感到非常惊讶。 对我来说,这是再正常不过的了,然而我却必须承认,我还没有看到哪个发行版会把这作为默认配置。[1]

下面是解决之道:

XF86 下面的 PS/2 和 USB 鼠标

我的 GNU/Linux 发行版不是最新版所以我用的是 XF86,我觉得下面的方法适用于任何 X(如Xorg) 但是我没有测试过。

这个“usb 鼠标的即插即用法”("usb mouse hotplugging")只有在你的笔记本电脑上既有一个内在 PS/2 鼠标又有 usb 接口是才起作用。为什么需要有一个内建鼠标?是的,你可以不要。但是你没有鼠标那么运行 X11 又有什么意思呢?
Section "ServerFlags"
Option     "AllowMouseOpenFail"
EndSection
这样你的 X 服务器就能正确的处理插入和拔出 USB 鼠标,不过前提是能在启动的时候正确读取设备文件(在/dev)。 有的发行版把 USB 设备支持编译为模块,因此你需要在启动的时候就加载这个模块——哪怕你的 USB 鼠标并没有连接好。

# put this into an init script e.g
# /etc/rc.d/rc.local for fedora or
# /etc/conf.d/local.start for gentoo or ....

# load the kernel modules needed for a usb mouse even if there
# is no mouse connected yet:
modprobe hid
modprobe input
modprobe mousedev
这下应该好了!