Archive for the 'ubuntu' Category

Firefox 3 Thumb Button brings up Save As dialog

Thursday, October 2nd, 2008

This has been driving me nuts since I have upgraded to Firefox 3.0.1 on my laptop like a month ago. I’m still running Gutsy on that thing, and only the beta version (which crashes a lot) is in the repositories. So I pretty much did the same thing as back when FF 2.0 came out and I was running dapper. I snagged the statically linked linux binary from the website, dumped it into /opt/firefox and un-installed the old version. It works fine with a single exception - my thumb button was acting weird as hell.

This requires some explaining. I’m using Logitech VX Revolution wireless mouse and the btnx to detect and remap all the additional buttons on the mouse. I configured it so that the back and forward thumb buttons are set to emulate the Alt+ left arrow key and Alt+ right arrow key. These are of course Firefox shortcuts for Back and Forward controls.

To tell you the truth, I actually forgot how to press the back and forward buttons on the FF chrome. I just never do it. At home I am using MS Sidewinder mouse which also has convenient thumb buttons. I always use them while browsing because it is just so much faster than anything else. Faster than keyboard shortcuts because when I’m browsing one of my hands is usually holding the mouse. So thumb buttons are perfect for quick flicking back and forward between pages and I miss them when I’m forced to use a mouse which doesn’t have them.

Ever since I started using FF 3.0.1 on my laptop the back thumb button started doing something weird. In addition to sending the browser the “Back” signal it would also invoke the “Save As” dialog. Yes, it would just pop up in the middle of the screen. Attempting to use the dialog would be futile however. I tried to actually save whatever it was asking me to save several times, but Firefox never actually produced any files as a result of using this particular dialog.

It was nothing more than a constant annoyance. Every time I tried to go back a page, I would have to cancel this dialog. It was actually more annoying than clicking the buttons manually, or taking my hand off the mouse do do the Alt+ Left Arrow thing. Since then I have reconfigured btnx dozens of times, and kept searching Google for a possible solution. No luck. Eventually I figured out this had to be some Firefox setting and started digging in about:config.

Through bunch of trial and error tests, and good amount of luck I finally managed to identify the culprit. If you have this problem, all you have to do is to set:

middlemouse.contentLoadURL = false

From mozilla knowledge base:

Background:

This preference determines how to handle middle clicks in the content area. It was split off from middlemouse.paste, which now handles middle clicks in text fields only.

Possible values and their effects:

True: Load the contents of the clipboard as a URL. (Default for Linux/Unix.)

False: Handle middle-clicks normally. (Default for all but Linux/Unix.)

I actually never, ever use this feature because 90% of the time the thing in my clipboard is not a loadable URL. Besides, since I switch between platforms a lot, I generally don’t get used to platform specific features like that.

I have no clue why this particular setting kept picking up the Back Thumb button as some sort of “Save As” invocation. Note that this was not happening in FF 2.x, so go figure. Setting it to false solved the issue for me. I can browse like a normal person again.

Hopefully this post will help some other poor soul frustrated by this issue. )

Easy Way to Create Simple Linux Packages

Tuesday, September 23rd, 2008

I just figured out how to create an installation package in any of the popular formats (deb, rpm, etc..) in under 30 seconds. This method is probably not something you’d want to use for a serious project, but it is perfect for small scale things such as shell scripts, or various perl/python/ruby concoctions you want to distribute.

Before i start, I must confess that I never really made a deb package from scratch. I did create debs before with stuff like checkinstall. For example I do it every time I install ffmpeg on one of my machines because for some reason that package is horribly, horribly broken in the repos and half the features are disabled. If you want a working copy, you have to grab the source and roll up a deb yourself.

I never created a deb for one of my own scripts because I never needed too. Most of the time stuff that I write ends up being a single script or an executable, which I stick in /usr/local/bin or just keep it in the home directory. If I distribute it, I always figured someone else could do exactly the same - grab the binary and stick it somewhere in the path.

But the other day I was like “maybe I’ll just make a deb for this one script here since I already have like a whole project page for it. And so I googled “How to make a deb” and got tons of excellent tutorials, each of which was at least 50 pages long. I figured I was doing something wrong because a simple thing like creating a package can’t be that complicated and the creators of these extremely detailed howto pages must simply be suffering from the common case of verbal diarrhea which seems to plague at least every third linux user.

I mean, it took me 10 minutes to write and debug this script. If wrapping it inside of a deb takes 3 hours, then we are in trouble. Fortunately I’m a very lazy individual, and instead of trying to follow one of these gargantuan howto articles, I decided to find a quicker way and installed the EPM package:

sudo aptitude install epm

EPM basically builds packages for you almost automatically. All you need to do in terms of setup is to create a single .list file in the same directory as your project. For example for Twimi I created the following file:

%product twimi
%copyright 2008 by Lukasz Grzegorz Maciak
%vendor Lukasz Grzegorz Maciak
%description A minimalistic, command line Twitter updater.
%version 0.4
%readme README
%license LICENSE
%requires curl
 
f 755 root sys /usr/bin/twimi twimi

I think the above is pretty much self explanatory. The first 8 lines are metadata which will be embedded in the deb - you know, the stuff that you can read when you do aptitude show. The last line specifies what to do with the project files during installation. The syntax for this command is pretty much this:

f  mode  user  group  destination  source

You can find more info about other prefixes (there is c for configuration files, d for creating directories and etc..) by running man epm.list. All I needed was to copy a single shell script to some directory in your path, and then make it executable, and that was accomplished with the single line above. No need for any other tinkering. I saved the file as twimi.list and created README and LICENSE files because apparently epm expects them. You can leave them empty, but they need to be there for some reason.

Once you have all of this set up, you can create a deb by running the following command (where you’d replace twimi with the name of your project naturally):

sudo epm -f deb twimi

KABLAM! The deb will magically appear in a subdirectory named after your platform and architecture - for me it was linux-2.6-intel. Added benefit is that you can use the same .list file to generate other types of packages. Observe:

sudo epm -f rpm twimi

In addition to basic linux packages can apparently also make osx and bsd ones as well - but you will need the prerequisite package management tools for those systems installed. So I couldn’t really create an osx package (and I don’t own a mac so I don’t know how would I test it), but the option is there if you need it.

Undoubtedly someone will probably tell me there is an easier and more straightforward way to do this kind of stuff. This method worked for me, but if there is another more proper, and equally straightforward way I’d love to hear about it.

VirtualBox B0rken By Gutsy Kernel Upgrade

Tuesday, June 24th, 2008

I still have Gutsy on my work computer. I should really upgrade it to Hardy but unfortunately “dist upgrade in progress” is not really an acceptable excuse for not doing actual work so I keep putting it away. Ideally I could probably just run dist-upgrade during my lunch break, and then come back to a fully upgraded system. But every single dist-upgrade I did in the past required some babysitting so I’m not expecting this one to be any different. So for the time being I will stick with Gutsy - at least until I carve out a good chunk of time to devote to upgrading it, and potentially fixing anything that broke in the process.

Then again, maybe if I have upgraded earlier I wouldn’t have this VirtualBox issue today. At work I’m usually running a Windows XP instance inside VirtualBox so that I can access and use various Windows specific apps. Yesterday it just stopped working - it simply wouldn’t boot telling me that a wrong kernel module is installed. I wish I took a screenshot of the error message but I didn’t. Instead I started troubleshooting. First I needed to find out which version of kernel was installed on my machine:

lmaciak@malekith:~$ uname -a
Linux malekith 2.6.22-15-generic #1 SMP Tue Jun 10 09:21:34 UTC 2008 i686 GNU/Linux

It seems that my Kernel is 2.5.22-15. I vaguely remember pulling down some updates on Friday morning. A new kernel was among them, I believe. Next I took a quick peak on my VirtualBox installation:

lmaciak@malekith:~$ aptitude search virtualbox-ose-modules
i   virtualbox-ose-modules                   -
i   virtualbox-ose-modules-2.6.22-14-generic - virtualbox-ose modules for linux-image-2.6.22-14-generic
p   virtualbox-ose-modules-2.6.22-14-server  - virtualbox-ose modules for linux-image-2.6.22-14-server

It immediately became clear - there is a mismatch between my kernel and the installed modules. Unfortunately the only VirtualBox kernel modules in the repositories were the 2.6.22-14 ones. A 2.6.22-15 version simply doesn’t exist. Not for Gutsy at least and the Hardy release has to many unresolved independecies. So if you are still on Gutsy for some reason (like me) and you just updated your kernel (like me) you are now totally screwed (like me). The OSE version of VirtualBox just won’t work and there is no solution for this yet - and there may never be since Gutsy is on it’s way out.

There is a quick workaround though. Ditch the OSE version, and use the non-free binary under the PUEL License. I believe that my use of the software falls uder the “Personal use or Evaluation” clause since I’m not using it for hosting, and not sharing or distributing it. And I will likely only keep it only until I upgrade to Hardy.

If you are in the same boat, here is what you do. First get rid of your current VirtualBox installation:

sudo aptitude remove virtualbox-ose

Next, head over to the sun download page and grab yourself an appropriate deb file (pick Gutsy from the pull-down list). Install it via dpkg:

dpkg -i virtualbox_1.6.2-31466_Ubuntu_gutsy_i386.deb

It will go through the motions, and you may need to acknowledge one or two prompts as it configures appropriate kernel module. Once it is done, you should be all set. Please note that /usr/bin/virtualbox is unlinked replaced by /usr/bin/VirtualBox (note the camel case) which means any old aliases, shortcuts and key bindings will no longer work. You will have to manually adjust them. Other than that, the difference between the two versions in minimal. They use slightly different icons, and a different splash screen but for the most part it is the same software and you can easily use your regular VirtualBox images.

I hope this will help any potentially pissed off VirtualBox users who are still clinging to Gutsy for whatever reason. mrgreen

Ubuntu Hardy on Compaq Presario 1240 (Living Without X)

Tuesday, June 10th, 2008

Well, the Nethack Server is gone. I know that couple of people played on it, and Anthony even ascended but it is now gone. It was actually off line for months now and I didn’t even notice. It got knocked off the network when I switched from WEP to WPA few months ago. Then it crashed hard and sat there for another month or two without a reboot. Now I have some nice dead pixels on the LCD which I guess might be sort of a screen-burn side effect or something. It was acting slow, and erratic so I nuked it. I should have saved the high scores and the bones files but hindsight is always 20/20. So big apologies to anyone who played on the server. I might resurrect it at some point, but I guess the old Presario with the flaky Wifi is just not a very reliable platform for something like that.

It is a good platform for experimenting with bare bones installations. I always wanted to set up an X-less machine and see how usable it would be. I already have a library of very useful CLI apps so really this should be a great experiment. I briefly messed around with a net install of Debian Etch but in the end I went right back to what I know and decided to give Hardy a whirl. It would be a nice test to see how the brand new system stacks up on very old hardware.

So I grabbed the mini ISO, and run it with the cli boot parameter. Why the mini iso? To make a long story short, I wasted 4 CD’s burning corrupted copies of the alternate install CD. What I wanted was a bare bones CLI system but every time I started installation some file was corrupted. I guess this will teach me to check the md5 checksums before burning next time. Either way, the minimal install ISO seemed like a good solution - weighing in at 8MB wouldn’t get corrupted during transfer.

Installation was uneventful, but tad long since a lot of packages needed to be downloaded. I ended up with a lean CLI system. Since I initially did not want to install X on it, the first thing I did was to update my tty resolution This is done by editing the grub menu like this:

sudo vim /boot/grub/menu.lst

You will see something like this:

title      Ubuntu, kernel 2.6.15-20-386
root      (hd0,4)
kernel    /boot/vmlinuz-2.6.15-20-386 root=/dev/hda5 ro
initrd    /boot/initrd.img-2.6.15-20-386
savedefault
boot

The Compaq can only handle 800×600 with 24 bit color at most, so I add the following to the kernel line:

vga=789

The like should look like this once you are done with it:

kernel    /boot/vmlinuz-2.6.15-20-386 root=/dev/hda5 ro vga=789

Now how does the 789 relates to my resolution? Good question! You can find other magical values you can add to that line listed on the Ubuntu FrameBuffer wiki.

Next ting was setting up the wifi connection which was not that difficult. I ended up with a fully functional CLI system. I could browse the web with w3m, use Midnight Commander as my file system browser and etc. Btw, this takes me way back:

Compaq Presario 1240 Running Hardy

I sat there staring at this screen reminiscing all the good times I had working with Norton Commander back in the day. Oh man! These were the good days. I vividly remember excitement involved in unpacking a pirated copy of Wolfenstein 3D and Alone in the Dark and running it from the Norton interface. Ah, these were the days. I was young, naive and was just discovering wonders of technology. Unfortunately, I seem to be the only person with fond memories of that time. When my brother saw the screen, he made a face and exclaimed: “man, I used to hate that thing”. But how can you hate the commander? I mean, it’s a fucking commander! It commands respect! Here is a better shot of the app itself running in 800×600 mode on the tty:

Midnight Commander on Hardy

My cousin had a similar reaction. She pretty much said “You know, it’s 2008 - you can use Windows Explorer now”. cry No, thank you - I will stick with linux and my ultra light applications that hardly take up any memory and/or CPU power to run.

But I wanted a little bit more flexibility. Swapping between TTY’s all the time is not always the optimal solution. Sometimes I would for example want to split my screen into 2 or 4 panels with different content. Screen does that, but it does not do vertical splits out of the box. You can get that functionality by applying a patch and recompiling, but I decided to get something a tad more complex. So I turned to DVTM which is labeled as a tiling window manager for the CLI. It’s not in the repositories so you have to compile it yourself:

aptitude install make build-essential libncurses5-dev
wget http://www.brain-dump.org/projects/dvtm/dvtm-0.4.1.tar.gz
tar -xzf dvtm-0.4.1.tar.gz
cd dvtm-0.4.1/
make
sudo make install

The result is pretty neat. You can see me running a split panel session with htom (upper left), aptitude doing updates (upper right), and w3m (bottom):

DVTM Running in a TTY

DVTM has two major disadvantages. First is that you loose all the neat framebuffer features - for example like the images being displayed in w3m. No drawing or image viewing utilities will work in it - just like they don’t work in screen. Seconly, DVTM is not very configurable. There is no dot file (like .dvtmrc or something) that you could use to customize settings, set default layout and etc. The author suggests changing the configuration in one of the .h files, and then recompiling the whole thing every time you want to change something. ( Not really what I want to do.

Finally I broke down, and decided that that running mimimal x configuration with Ratpoison is not much more taxing on the hardware. I still intended to use mostly CLI apps (since that’s really what Ratpoison is all about) but the possibility of actually being able to run some gui apps (such as Dillo or Kazekahese for example) was a nice touch. Installing ratpoison was easy:

aptitude install x-window-system-core ratpoison
aptitude install xserver-xorg-video-vesa xserver-xorg-input-mouse

I got a lot of scrolling text on my barebones install (over 30 MB of x related packages) but installation was swift and simple. But it was not perfect. If you follow these instructions you will notice that the display is bit “gritty” and pixelated under this setup. This bothered me a bit. Running lshw told me that this system actually has NeoMagic NM2160 MagicGraph 128XD card installed on board. Quick aptitude search told me that there is a package which caters to this brand of graphic devices. To get full use out of your card you will need to do:

aptitude install xserver-xorg-video-neomagic

After that, the image was crystal clear and sharp as ever.

Now my rig starts in cli mode, but and I can continue like that. If I need X for some reason I can start it manually, and it actually takes about 2 seconds to start up. Ratpoison is rather nifty - and not much different from dvtm, only it uses X and is completely configurable. Here is a screenshot of me running htom (upper right), Midnight Commander (upper left) and opera (bottom):

Ratpoison!

Here is something that I did not expect or anticipate: Opera actually outperforms Kazehekaese on this machine. It’s bizzare but true. I guess the geko engine was choking due to limited memory or something.

I might try another windowing manager like awesome at some point in the future because of the floating window feature. Ratpoison only knows how to tile windows which is fine but not really practical in the long run. As you can see on the screenshot above, the 3 way split is already kinda cluttered. Add 2-3 more panels, and you won’t be able to see anything on any of them. With mere 800×600 resolution, the screen estate on that thing is priceless.

Anyway, for those interested my .ratpoisonrc looks like this:

bind c exec rxvt -fn "Lucida Console-8"
bind b exec links2 -g
wrap off
escape Pause
 
exec xsetroot -solid black -cursor_name left_ptr
exec xli -onroot -fullscreen /home/luke/eva.jpg

Note that I remapped the escape key from Ctrl+T to Pause mainly because of the keyboard layout. On the laptop keyboard the Ctrl+T becomes a two hand salute due to the weird positioning of the keys. Pause on the other hand is strangely withing the reach of my right hand. Go figure.

One thing that did not work well under Ratpoison was Midnight Commander. Something about rxvt and mc not agreeing on the locale settings. It was easily resolved by adding the following line to my .basrc:

LANG=C

I’m also bound a key for links2 since it is really the faster, and more responsive browser on this machine. If needed I can always launch opera, but for quick lookups links2 is more than enough.

So there you have it - it’s a minimalistic system, which runs mainly CLI apps. It does have X but it does not need to be running. And when it does it uses ultra light window manager that is also stripped down for simplicity and performance. What do you think?

Linksys WPC54G ver. 1.2 with WPA on Hardy

Monday, June 9th, 2008

I’m pleased to say that my old trusty Linksys WPC54G ver 1.2 works without ndiswrapper Hardy Heron. I have been using this card since Hoary, but never “natively”. My last attempt at installing it was under Feisty and I failed. Whether it was me or Feisty being… Well, feisty and uncooperative remains to be determined. You were supposed to do something like this:

sudo aptitude install bcm43xx-fwcutter
sudo bcm43xx-fwcutter -w /lib/firmware/ ~/bcmwl5.sys

Where bcmwl5.sys was the original Windows driver you could obtain from the linksys ftp site. It did not work for me, and I ended up falling back on ndiswrapper like usual which always worked, but was always flaky.

I figured I might as well try the bcm43xx trick under Hardy. Things generally improve over time, and old bugs and quirky behaviors go away - it’s not like Debian where you get a stable release once in a century. Unfortunately, it once again failed miserably. Or rather I failed. Or perhaps, should I say we had a miscommunication. I asked Hardy to use the bcm43xx module and he did exactly that - despite the fact it was the wrong thing to use.

What I didn’t notice was that some sort of a switcharoo took place, and this time around the errors spewed forth by the card were something among the lines of: b43/ucode5.fw” not found. As you can probably see, they did not mention bcm43xx anywhere, but I assume that b43 == bcm43xx. I assumed wrong. They are two different modules. So how do you make the card work under Hardy? Like this:

sudo aptitude install b43-fwcutter

Yep, that’s it.It automatically pull down the relevant firmware, cut it and throw the relevant .fw files into /lib/firmware automagically. It’s that easy. This is what happens when you assume the “well, this worked last time so I’m just gonna keep trying and ignore this very helpful error message right here cause I know better” stance.

My next task was of course to configure the system to use WPA. Ubuntu is nice enough to support it out of the box via the wpa_supplican package - not all distros do though. Etch ships without it, and it took me a while before I figured out why I couldn’t connect. My Gutsy laptop had no issues picking up the Wifi in my house. All I had to do was to pick the network from a list using knetworkmanager, type in my passphrase and I was ready to go. It would be a bit more difficult with this system, because I was building it bare bones, without any window manager.

How do you set up WPA without the GUI? There is a really nice writeup in Ubuntu forums that shows you what you need to do. Let me summarize it here, for future reference.

First you need to convert your pass phrase to an actual hex key. You do this by running the following command:

wpa_passphrase my_ssid "my long passphrase"

If your passphrase is an actual phrase (ie. it contains spaces as it should) you will need to put it in quotation marks. The output will look something like this:

network={
    ssid="my_ssid"
    #psk="12345678"
    psk=fe727aa8b64ac9b3f54c72432da14faed933ea511ecab1 5bbc6c52e7522f709a
}

You are interested in the last line - the psk value. Copy it, save it or hold on to it in some way. Next open up your /etc/network/interfaces and add the following lines to the bottom:

auto wlan0
iface wlan0 inet dhcp
wpa-driver wext
wpa-ssid <your_essid>
wpa-ap-scan 1
wpa-proto WPA
wpa-pairwise TKIP
wpa-group TKIP
wpa-key-mgmt WPA-PSK
wpa-psk <your_calculated_psk_key>

The last line is where you paste in that long hex key we calculated in the previous step. Now running:

sudo ifup wlan0

should bring your wireless up, authenticate and negotiate an IP from the DHCP. The first line, will automate this process so that every time you boot, or insert your card into the machine, it will try to authenticate and connect.

There is one small issue with this setup that I noticed. The LED’s on my card no longer work, but that might be unrelated to this setup. They worked when I was using it under Feisty with ndiswrapper, and it did lit up when I briefly experimented with Debian Etch on this system. But they never switched on under Hardy for some reason. Then again, maybe the card just had it - I’ve been using it for few years now, and it is a little bit “bent” from that one time, I forgot to take it out before putting the laptop in my bag. so perhaps the LED’s just died a natural death. The card still works though.