Tải bản đầy đủ - 0 (trang)
Hack 46. Hotswap Your Laptop's Optical Drive

Hack 46. Hotswap Your Laptop's Optical Drive

Tải bản đầy đủ - 0trang

gooley@falcon:~$sudohotswap

Password:

I/Owarning:failedtoloadexternalentity"/etc/hotswaprc"

hotswap0.4.0

Copyright2001TimStadelmann

Thisprogramisfreesoftware,licensedundertheconditionsof

GNUGeneralPublicLicenseversion2,or(atyouroption),any

version.

ThefollowingIDEdeviceiscurrentlyconfigured:

HL-DT-STCD-RW/DVDDRIVEGCC-4242N

Doyouwanttoremovethisdevice?y

Youcannowremovethedevicefromthemodulebay.

WouldyouliketoinsertanIDEdeviceintothemodulebay?

Aborting



Atthispoint,youcanejectandremovetheopticaldrive.To

reinsertthedrive,simplyrunhotswapviasudoagain

(occasionally,hotswapwillreportanerror,asshownhere,butit

willactuallyregisterthedrivewiththeIDEsubsystem):



gooley@falcon:~$sudohotswap

I/Owarning:failedtoloadexternalentity"/etc/hotswaprc"

hotswap0.4.0

Copyright2001TimStadelmann

Thisprogramisfreesoftware,licensedundertheconditionsof

GNUGeneralPublicLicenseversion2,or(atyouroption),any

version.



ThereiscurrentlynoIDEdeviceconfigured.(Floppydiskdriv

batteries,and'travelmodules'arenotmanagedbythisutility

youwanttoswapsuchamodule,youshouldremoveitnow.)

WouldyouliketoinsertanIDEdeviceintothemodulebay?



PleaseinsertthenewdeviceintothemodulebayandpressRETU



NoIDEdevicehasbeenfoundinthemodulebay.Ifyouaresur

thedeviceyouwanttoconfigureconnectstotheIDEbus,make

thatthemoduleisinsertedcompletely.

Doyouwanttotryagain?n

Aborting



Aquickcheckofdmesgwillconfirmthatthedrivedidindeed

getre-registeredwiththesystem:



gooley@falcon:~$dmesg|tail

[4296527.332000]ProbingIDEinterfaceide1...

[4296527.698000]hdc:HL-DT-STCD-RW/DVDDRIVEGCC-4242N,ATAPI

[4296528.004000]ide1at0x170-0x177,0x376onirq15

[4296528.008000]hdc:ATAPI24XDVD-ROMCD-R/RWdrive,2048kBC



Hotswappingtheopticaldriveusuallyresultsinalossofthedrive's

DMAsettings.Asofthiswriting,theonlywaytore-enableDMAisto

rebootthesystem.



HotswappingisonemorecapabilityLinuxhasrecentlygained

onlaptopsandportablemachines.Nowyoucanenjoyanother

abilitythat'sbeenaWindows-onlyfeature!







Chapter5.X11

Hacks47-53

TheXWindowSystem(X11)isthebasisofUbuntu'suser

interface.X11isresponsibleformanagingyourkeyboard,

mouse,ortouchpad,andalsotakescareofthehardware

accelerationfeaturesrequiredby3-Dapplicationssuchas

games.It'swhereyouspendmostofyourtime,soit's

importanttogetitconfiguredjustright.

ThischapterwillhelpyoucustomizeX11toworkexactlythe

wayyouwantitto.Althoughnearlyeverymouse,keyboard,or

touchpadwillworkrightoutoftheboxwithUbuntu,youcan

usetheX11configurationfileandsomerelatedutilitiestogeta

lotmoreoutofthem.IfyouwanttotuneX11totake

advantageofalltheaccelerationfeaturesofferedbyyour

graphicsadapter,spreadyourdesktopacrossmultiplescreens,

orgetyourfontslookingjustright,thehacksinthischapterwill

helpyouout.







Hack47.ConfigureMultibuttonMice



Sevenbuttons,atilt/scrollwheel,andwhoknowswhat

else?Findouthowtoputallthosebellsandwhistlesto

gooduse.

GamerslovemicewithmorebuttonsthantheSpaceShuttle

becausetheextrabuttonscanbemappedtoprovidequick

accesstocommonfunctions,butgettingthemworkingunder

Linuxcanbeabittricky.

OpentheXorgconfigurationfileat/etc/X11/xorg.confinatext

editor(forexample,usingthecommandsudovi

/etc/X11/xorg.conf)andlookforastanzalabelledInputDevice.If

yourcomputerisalaptopwithatouchpad,itmayhaveseveral

InputDeviceenTRies,somakesureyoufindtheonethatrefersto

yourmouse.IfitwasconfiguredautomaticallybyXorg,itwill

probablylooksomethinglikethis:

Section"InputDevice"

Identifier"ConfiguredMouse"

Driver"mouse"

Option"CorePointer"

Option"Device""/dev/input/mice"

Option"Protocol""ImPS/2"

Option"ZAxisMapping""45"

Option"Emulate3Buttons""true"

EndSection



StartbychangingtheProtocolvalue.TheExplorerPS/2driver

supportsmoredevicesthantheolderImPS/2driver,so



substitutethisline:

Option"Protocol""ExplorerPS/2"



Sinceyourmultibuttonmousealmostcertainlyhasamiddle

button,youdon'tneedtheEmulate3Buttonsoptionanymore,so

deleteit.

Unfortunately,thereisnowayforyourcomputerto

automaticallydeterminethenumberofbuttonsavailableona

mouse,soyouneedtoaddanoptionthatexplicitlytellsXorg

howmanyithas.It'sobviousthatyouneedtocountallthe

actualphysicalbuttonsonthemouse,butrememberthatyou

usuallyneedtoaddthreemore:oneforclickingthescroll

wheel,oneforscroll-up,andoneforscroll-down.Atypicalscroll

mousewithtwomainbuttonsonthetop,twoontheside,anda

scrollwheelactuallyhassevenbuttonsasfarasthedriveris

concerned,soaddalinelikethis:

Option"Buttons""7"



Next,maptheactionofthescrollwheeltovirtualbuttonsusing

theZAxisMappingoption.Inthecaseofasimplescrollwheelthat

movesonlyupordown,youcanassigntwovalues,whichare

associatedwithnegative(down)andpositive(up)motion,

respectively:

Option"ZAxisMapping""45"



Somemicehaveascrollwheelthatalsorocksfromsidetoside,

andsomeevenhavetwoscrollwheels,inwhichcaseyoucan

addmappingsfornegativeandpositivemotioninthesecond



axis:

Option"ZAxisMapping""4567"



Unfortunately,youmayfindthesecondscrolldirectionisn't

recognizedbyXorgatallbecausethereiscurrentlynostandard

fordefininghowmiceshouldencodehorizontalscrolldatawhen

it'stransmittedtothedriver.Evenifitisrecognized,youmay

findtherockerorsecondscrollwheelmovesintheopposite

directiontowhatyouexpect,soyoumayneedtoreversethe

thirdandfourthvalues.

SomebrowserssuchasFirefoxarehardcodedtousebuttons4

and5asshortcutsfor"back"and"forward,"butbecausesome

wheelmicereportwheel-upandwheel-downasthefourthand

fifthbuttonevents,respectively,youmayneedtodosome

extraworktousethesidebuttonsasbackandforward.Youcan

remapthereportedbuttoneventsbycallingxmodmap:

xmodmap-e"pointer=1236745"



Thexmodmapcommandwillneedtoberuneachtimeyoulog

intoGNOME,sogotoSystem Preferences Sessions

StartupProgramsandputinthewholeline;thencompensate

fortheoffsetbuttonvaluesbyusingamodifiedZAxisMappingline

in/etc/X11/xorg.conf:

Option"ZAxisMapping""67"



Onefinaloptionyoucanconfigureismouseresolution.Many

multibuttongamingmicerunatveryhighresolutionstoenable

accuratetargeting,butyoumayfindthatitthrowsoffXorg's



responsecurve.Inthatcase,itmayhelptoaddaResolution

optionindpi(dotsperinch):

Option"Resolution""2400"



Onceyouhavemadeallofthesechanges,yourmouse

configurationwilllooksomethinglikethis:

Section"InputDevice"

Identifier"ConfiguredMouse"

Driver"mouse"

Option"CorePointer"

Option"Device""/dev/input/mice"

Option"Protocol""ExplorerPS/2"

Option"Buttons""7"

Option"ZAxisMapping""45"

EndSection



Toapplychanges,youneedtorestartXorg.Theeasiestwayto

dosoistologoutofyourcurrentsessionandthenpressCtrlAlt-Backspace,whichwillkillXorgandforceGDMtorestartit(if

GDMdoesn'trestartit,loginattheconsoleandrunthe

commandsudo/etc/init.d/gdmrestart).

Logbackinandlaunchxev,theXEVentreporter,andclickeach

buttonandscrollthescrollwheelinbothdirections.Eachevent

willcauseabuttonnumbertobereportedintheterminal.If

everythingwentasplanned,eachbuttonwillreportadifferent

buttonnumber.







Hack48.EnableYourMultimediaKeyboard



Makethemostoftheadditionalkeysonyourmultimedia

keyboard.

Whenyoupressakeyonyourkeyboard,itdetectsthekey

pressandsendsacorresponding"keycode,"whichisthen

matchedusingalookuptablethatconvertsthekeycodetoa

character.However,manymodernkeyboardshaveavarietyof

additionalkeysthattypicallyreturnkeycodesthataren't

includedinthestandardlookuptable,soLinuxdoesn'tknow

whattodowiththem.

InUbuntu,youcanusetheseextrakeysasshortcutsforsuch

tasksasopeningemail,launchingabrowser,orchangingaudio

volume.WiththehelpofGNOMEPreferences,youcanconfigure

somespecialactions,butformaximumflexibility,Hotkeyslets

youcompletelycustomizeshortcut-keybehavior.



AssignGNOMEKeyboardShortcuts

Ifyouwanttocreateshortcutsonlyforbasictasks,startby

openingSystem Preferences KeyboardShortcutstoseea

listofpredefinedactions,asshowninFigure5-1.



Figure5-1.UseSystemPreferencesKeyboard

Shortcutstoassigncommonactionstokeys



Clickontheshortcutentryforanactionandthenpressthekey

combinationyouwanttoassociatewithit.Forexample,ifyou

wantF7tolaunchyourwebbrowser,clicktheshortcutentry

nextto"Launchwebbrowser"andthenpressF7.Changesare

appliedimmediately,sothereisnoneedtosavethenew

settings.

Thebuilt-inGNOMEkeyboard-shortcutsettingsincludeonly

predefinedactions,soifyouwanttolaunchacustomscriptor

anarbitraryprogram,you'llneedsomethingmoreflexible,such

asHotkeys.



Hotkeys

Hotkeysisaprogramthatinterceptskeycodesfrommultimedia

keysandmapsthemtospecificevents.Theeventsaretotally

user-definable,soyoucanconfigurekeystorunprogramsor

evencustomscripts.Forexample,inadditiontobasicactions

suchascontrollingvolume,openingemail,orlaunchinga



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Hack 46. Hotswap Your Laptop's Optical Drive

Tải bản đầy đủ ngay(0 tr)

×