Thursday, July 26, 2012

Fine-Tuning Your Hardware

By:  Whitson Gordon  & Kevin Purdy

On some systems, Ubuntu and other Linux systems will install as if they they had always been right there on your system. Other times, there's a piece missing. Here's how to patch up the last piece (or two) of your system if not everything's working right off. 

Note: Like other sections of our Getting Started on Linux series, this guide is written from the perspective of a new Ubuntu user. But the knowledge is univerally helpful, many of the tips can be applied in other systems, and the last bit on troubleshooting is handy for any Linux newcomer.

The Biggie: Get Wi-Fi Working
You might load in an Ubuntu CD or USB drive and have your Wi-Fi working right away, as if it was built for this Linux stuff. Or you might spend an annoying bit of time searching out Windows drivers and re-jiggering them for Linux use. It's hard to tell, but it's very annoying to encounter Wi-Fi problems right off—since, you know, you can't go online to find a solution, or download the right fixes. If you'd like to know where your wireless card stands, check out HJ Heins' gigantic If your WI-Fi card is listed in the green, you're likely good to go, and most distributions can work with it. If not, the second place to check is Ubuntu's community documentation, where owners of certain finicky cards have posted their solutions for all to follow. Beyond that, you can turn to this basic troubleshooting guide, along with the help available through Google, the Ubuntu Forums, and other community resources (our tips on doing so are a bit further down).
  
When all else fails, use your wireless card's Windows driver. Odd-sounding, sure, but you can use a tool to "wrap" the Windows driver for use in Linux. If you want to jump in, download the Windows driver for your WI-FI hardware, un-pack them, then install the ndisgtk package in Ubuntu (either with a temporary ethernet cable, or with offline means). Launch the app from the System->Administration menu ("Windows Wireless Drivers"), then load the INF files from your Windows package with the "Install New Driver" button.
Luckily, the How-To Geek has walked through the process, step by step, in Ubuntu, and it's a
great resource.
Proprietary Drivers
While many hardware manufacturers, like Intel, make their drivers free and open source, others (like Nvidia, ATI, Broadcom, and others) don't.This means that, as an open source operating system, most Linux distributions aren't allowed to package these closed source drivers with themselves—which means you have to install them manually.
  
For what it's worth, open source drivers for some of these peripherals do exist. Nouveau, for example, is an open source Nvidia driver that comes with many Linux distributions. It'll give you some pretty good support, but if you want the best 3D and high quality graphics your card has to offer, you'll have to install the proprietary drivers.  
This is pretty different on every distro. Ubuntu has a very nice proprietary driver manager under System > Administration > Hardware Drivers, which will tell you the drivers available for your system and let you install them with the press of a button. Other distributions will require a bit more work. You'll have to search out the instructions for your specific distro on Google or that distro's documentation (for example, Mint has their own instructions for installing Nvidia's proprietary drivers, as does SUSE).

This isn't just for graphics cards, either. If you have a particular Wi-Fi card or other piece of hardware that doesn't have open source drivers, you'll need to use this method for them too. Generally, this is the first thing I do whenever I install a fresh copy of Linux—check what proprietary drivers are available and enable them.
Proprietary Stuff: DVDs, MP3s, Video
Formats, and More
Ubuntu is not the most puritanical of Linux distibutions when it comes to open software, but it doesn't go so far as to build in access to MP3s, DVDs, licensed fonts, and other items that you probably take for granted on most computers, but which require tricky licensing. But getting access to the good stuff has become remarkably easy. So easy, in fact, it's basically two steps now:
  
Step One: If you're in Ubuntu right now, click here to install ubuntu-restricted-extras. If you're not in Ubuntu at the moment, you could bookmark this page and click that link when you get into Firefox. You could also grab an installer from Ninite, or head to the Ubuntu Software Center (found in the Applications menu in the upper-left desktop corner) and search for "ubuntu restricted," then install the ubuntu-restricted-extras result.
Step Two: Open up a Terminal (Applications->Accessories->Terminal), then enter this line and press Enter:

sudo /usr/share/doc/libdvdread4/install-css.sh 

Now you've got support for MP3s, commercial DVDs, most of the video and audio formats you'll come across, Java, Windows-specific fonts, and everything else you might encounter. And it didn't hurt at all, did it?

Other distributions usually offer a similar kind of "restricted goods" package in their repositories, or app offerings. Search your installer package (YUM, Synaptic, or another offering from the main menu) for things like "mp3," "avi," "Windows media" and the like.


Extra Mouse or Keyboard Buttons
 
By default, your mouse probably works just fine—left click, right click, scrolling, and even sometimes forward and back buttons work out of the box in Linux. However, if you want to remap your fancy mouse's extra buttons, you'll need to do so manually. There are a ton of different methods, but I've always found xbindkeys to be the easiest program. It's quite intimidating but fear not—it's actually remarkably simple. For this demonstration, I'm going to map my mouse's hidden thumb button to Ctrl+T, so I can open new tabs in Firefox with ease.

To start, we want to figure out the names of the buttons on our mouse. Each button is numbered, but it's hard to tell which button is which just by looking at it. So, to find out, run the following command:

xev


This will open up a small white window with a box in it. Place your cursor in the white window, but outside of the box and press the button you want to remap. In this case, we're pressing the thumb button. Xev will give you a few lines of code in the terminal, like:

ButtonPress  event,  serial  33,  synthetic  NO,  window  0x4e00001, root  0x142,  subw  0x0,  time  568329,  (93,19),  root:(96,714), state  0x0,  button  10,  same_screen  YES

See on the last line, where it says button  10? That's what we're looking for. Looks like our thumb button is button #10 on our mouse. Hit Ctrl+C to exit xev, make a mental note of your button's number and move on to the next step.

Next, we'll need to install two programs: xbindkeys and xautomation. In Ubuntu, that means running the following command:

sudo  apt-get  install  xbindkeys  xautomation

After that, you'll want to create a config file for xbindkeys. To do this, run:

                              xbindkeys  --defaults  >  /home/your-user-name/.xbindkeysrc
Replacing your-user-name with your username. This command should be the same on all flavors of Linux. Next, we'll want to edit that file, so open up your file browser, head into your home folder, and go to View > Show Hidden Files. You should see the .xbindkeysrc file show up at the bottom of the list. Double-click on it, and add the following lines of text to the end of the file (but before the  #  End  of  xbindkeys  configuration  # line):

#  Thumb  Button  =  Ctrl+T 
"xte  'keydown  Control_L'  'key  T'  'keyup  Control_L'"
b:10

Xte is a program that's part of the xautomation package that we downloaded earlier, and it simulates keypresses. In this case, we're simulating pressing the left Control key down, hitting T, and then releasing the control key. b:10 corresponds to the button number we found earlier. See? Not that difficult. You can now go back to xev and figure out your other mouse button numbers, and remap them as you see fit. If you need to know the names of other keys on your keyboard, xte's manual page lists some useful ones.
  
You can do a whole lot of things with xbindkeys, and we won't dig into it here—this should get you started on at least getting a bit of functionality out of your mouse—but check out Ubuntu's Keyboard Shortcuts guide for more info. I'd also highly recommend googling xbindkeys and the name of your mouse, or what you want to do. You'll find some pretty neat tutorials out on the net. Good luck!


Where to Get More Help
Obviously, this is just the tip of the iceberg. Because Linux is so endlessly configurable, there are a lot of things you can do—and a lot of hardware you can do it with. Luckily, there are also a lot of great places to get help, including:

Ubuntu's Community Documentation: This is a great place for frequently sought-after info. You can find out about things like mapping your mouse buttons (which we discussed above), and even search for a specific laptop or netbook model to see what tweaks you'll have to make to get all your hardware working. In fact, if you're running Linux on a laptop or popular desktop computer, the first thing I'd recommend doing is searching the Community Documentation for your model—you'll find almost all the info you need to get your hardware up and running.

The Arch Linux Wiki: While it's designed for Arch Linux users, it's still one of the best Linux wiki's I've ever seen. You'll need to keep in mind the distro you're using when you read it (for example, when they tell you to install a package with pacman, you'll need to remember to run the command using apt-get, or whatever your distro's package manager is), but other than that, it's a great resource, especially when it comes to command line tools and getting hardware working.
The Ubuntu Forums: It's one of the biggest Linux forums out there, so if you  have a problem, chances are someone's already asked about it on the Ubuntu Forums. Google the problem you're having (using the tips below), and if you don't find anything grab an account at the forums and ask it yourself—trust me, as a beginning Linux user, you'll be spending a lot of time here. You might as well get an account now.
 
Google: Frankly, the best way to find what you're looking for is to search Google. The above resources are all great, but what I usually do is Google my problem, then look for a result from the top three sources—if they exist, it's likely they'll contain the solution to my problem. Make sure your search terms are good, too—try using the word "solved" in your search terms, or if you see the name of a program on one page hat you think does what you want it to do, try googling for tutorials on that program.
Lifehacker: We've got quite a few Linux-savvy readers here at Lifehacker, so if you're looking for advice, our weekly open thread is a great place to find it. Your fellow readers may not be able to answer super-specific questions ("I'm trying to do X with program Y and it's giving me this error code. What do I do?"), but they'll be a wealth of knowledge when it comes to the general stuff ("What's the best way to remap my mouse's button to open a new tab in Firefox?").

0 comments:

Post a Comment