Posts Tagged ‘gentoo’

Android 2.2 USB Tethering on a Gentoo box

Tuesday, August 3rd, 2010

Why not use the WiFi Hotspot

Recently HTC rolled out the Android 2.2 upgrade for my Desire, finally enabling USB Tethering out of the box. Often enough I used the WiFi hotspot feature on my previous phone to enable my laptop to have internet on the go. Android’s got this feature as well nowadays, but I don’t really like it because it really, and I mean *really*, puts the drain on your phone’s battery. USB Tethering seems like a much better solution.

Setup for Android

This is by far the easiest part, just hook up your phone, drag down the status bar and instead of charge only, or whatever mode it is in at that time, set it to USB Tethering.

Setup for Gentoo

This part is a bit trickier, especially when you roll your own kernel. Open up menuconfig for your kernel and enable these options

Device Drivers --->
  [*] Network device support --->
    USB Network Adapters --->
      [*] Multi-purpose USB Networking Framework
        <*> CDC Ethernet support
        <*> CDC EEM support
        <*> Simple USB Network Links (CDC Ethernet subset)
          [*] Embedded ARM Linux links
  [*] USB Support --->
    <*> USB Modem (CDC ACM) support
    <*> USB Wireless Device Management support

Now build your kernel as usual and reboot. When you now plug in your Android phone when it’s in USB Tethering mode, if all is well, you should be able to see a new network interface, usbX, X usually being 0. The link might be down, so check it with the command

$ ifconfig -a

Which will output something like this

usb0      Link encap:Ethernet  HWaddr 26:10:72:ab:38:0e  
            BROADCAST MULTICAST  MTU:1500  Metric:1
            RX packets:0 errors:0 dropped:0 overruns:0 frame:0
            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:1000 
            RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Which means it all worked. Now all you have to do is run a DHCP request on that interface, and Android will handle the rest. You can set up a init.d script for this interface much the same way you would for a normal interface. Just make a symlink from /etc/init.d/net.lo to /etc/init.d/net.usb0 and run that script whenever you want.

Beautifying the whole thing

Running around on the console starting bootscripts like that doesn’t suit everyone, including me when I’m just on the road and stuff needs to work. I recommend using something like wicd or NetworkManager to handle it for you. Using wicd it’s pretty easy to make it automagically use the usb0 interface when it appears, so you’ll only have to plug it on for it to work.

Gentoo, awesome and themes

Thursday, February 25th, 2010

I’ve been a Gentoo user since forever, and for some time I’ve been using awesome for a window manager instead of the desktop environments Gnome or KDE. One thing I never got around to change was the wallpaper. My terminals are pseudo-transparent, and I never disliked the default ‘awesome’ wallpaper. @ZackLeonhart’s bitching and moaning changed that.

Turns out that aside from editing the system-wide theme script, by default located in /usr/share/awesome/themes/* (which I consider to be a BadThink™), there is no straight forward way of doing it nicely in the Gentoo provided default setup. So here’s what you do.

  1. Create yourself a lua.rc in ${HOME}/.config/awesome
    $ cp /etc/xdg/awesome/rc.lua ~/.config/awesome
  2. Recursively copy all themes from the system-wide dirs to your local configdir.
    $ cp -rvf /usr/share/awesome/themes ~/.config/awesome
  3. In your copy of lua.rc you will find a variable called theme_path, change it to theme_path = os.getenv("HOME") .. "/.config/awesome/themes/path/to/theme.lua"
  4. Edit the variable theme.wallpaper_cmd to contain the string "eval `cat ~/.fehbg`"
  5. Choose a wallpaper you like, execute $ feh --bg-scale /path/to/wallpaper.jpg

And you’re done! If you want to change your wallpaper, simply use feh again with a random other file, and make sure the file is readable when awesome is starting up, and it’ll set it up automagically. Basically, awesome’s ‘beautiful’ library takes your typed out command and executes that in order to set the wallpaper, feh has a convenient way of storing the default wallpaper by simply dumping the command that was used to set it up in the first place in a configuration file in your home directory, hence the eval `cat whatever` trick.

Screenshot of my new wallpaper in Awesome

Screenshot of my new wallpaper in Awesome

P.S.: Don’t think you can leave out the call to os.getenv() in step 3, awesome doesn’t expand the tilde (’~'), so the path it’ll try to access will be invalid.

P.P.S.: This is more of a note for me, in case I ever lose my epic new wallpaper. It can be found here.