Thursday, March 24, 2011

network management


I'm firmly in the "NetworkManager is the devil" camp, because it messes up my network configuration without triggering a loud error in syslog or somewhere. Grr.

I'm now using wicd to manage my wireless/ethernet networks.

Note, to use wicd in a non-systray window manager (wmii), type "wicd-client -n &"

Lastly, "ifconfig" is deprecated(!).  Use "ip" instead -- http://en.wikipedia.org/wiki/Iproute2
"ifconfig" => "ip a"
"route" => "ip r"
http://andys.org.uk/bits/2010/02/24/iproute2-life-after-ifconfig/

Friday, March 4, 2011

EasyTether internet tethering for Android on Debian

My local cable provider likes to mess with me, so on occasion I get internet via my cellphone. In practice this works rather well. Install EasyTether on the phone and on your Debian machine. Connect via USB, then run some commands on the Debian side to route packets via your cellphone. The software is designed to be run standalone, not as part of the normal Linux system, which is a little weird. The following stanza helps with this. If you add the following to /etc/network/interfaces, you can turn on/off the tethering using the normal ifup/down commands:
iface easytether0 inet dhcp
      pre-up easytether connect &
      pre-up sleep 1
      pre-down killall easytether
That is, after the above is added, do "sudo ifup easytether0" to route packets through the USB-connected Android device. To turn it off, do "sudo ifdown easytether0". This solution is rather buggy. Disconnect and reconnect the USB cable to solve some problems. Also, by default EasyTether doesn't route ICMP packets, which means you can't use "ping -c1 4.2.2.2" to verify your internet connection is up. "curl google.com" is a good check instead. Note that EasyTether Lite doesn't route https, which means Gmail and Facebook doesn't work. To get around the latter, use the mobile site: http://m.facebook.com The full software is $10 and has been a fantastic value for me -- highly recommended. http://www.appbrain.com/app/easytether-lite/com.mstream.easytether_beta

Wednesday, February 16, 2011

video: installing drivers and tweaking DPI

With the new kernel, the nVidia drivers can be installed. I didn't have luck with the free nouveau drivers, so went with the proprietary nVidia setup. Download it, then:

aptitude install gcc make binutils linux-headers-2.6.37-trunk-686
sh ./NVIDIA-Linux-x86-260.19.36.run

It worked! But... fonts are way too large. At the login page the "user" and "password" fields have letters so big they overflow the space. Terminal windows are unusable. It looks terrible.

I'd already seen this and had found a fix. The Samsung TV lies like a rug to the computer about how big it is. So, on the Linux side just ignore the TV's boasts and set the DPI manually.

File /etc/X11/xorg.conf, add text in bold:

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BoardName      "GeForce GT 430"
# JM:
    Option         "UseEdidDpi" "FALSE"
    Option         "DPI" "100 x 100"
EndSection

Restart X to see the changes. For my system, this was:

service gdm stop ; service gdm start

video: nVidia GT 430 on Debian, upgrading the kernel

For my new media computer, I chose a nVidia GT 430. It's cheap at $80, small, and doesn't require big power connectors used by my older gamer card. It's also another nVidia card, which has some level of support for Linux.

Debian Squeeze runs Linux 2.6.32, but the 430 is new enough that it requires newer drivers to work well. I wasn't looking forward to dicking with the kernel and/or X settings just to be able to use my computer. It's easy to spend hours or days tweaking things that might help, or might not.

For additional challenge, the video card takes over the audio. The nVidia card can transmit both video and audio over the same HDMI cable to the TV. This is cool because I can control computer audio via the TV remote. However this means I'd switch from my nice Mackie studio monitors to the little speakers inside the TV.

So, under normal Debian with the new GT 430, graphics are old VESA style: low resolution and sluggish. And, no audio at all -- not through the HDMI connector, nor through the motherboard's audio port. But the video is usable.

To verify Debian with new kernel would work with the 430, I found a derivative: PureOS. Installing to a USB flash drive didn't work very well, but it gave me enough confidence to redo the kernel in my main Debian hard drive. http://pureos.org/index.php?lang=english

Upgrading the kernel turned out to be rather easy and not risky. It's in two steps:

1a) "pin" the system so it sees both stable and unstable packages. It'll use stable most of the time, but the newer files are available if needed.

File /etc/apt/preferences, add the text in bold:

Package: *
Pin: release a=statler
Pin-Priority: 1001

Package: *
Pin: release a=squeeze
Pin-Priority: 100

# JM:
Package: *
Pin: release a=experimental
Pin-Priority: 69

1b) tell the system where unstable packages are located

File /etc/apt/sources.list, add text to the end:

# JM:
deb http://ftp.debian.org/debian/ experimental main contrib non-free
deb-src http://ftp.debian.org/debian/ experimental main contrib non-free
2) install the new kernel. It automatically adjusts the boot manager so that you can use either the new or old kernel when the computer boots.
aptitude update
aptitude install linux-image-2.6.37-trunk-686
reboot

With our system running Debian with an upgraded kernel, we're now ready to install the nVidia drivers, thus making our video card happy

new media computer

My old computer is a bit of a mess. Over three years it's accumulated a few hard drives, with cables strewn about. A new computer isn't in my budget, but I'm tired of looking at the full-size computer case in my living room.

Thus, my media PC project. I bought a case small enough to fit in the media cabinet under my 46" tv/monitor, which will contain the guts of the old computer. Then the old case will vanish, and my living room will look great! No more cables multiplying like rabits, languidly lazing about, collecting dust and tripping my Roomba.

This project is in several steps:

1) find the right case. This was rather harder than I'd expected.

2) replace video card. My old gamer video card is too big and
power-hungry.

3) rearrange hard drives. New case only has room for two.

4) move motherboard from old case to new, without a hammer.

5) what the hell, let's change operating systems.

Sunday, March 21, 2010

"Danger: Emacs"

http://www.flickr.com/photos/hackaday/3841760416/

heh

HOW TO SET UP REMOTE CONTROL FOR LINUX (lirc)

Using a infrared (IR) remote control for Linux consists of getting
several pieces to be configured correctly, and to talk to each other
correctly.

STEP 1 -- install Lirc

apt-get install lirc

STEP 2 -- configure your remote

In this case, I have a Microsoft Media Center remote. Therein the problems start. It
has a Vista logo, but is marked "HP" on the bottom, and is recognized
as a "Philips" USB device:

$ lsusb
Bus 005 Device 002: ID 0471:060c Philips

To tell Lirc which remote you have, type:

$ sudo dpkg-reconfigure lirc

and follow the prompts.  This changes settings in /etc/lirc/lircd.conf
and probably other files.

To verify this worked, use the "show cooked codes" command and press
keys on your remote.  To quit, press control-C.

$ irw
000000037ff07bed 00 ChanUp mceusb
000000037ff07bed 01 ChanUp mceusb
000000037ff07bf2 00 Home mceusb
000000037ff07bf2 01 Home mceusb

At this point, your remote works, and your computer is correctly
translating the bitstream into keys.

STEP 3 -- translate keys into actions

Add this to your ~/.lircrc file:

begin
        prog   = irexec
        button = Home
        config = echo "Hello world!"
end

To test this, run the "how does program X translate key Y" command,
ircat.  In this case, we're intercepting the irexec command:

$ ircat irexec

echo "Hello world!"

Once the translation step works correctly, run it for real:

$ irexec

Hello world!

STEP 4 -- translate keys into "smart" actions (VLC media player)

Change your ~/.lircrc file into this:

begin
        prog   = irexec
        button = Home
        config = echo "Hello world!"
end
begin
        prog   = vlc
        button = Home
        config = key-stop
end

Start irexec again, and also VLC on a video:

$ killall irexec
$ irexec &
$ vlc mymovie.avi

Pressing "Home" should stop the video, but it doesn't work -- VLC has
to know to subscribe to Lirc events:

$ vlc --control lirc sample.avi

When Home is pressed on the remote, Lirc sends the event to *all*
applications that are interested. In this case, pressing Home prints
"Hello world!" in the terminal, and the movie stops.

The Lirc service, lircd, grabs infrared data from the USB device and
translates it to button names. In this case, it knows I
have a Media Center remote "mce", so the IR squiggles it got when I
pushed the Home button, it understands as "the user pressed the Home
button".

Each application subscribes to Lirc events. The lircd service
translates specific buttons for specific applications. In this case,
the "vlc" media player received the "key-stop" message, and it stopped
the video. The "irevent" application also received a message, in this
case the "echo hello world" string, so it printed a message to the
terminal.

If something goes wrong, look at each part of the setup:

- IR signals to buttons with lircd

"irw" displays buttons

- buttons to actions

    "ircat vlc" shows actions for a specific program, in this
 case vlc

 "irexec" does things directly, like printing messages


Different applications understand different messages.  Many programs
don't understand remote buttons at all, so an intermediate programs is
used to do the translation.


STEP 5 -- translate buttons into "dumb" mouse/keyboard events (Google Chrome)

Add this to ~/.lircrc:

begin
prog = irxevent
button = Home
config = Key CTRL-t CurrentWindow
end

Test the mapping:

$ ircat irxevent

Key CTRL-t CurrentWindow

Now run irxevent directly.  It intercepts the Home button, then sends
a keypress to the current window. In this case, Control-T on a Google
Chrome window opens up a new tab.

$ killall irxevent ; irxevent


Hope this helps!

- john


REFERENCES:

- lircd.conf, mapping buttons to actions:

http://www.lirc.org/html/configure.html#lircd.conf

- keys for Google Chrome:

http://www.google.com/support/chrome/bin/answer.py?hl=en&answer=95743

- VLC

http://en.gentoo-wiki.com/wiki/VLC/LIRC

- my setup: