Showing posts with label hardware. Show all posts
Showing posts with label hardware. Show all posts

Friday, January 6, 2017

Mapping Trackball Buttons

For years, I've used a Logitech M570 wireless trackball with my Linux Mint PC. I generally prefer trackballs to mice -- no need to lift and reposition after a bunch of movement -- and I find that using my thumb, rather than my index finger (or, if I'm in a bad mood, my middle finger) to move the cursor is less fatiguing for my hand and wrist. The M570 works fine with Linux (at least Mint and Ubuntu) with no need for additional drivers.

In addition to the usual (at least for non-Mac users) three main buttons (left, write and combination scroll wheel/third button), the M570 has a couple of secondary buttons, which Logitech describes as "large, easy-to-reach Back/Forward buttons". I'm not sure I'd agree about "large", but I agree that they are easy to reach, and up until my most recent operating system upgrade I would have agreed they acted as back and forward buttons. Prior to the upgrade (and with no special configuration on my part, at least that I can remember), the extra buttons acted like page up and page down in every web browser or document reader that I used. After the upgrade (and switch from the Cinnamon desktop to the Mate desktop), their behavior changed. In the Firefox web browser, they would switch among tabs rather than vertically scrolling the current tab. In Xreader and Acrobat Reader, they also did not move forward backward among pages. (I don't recall trying to read multiple documents at once to see if they would switch among open documents.)

I find the forward/backward action rather handy with multipage documents and long web pages, so I wanted the previous behavior back. It turned out (after some research) not to be hard to do.

The first step is to install the xbindkeys and xautomation packages, both available from the Canonical repositories. This can be done via Synaptic or by running
     sudo apt-get install xbindkeys
     sudo apt-get install xautomation
in a terminal. (I also installed xbindkeys-config, which xbindkeys "suggests", but I don't think it's really necessary.) The xautomation package provides a command xte that can fake a key press.

The second step is to determine what button numbers are assigned to the forward and backward buttons. Run
     xev | grep -i button
in a terminal. This will open a small window with a target. Position the cursor over that window and click each of the buttons. You will see two messages in the terminal for each button, one for the press and one for the release. Look for the button numbers. For me, they were button 8 for forward and button 9 for backward, but your mileage may vary.

The third step is to configure xbindkeys to translate the extra trackball buttons appropriately. The configuration for xbindkeys is kept in a plain text file named .xbindkeysrc in your home directory (~/.xbindkeysrc). You can either create a new one (if you don't have one yet, or if there is nothing in it you want to keep) containing the lines below, or append those lines to the existing file, using your choice of text editor.
# Key bindings for Logitech M570 trackball
"xte 'key Page_Up'"
b:9
"xte 'key Page_Down'"
b:8
If your button numbers differ from mine (8 and 9), edit the lines accordingly. Note carefully the single and double quotation marks; xte seems a bit finicky about them.

Finally, you'll want to test this. You need to restart xbindkeys to get it to read the modified configuration file. Theoretically you can do this by running
     killall -HUP xbindkeys
in a terminal, but I found it necessary to restart the X server (after closing any applications using it, such as my web browser and email client). Typically Control+Alt+Backspace will do the trick. After that, try the trackball keys and hopefully they'll behave as expected.

Sunday, April 3, 2016

Tale of the Loose Cable

Friday I used my laptop (Acer Aspire V5-131, Linux Mint 17.3) at a coffee shop with no problems. Saturday it wouldn't boot. The specific error message was:
Broadcom UNDI PXE2.1 v15.0.1
<blah blah blah>
PXE-E61: Media test failure, check cable
PXE-M0F: Exiting Broadcom PXE ROM
No bootable device -- insert boot disk and press any key
The message suggests that either the hard drive was down, the data cable to the hard drive was loose (or broken), or the hard drive was somehow no longer bootable. Searching online essentially confirmed that.

I opened up the laptop and confirmed that the ribbon cable seemed to be connected at both ends. That was a bit worrisome. Could the disk be dead? Then came one of those good news/bad news situations. I booted the laptop from a live Mint USB drive. Once I was at the desktop, I was able to mount the hard disk and read it just fine. So the disk was not dead, which was the good news. The bad news was that this sent me off on a wild goose chase.

If I could read the hard drive when I booted from a USB, but I couldn't boot from it, logic said that the boot partition must either be corrupted or no longer marked as the boot partition. Right? A few episodes of cycling the power off and on confirmed that it consistently could read the hard disk when started from the USB stick and consistently could not boot from the hard disk. Only problem: running off the USB stick, I could read the boot partition just fine, and gparted confirmed that it was marked as the boot partition.

Unwilling to abandon my chase of the wild goose, I did the only thing I could think of: I reinstalled Mint (forcing me to update or reinstall tons of software -- still not done with that). After the reinstallation, the laptop booted from the hard disk just fine. I took it to the coffee shop and slugged down coffee while some of the software updates ran. Things were back on track ... until I got home and discovered it once again would not boot from the hard drive (same message as above). Grrrr.

Turns out a loose cable was at fault. It just didn't look (or feel) loose. In hindsight, the Broadcom ROM media test may just be more accurate (or more finicky) than whatever Mint does when deciding whether to mount a disk. For the benefit of anyone else staring at PXE-E61, here's a quick synopsis of what to check.

The first step is to remove the cover from the base of the laptop (Figure 1). (This might be a good time to apologize for the fuzzy images.)

laptop base
Figure 1: Laptop base

Remove one small (and easily lost!) Phillips-head screw from the base (highlighted in the photo), then slide the case in the direction indicated by the arrow and remove it, exposing the innards (Figure 2).

laptop interior
Figure 2: Laptop interior
The blue padding covers the hard disk; the arrow points to the ribbon cable connecting the hard disk to the (largely obscured) circuit board.

I'm used to cables that snap into place, but while this one connects solidly at the hard disk, the connection to the circuit board is secured largely by inertia. Figure 3 shows that end of the ribbon cable exposed. Note the metal "teeth"  (fingers? tentacles?). Also note the black line running across the width of the ribbon.

exposed cable end
Figure 3: Exposed cable end
Finally, Figure 4 shows the cable pushed all the way in at the circuit board end.

cable plugged in
Figure 4: Cable plugged in


You can see a light colored plastic tab covering the teeth of the cable, with a dark colored (and, it turns out, removable) plastic widget underneath the cable (visible on either side of the cable). Getting the cable to slide in between them is a bit of a pain in the ass. I don't know whether the dark plastic piece is a guide that was originally glued to the cable or not. In any case, the key is that the black line running across the width of the cable is close to the plastic stuff and, importantly, none of the metal teeth (fingers? tentacles?) are showing. If you see any portion of the teeth (connectors), the cable may be making intermittent content.

Tuesday, July 29, 2014

New Linux Laptop

Earlier this month I decided to get a netbook, and of course I wanted to run Linux (preferably Linux Mint) on it. After shopping around, I settled on an Acer Aspire V5-131. I won't say it was my dream machine -- it has a conventional hard drive, whereas I would have preferred a solid-state drive -- but it satisfied my other key criteria:
  • size and weight are appropriate for a netbook;
  • it comes with Linpus Linux, ensuring that I could load a different Linux distribution without having to learn the new Windows 8 interface or fight through a lot of UEFI secure-boot obstacles (I think the BIOS supports UEFI, but I think it's off by default);
  • it has 4 GB of DDR3 RAM (a lot of the competing machines only had 2 GB); and
  • it was pretty cheap for a machine with its specs.
When I received the machine, I downloaded and ran UNetbootin (on a Windows box, as it happens), which allowed me to install a "live" (bootable) version of my preferred Linux distribution (Mint 17) to a USB drive. I use the Cinnamon version of Mint on my desktop, but I went with the Xfce version for the netbook because I figured it would put less strain on the processor.

From there, I just had to boot the Aspire, interrupt the boot sequence to get to the BIOS, change the BIOS to boot first from a USB drive, plug in the USB stick and reboot. That put me into Mint. After verifying that WiFi worked (there really wasn't much else to test), I chose the option to install Mint, and took defaults for pretty much everything. You can install Mint to coexist with another operating system, but all I wanted was Mint (no disrespect to Linpus intended). so I let it overwrite Linpus. Just like that, I had a working Mint netbook. There was no drama (possibly a first for me when installing/configuring a machine).

So far I've been quite happy with the Aspire. Some people seem be concerned about the bulge in the back caused by the battery. (The Aspire has better-than-typical battery life, as I understand things, so that bulge pays dividends.) The battery causes a slight downhill tilt to the keyboard, which I find comfortable.

The Aspire has a touchpad but does not have separate mouse buttons. Some of the reviews I read before purchasing seemed to think that was an issue, while other people said gestures (single finger tap for left button, double finger tap for right button) were good enough. After setting the machine up, I discovered that it does in fact have mouse buttons, or at least mouse button functionality. The touchpad appears to be hinged along the top edge and not anchored to the case along the bottom. If you push the front left (lower right) corner of the touchpad reasonably firmly, you get a left (right) mouse button click. For the left mouse button, I think it's easier to tap, but I find pushing the front right corner down to get the "hardware" right mouse button action much more accurate than two fingered taps (or tapping the lower right corner with one finger, which will generate a right mouse button event if are very precise).

The only issue I've encountered so far is that the touchpad is a bit too sensitive for my tastes. When I'm typing, I can generate a mouse event without meaning to, presumably because the angle of my hands brings my palm a tad too close to the pad. Flexing at the wrists eliminates the problem, but too much typing with flexed wrists is probably not good for the associated tendons.

Saturday, May 19, 2012

Installing Mythbuntu with WinTV-DCR

A few years back, I bought a tower PC with Windows Vista Media Center (home version) and a tuner card built in.  I've used it almost exclusively as a personal video recorder. For a variety of reasons, Vista has increasingly gotten on my nerves, so I finally bit the bullet and replaced it with MythTV.  The process has taken much longer than I expected, partly due to dopiness on my part, partly due to sketchy instructions here and there (or presumptions that I know things I do not). Herein I chronicle some of the details in case they'll help anyone else. It will be a long post, as it was a long process.

I should note a few more things about my equipment before diving in. I am a Comcast cable customer. I run the incoming cable through a splitter, with one connection to the TV (flat-screen HD) through a set-top cable box and the other to the tuner card in the PC. The PC has an NVidia graphics card (the precise model is, I think, irrelevant) that connects to the TV via an HDMI cable.

The tuner in the PC can only capture analog channels (NTSC), and Comcast is moving more and more channels to digital. So part of the motivation of trying out MythTV was that I needed to install a new tuner in any case. After a little online shopping, I settled on a Hauppauge WinTV-DCR (model 2650), a dual-tuner CableCARD receiver that connects to the PC via USB. The 2650 is not explicitly recognized by MythTV, but according to multiple success stories by other people, you can falsely identify it as an HDHomeRun Prime and it will work fine with MythTV.

As I've mentioned more than once, I run Linux Mint on various PCs and laptops, so I initially thought about installing Mint on my PVR machine and then adding MythTV. A couple of things I read online about complications, coupled with the  discouraging thought of downloading a potentially large number of dependent packages via my slow DSL line, caused me instead to download Mythbuntu 12.04 (at the office, where speeds are much greater) and burn an ISO image to a DVD. Mythbuntu is basically Ubuntu with things deemed inessential to a media server stripped out and MythTV added.

My initial thinking was to run Mythbuntu from the DVD, give it a test drive, then install it alongside Vista long enough to confirm that I liked it and to move my existing recordings over. Fortuitously, I took the precaution of copying almost all the recordings to an external hard drive before beginning the experiment. (The "almost" refers to one two-hour recording, approximately 5.3 GB, which could not be copied to the external drive. The issue was not lack of space; apparently the file was too large for the file system -- which might be FAT; I can't recall -- on the drive.)

Like other Ubuntu-based distributions, including Mint, you can boot from the CD or DVD, try out the system, and optionally install it. The test drive is useful to determine whether Mythbuntu correctly identifies and has drivers for your keyboard, mouse, display, network connections etc. In my case, this all worked fine, including installation of the NVidia proprietary drivers. For what it's worth, my keyboard and mouse are wireless, through a hub connect by USB. There was no problem with either of them.

I expected also to test MythTV itself, but as it turns out that cannot be done booting from the DVD. MythTV is a client-server system, so it comes with two parts, a front-end (client) and a back-end (server). You can test MythTV's front-end with a preexisting back-end, but if (like me) this is your first foray into MythTV, you will not have a back-end installed. No back-end, not test.

There was nothing for it but to install Mythbuntu. Mythbuntu initially gave me a screen with three choices, the first being to install alongside Vista. I chose that and took the default choice for disk partitioning. Shortly thereafter, Mythbuntu informed me that one of the partitions (it was not clear which; possibly the swap partition) was too small at the size it had selected itself and that I should back up and make it bigger. So I backed up and got what looked like the "how do you want me to install it" dialog again. Apparently I paid insufficient attention when I clicked the top choice, because this time the top choice was to wipe the old system and install just Mythbuntu. When I realized what it was doing (almost immediately) I ejected the DVD (the only way I could find to stop it), then reinserted the DVD and tried to restart the installation ... only to be told that the hard drive now had no system on it. To paraphrase Captain Keith Mallory, my "bystanding days" were over and I was "in it now up to [my] neck". A full install was on.

Thereafter, installation of Mythbuntu was quick and painless. There were 89 MB of updates awaiting me, which I deferred while I worked on the TV part. Physical connection of the WinTV was trivial (power cord, USB to the PC, attach the cable, insert the CableCARD).  The installation screen lets you select an IR remote if you have one. I do, left over from Media Center, and selecting the standard Media Center remote worked ... for a while ... more about that below. The WinTV comes with its own remote, but I thought it would be easier to stick to the MCE remote (to which I'm used) rather than figure out how to get the WinTV remote to work.

For the video device, I selected the NVidia driver. There were a couple of drop down boxes to configure "TV-Out". I wasn't sure whether that was necessary, but I figured probably not; the prompt starts "If you would like to configure TV-Out". So I stuck with the default settings, which seems to have worked.

MythTV itself started, and suddenly the mouse was gone.  My first thought was "how the heck do I navigate", but the keyboard arrow and tab keys worked fine. I later discovered this is a design feature, not a bug. When you are in a MythTV window, there is no mouse cursor. MythTV expects you to navigate via the remote. I wish I'd seen that somewhere before I launched into the installation, but no harm done. The remote worked fine to advance, retreat, select and cancel. At least it worked for a while (more to come).

In the video setup menu, I clicked the hi-def test button. It downloaded a 70+MB HD movie clip and played it successfully in the TV ... other than a lack of sound. The setup wizard theoretically allowed me to configure sound. I chose ALSA, but no joy. So I tried various other ALSA settings in the list (specifically those that mentioned NVidia), along with clicking the rescan button, and had no luck.

After a bit of searching, I exited MythTV, opened a terminal, and ran aplay -L, which showed me default:NVidia as a recognized sound device. That's what I'd hoped for, so I ran sound-test -Ddefault:NVidia -c 2 -t sine and heard tones in both of the TV's built-in speakers. (Sidebar: without the -t sine argument, you get "pink noise", which to me sounds like a bad connection.)

I then went back to the sound configuration screen in the front-end, and lo and behold the choice had changed, on its own, to ALSA:dmix:CARD=NVidia, DEV=0, and sound was working in MythTV. Maybe I forgot to try that one, or maybe my tests in the terminal somehow made the device more visible (?).

To configure the video source, I followed these instructions with minimal difficulty. I've had an account with Schedules Direct for a while, so my channel lineup was already configured. The one hiccup was that clicking Fetch channels from listing source repeatedly failed to do anything, until I realized that the CableCARD was not firmly seated in the receiver slot. (Paul slaps himself a few times.)

Pairing the device required a call to Comcast, in which I needed to give them three pieces of data: the card's serial number; a host ID, and a device (data) ID. The serial number was on the receipt I got from Comcast, but where to get the other two things? The back-end settings have a menu for Capture Card, in which I selected HDHomeRun Prime for each of the two tuners, and was given addresses for them and an IP address (on my home network, so a nonroutable address). This turns out not to be what Comcast wants. When you install the WinTV in Windows 7, the information is magically provided to you, but where would I find it in Mythbuntu? After a bit of searching, I indirectly stumbled on the answer. That IP address in the Capture Card screen was for a web server built into the WinTV. I opened that in a browser and it handed me the necessary information, including the serial number, on a silver platter. I called Comcast and in fairly short order had the card authorized (although they warned me it could take 45 minutes for the card to download all the channel information it needed).

Somewhere in the middle of this process I turned off the PC and went out to dinner. When I returned and booted the PC, the IR remote no longer worked! That's happened a second time as well. When I first observed this, I wasted considerable time searching for the source of the problem, playing with various remotes, and looking in the wrong places for where I could reconfigure it. (System > Control Center > Infrared is where I select the remote.) The lsusb command, run in a terminal, failed to show the remote being attached. As it turns out, unplugging the receiver's USB cable and then plugging it back in fixes the problem. I think I ran across some tweaks one can make in system files to eliminate the need to do that, and I will definitely research that tomorrow. I can't picture having to reseat the remote cable every time I wake the computer.

I have not yet tried to record anything, nor to import my Windows recordings, so there will probably be a follow-up post. Meanwhile, there are two pressing issues. One is fixing that bug with the IR remote. The other is to figure out why the first channel in my cable lineup (which happens to be ABC) is showing programming dubbed in Spanish (?!). All the other channels coming through the WinTV tuner are in English, and the one that is dubbed when viewed through the tuner is in English when viewed through the cable box.

Sunday, April 8, 2012

Resizing My Windows Partition

My laptop is dual boot -- Windows 7, Linux Mint 11 (Katya) -- and I ran out of space on the Windows partition. (Microsoft has never seen a disk drive it wasn't happy to fill up for you.) As it turns out, alleviating this was child's play (well, if your child is pretty advanced) once I figured out one little thing ... which I record here, since I'll not doubt forget it and then have to repeat the process.

I booted my laptop from the Katya CD.  Like all Mint distributions, you can run Linux from the CD, which allows you to screw with the hard drive. Mint comes with GParted, the Gnome partition editor, which deserves every accolade that anyone has ever thrown at it. My hard drive started with a small boot partition, followed by the Windows partition (NTFS), and then one extended partition for Linux containing three logical partitions (home, swap and the main partition).  All I had to do was:
  1. Shrink the main partition (which had the most free disk space) to create some unallocated space.
  2. Move the main partition all the way to the right.
  3. Move the swap partition all the way to the right. The unallocated space was now at the beginning of the extended partition.
  4. Shrink the extended partition to give up the unallocated space (placing it between the NTFS partition and the extended partition.
  5. Expand the NTFS partition to soak up the free space.
  6. Apply all operations.
The sticking point, which I discovered only by clicking anything that couldn't outrun me, was that I needed to right-click the swap partition and select "Swapoff" in order move stuff around within the extended partition. When all was said and done, I used "Swapon" to turn the swap partition back on.

Once that was done, I booted into Windows, which immediately ran chkdsk to square things away.  I rebooted into Windows, and all looks good.

Actually, the first time I did this, GParted showed the correct (new) partition scheme, but when I got into Windows it showed the old partition size.  Back to Mint and GParted, and sure enough, the old partition table was there. I'm not sure whether I screwed something up. The first time chkdsk ran, it rebooted when my back was turned, and so booted into Mint (the default) rather than Win 7. I don't know if that was the problem, or if somehow the modified partition table was not written the first time around.  Anyway, it's all good now.

Saturday, February 11, 2012

The Case of the Dormant Function Keys

There's an intermittent problem on my home PC (Linux Mint) that's been driving me slightly buggy (okay, slightly buggier).  My mail client is Thunderbird, and when composing messages I frequently hit the F9 key, which should open the "Contacts Sidebar", from which I can select recipients.  Usually it does.  On my office PC and laptop it always does.  At home, though, it sometimes doesn't -- the F9 key goes mysteriously dead in T-bird.  I can work around it by opening the contacts sidebar from a menu, and eventually the problem disappears (for a while).

Today, though, it happened again and I decided to try to sort it out.  Testing with other programs showed that all the function keys, not just F9, were dead, and in all applications.  I checked system settings in the control panel, and could find nothing that would be remapping the F keys.  A bit of work with Google, though, turned up the culprit: my keyboard.

I have a Microsoft ergonomic keyboard at home (and only on the home PC). Microsoft decided to assign alternate functions to all the F keys, so that, for example, F9 does double duty as the "Send" key (with a different key code).  At the end of the row of function keys is an "F Lock" key.  (For reasons that will become clear, I cannot get out of my head another name for it, also starting with "F" and ending with "ck".)  The F Lock key toggles function keys between their normal key codes and the alternate codes.  It apparently cannot be controlled by the operating system -- or at least nobody has figured out how.  Microsoft being Microsoft, they decided that the F Lock key has to be on for function keys to act as function keys (which seems to suggest that the being a function key is not the normal role of the function key).  Whatever.

The problem, as reported by various people, is that the F Lock apparently toggles randomly, without the key being struck.  In my case, this may mean that the state of the function keys at startup is random -- the keyboard sometimes wakes with F Lock on and sometimes with F Lock off.  With the culprit identified, there are two possible resolutions.  For now, I'll try the lazy approach: do nothing special, but keep an eye on the F Lock status light.  If it becomes too hard for me to remember this (the problem is, after all, intermittent), the more involved solution is to use the xev utility (which displays keyboard events, including key codes) to make a list of the key codes of the 12 function keys, both with and without F Lock engaged, and then use the xmodmap utility to map the key codes for the non-standard functions (undo, redo, reply, send, ...) back to the same virtual keys as the function keys (so that F9 looks like F9 to the system, regardless of the status of F Lock).