Pages

Showing posts with label Squeeze. Show all posts
Showing posts with label Squeeze. Show all posts

July 18, 2011

Fixing ugly Qt fonts in Openbox, Fluxbox, etc.

On Debian Squeeze at least, unless you are using GNOME or Xfce (or ostensibly KDE) or are running the configuration daemons that come with these, fonts rendered by Qt apps look like utter crap.

It seems that Qt honors neither ~/.fonts.conf, nor what's in ~/.fonts.conf.d, nor what's in /etc/fonts/conf.d. This is a problem if you want to run light-and-lean and not use the GNOME or Xfce daemons in Openbox, Fluxbox, and likely many other window managers.

After much hair pulling, I finally managed to work around the problem by using Xresources. Adding the code below to either ~/.Xresources (for user-only changes) or to a new file /etc/X11/Xresources/fonts-default (for system-wide changes) fixed the issue for me. It also fixes problems with ugly font rendering in OpenOffice.org and LibreOffice.

What I added is:
Xft.dpi: 96
Xft.antialias: true
Xft.hinting: true
Xft.rgba: rgb
Xft.autohint: false
Xft.hintstyle: hintslight
Xft.lcdfilter: lcddefault

The dpi entry is there just for good measure. Change settings as needed according to taste.

June 25, 2011

Squeeze, Fonts, Firefox update

This is good.

This morning I finished upgrading a Lenny installation to Squeeze. (For those of you who might know what's coming next, this installation had the plain old standard libcairo2 -- no patches of any sort.) So far things seem to be just fine. But it's Debian and so this is no big surprise. This is not why I'm writing this post.

The reason for writing this post is to let you know that indeed the rumors are true. Installing Iceweasel 5 from http://mozilla.debian.net/ solves three problems that have plagued lots of Linux users:
  1. Obsolete Iceweasel/Firefox.
  2. Ugly font rendering with official Firefox binaries.
  3. Ugly font rendering everywhere on the system.
You heard it right, folks. Installing Iceweasel 5 in Squeeze brings in a version of libcairo2 with all the yummy Ubuntu font rendering goodness. Like I said, this is good.

But there are a couple small gotchas:

Confusing instructions
The directions given at http://mozilla.debian.net/ are complete, but the order in which the info is given is confusing. So here is what you need to do, in the order in which you need to do it.
  1. Add the following entry to /etc/apt/sources.list or a new file in /etc/apt/sources.list.d/:
    deb http://mozilla.debian.net/ squeeze-backports iceweasel-release
  2. Add the archive key to your apt keyring:
    # wget -O- -q http://mozilla.debian.net/archive.asc | gpg --import

  3. Import it into the APT keyring:
    # gpg --export -a 06C4AE2A | sudo apt-key add -

  4. Update the repository database:
    # apt-get update

  5. Install Iceweasel 5 with the following command:
    # apt-get install -t squeeze-backports iceweasel

Configuring fonts
After I did the above, fonts were still not quite right. So I added the ~/.fonts.conf  file posted here here*. (Blogger, please make it possible to post code with angled brackets!!)

I don't know which is the magic setting responsible for letting the fonts come out all pretty (I suspect lcdfilter), but I'm happy enough with the results now that I'll just be using the setup for a while. It's only a process of elimination to figure out which setting is the key, and once it's found it should be an easy matter to make these the system default so you don't need the ~/.fonts.conf file.

[update 2011-07-11: Changed sources.list addition to reflect changes at http://mozilla.debian.net/.] 
*[update 2011-07-01: I added rgba settings for completeness.]

April 02, 2011

Installing the Qt SDK

Update: Bits of this have been obsoleted with the 4.7.3 release. I'll try to post an update soon. [09 May 2011]

Because I live fast and loose and on the bleeding edge, I decided to install the Qt SDK using the Nokia download rather than from my distros' package manager. Actually, the real reason is that I was seeing a weird message in the debugger in Qt Creator on Ubuntu 10.10 and hoped the a newer SDK would fix that. But alas it did not--on neither my Ubuntu nor my Debian Squeeze development system. But I will continue to use the downloaded SDK because it will let me update to the latest versions.*

What follows is a brief guide to help you integrate the downloaded SDK into your system should you opt to do so.

The most important difference between installing the downloaded SDK versus installing from the repositories is that the downloaded install will only install for a single user.** The installation itself is pretty straightforward:
  1. Download the installer.
  2. Make the installer executable: In a term open to the directory where you downloaded the installer, enter the command
    $ chmod u+x {the-name-of-the-installer}
    In my case {the-name-of-the-installer} was qt-sdk-linux-x86-opensource-2010.05.1.bin
  3. In the same term, issue
    $ ./{the-name-of-the-installer}
    and follow the resulting directions. The installer will let you pick the directory where the SDK will go. Don't feel obliged to use the default. Because I didn't want another visible directory in my home directory, I installed into ~/.opt/qtsdk.
The above will install all the SDK bits in the specified directory and create two *.desktop entries for the Qt Creator IDE: one on your desktop (drag it to the trash) and the other in your ~/.local/share/applications directory--so that you get a menu entry for it.

Adding some missing bits
The above process gives you a working SDK that's well suited to using the Qt Creator IDE. However, for more general work there are a few things missing:
  1. qmake and other executables will not be available as system commands
  2. There is no menu entry for the Qt Designer GUI layout tool.
The first is required if you plan to do Qt development with another IDE (Netbeans, Eclipse, Monkey Studio, etc.). The second is nice to have in any case. Both are fairly easy to fix.

Making the SDK commands available
To do this we are going to edit your .profile file. Before making changes to your .profile, make a backup of it so you can get back to it easily if you break something! If you have also installed the SDK from the repositories, what follows will cause the repository commands to be overridden by the commands in the local SDK. If you don't want this, then don't do this.

Open ~/.profile in a text editor. Toward the bottom, add the following:
# set PATH so it includes local Qt SDK tools
QTSDK_LOCATION=$HOME/.opt/qtsdk
if [ -d "$QTSDK_LOCATION/qt/bin" ] ; then
    PATH="$QTSDK_LOCATION/qt/bin:$PATH"
fi
if [ -d "$QTSDK_LOCATION/bin" ] ; then
    PATH="$QTSDK_LOCATION/bin:$PATH"
fi
making sure to change QTSDK_LOCATION as needed for your installation. When you logout and log back in, the executables in the two bin directories should be available as commands. Test this by issuing
$ qmake -v
in a term. The output should make sense.

Adding an entry for Qt Designer to the menu
Assuming you have done the stuff in Making the SDK commands available, you can just add the following file as Nokia-QtDesigner.desktop to ~/.local/share/applications
[Desktop Entry]
Value=1.0
Type=Application
Encoding=UTF-8
Exec=designer %F
Name=Qt Designer
GenericName=GUI designer for Qt applications
X-KDE-StartupNotify=true
StartupNotify=true
Icon=Nokia-QtCreator
Terminal=false
Type=Application
Categories=Development

If you have not done the Making the SDK commands available stuff, then change the Exec= line to point directly at the designer executable (which should be in {qtsdk}/qt/bin)

Now I'm going to move on to testing alternatives to Qt Creator. Qt Creator has a very nice feature set, but the UI is a bit quirky. I'll let you know if I find anything I like better.

* A possible consequence of this is that installing extra bits and baubles will no longer be easy. For example, it seems the Qt4 Designer plugin for QScintilla 2 (libqscintilla2-designer in Debian-land) doesn't ship with Nokia's SDK, and I don't know if Qt Designer will pick up libs installed in standard system library locations.
** I'm quite certain that you can install the downloaded SDK for all users, for example by installing as root into /opt. However, doing so may generate *.desktop files on root's desktop and in root's .local/share/applications dir, and I am not sure if that will mess anything up. If you try this, please let me know how it worked for you.

March 23, 2011

Debian Firefox 4 Font Failure

[Update 2011-06-25: You should consider this post obsolete. See this post for more info. Iceweasel 5 installs most beautifully on Wheezy.] 
 
I just tried building Firefox 4 on Debian Wheezy. I build Firefox for my machines because (1) I want the latest FF and (2) I want subpixel rendering--which tends to get turned off sometimes|always in Debian and Ubuntu builds of Firefox and Iceweasel.

My first attempt failed. Why? Because if you enable-system-cairo in the build, FF4 insists that you have at least version 1.10 of libcairo2--and Wheezy and Squeeze are both at 1.8.10. One upshot of this is that there will be no way for Squeeze users to get subpixel rendering in FF4 using the default libcairo2 packages. Wheezy users will have to wait until the current Sid packages trickle down. Once that happens, it theoretically will be possible to backport the Wheezy libcairo2 to Squeeze (with patches even) , but I am frankly getting a little tired of this.

I am now making a second attempt to build FF4 wherein I did not enable-system-cairo, and it seems to building just fine. That should be ready for testing in another hour or so. But of course I expect font rendering to be just tragically bad. (Update: it built and runs fine and renders fonts every bit as badly as I expected.)

Tomorrow I will probably try building FF4 on Ubuntu 10.10, whose libcairo2 is at 1.10. I tried running the Linux prebuilt binaries from Mozilla on my Ubuntu machine, but as I have come to expect from Mozilla's FF builds, cairo did not seem to be enabled. (Update: Building on Ubuntu also failed. Apparently FF4 with enable-system-cairo also needs cairo-tee greater than 1.10, but Ubuntu's libcairo2 doesn't seem to be built with --enable-tee=yes.)

It seems every other post of mine in the last couple years has dealt with the agonies I've had in getting consistently good font rendering in Linux. It really shouldn't be this difficult.

December 20, 2010

XDG menus in Openbox

Now I feel stupid. For year(s) I've been sorta griping about how the Openbox menu doesn't give you a program listing that coincides with what you get in GNOME, Xfce, and even fbpanel. I've hunted for solutions to this before but came up short. Turns out the solution is insanely simple.

The following is a direct quote from from the excellent ArchWiki. I tried it in Ubuntu Maverick and it works.

Obm-xdg

obm-xdg is a command-line tool that comes with Obmenu. It can generate a categorized sub-menu of installed GTK/GNOME applications.

To use obm-xdg, add the following line to ~/.config/openbox/menu.xml:

{menu execute="obm-xdg" id="xdg-menu" label="xdg"/}

(note: the curly brackets above should actually be angled brackets, but this crazy Blogger interface makes it close to impossible to write the above with angled brackets.)

Then run openbox --reconfigure to refresh the Openbox menu. You should now see a sub-menu labeled xdg in your menu.

Note: If you do not have GNOME installed, then you need to install gnome-menus package for obm-xdg to work.

Update: This is having issues on Squeeze. More later as I (if I) figure it out.

October 19, 2010

Enabling touchpad clicking and edge scrolling in Squeeze

Gnome has a mouse configuration interface that lets you enable touchpad clicking and scrolling. But if you are a Debian Squeeze user and prefer Xfce, LXDE, or some handmade alternative, you will find that your touchpad's clicking and edge scrolling won't work [1]. You'll also find that those functions don't work in the GDM login screen even if you do use Gnome. No probs. The fix is easy.

To fix:
  1. Open  /usr/share/X11/xorg.conf.d/50-synaptics.conf (as root) in an editor.
  2. Add the text
    Option "TapButton1" "1"
    Option "VertEdgeScroll" "1"

    between Section "InputClass" and EndSection.
  3. Save, reboot and enjoy.
Note that if you use Gnome, you might find that your old mouse settings are messed up after the above. Set them again and all should be fine.

If you don't like the idea of changing system config files, you can use synclient in a startup script to enable things as well.

Useful links:

[1] At least at the time of this writing. When Squeeze is eventually released, this may change.

October 14, 2010

Fixing brightnes control, etc. on a Samsung R510 with Debian Squeeze

I finally got around to installing Linux on my Samsung R510 laptop. One of the problems with Samsung laptops is that they don't play well with some Linux standards. One example is the brightness control--it just doesn't work. There are some other issues that are less irritating, but this one is the worst for me.

There is a fix for these ails that was developed for Ubuntu (some of which is also at Google code.). The problem is that my current distribution of choice is Debian Testing (Squeeze). The good news is that these bits developed for Ubuntu can be used in Squeeze as well.

We need to install three different packages: easy-slow-down-manager, samsung-backlight, and samsung-tools. Here's what I did after installing Squeeze with Gnome on the R510:

easy-slow-down-manager
Download the Maverick *.deb for easy-slow-down-manager from from https://launchpad.net/~voria/+archive/ppa and install it directly with gdebi or your favorite package installer. It's all DKMS source code, so installing the package in Squeeze should be ok.

samsung-backlight
Downloaded the Maverick *.deb for samsung-backlight from from https://launchpad.net/~voria/+archive/ppa and install it directly with gdebi or your favorite package installer. Like easy-slow-down-manager, it's all DKMS source, so installing the package in Squeeze should be ok.

With a lot of Samsung laptops, we'd be done with these two packages. Sadly, the R510 needs some extra love. The following is taken almost verbatim from http://www.voria.org/forum/viewtopic.php?f=3&t=516&start=0&hilit=r510

First (as root):
# gedit /lib/udev/rules.d/95-keyboard-force-release.rules

In the Samsung section you will see a line with *N130*|*N140* etc. Add |*R510* there

Do the same for:
# gedit /lib/udev/rules.d/95-keymap.rules

Next, add "acpi_backlight=vendor" to grub:
# gedit /etc/default/grub

and add "acpi_backlight=vendor" to the line GRUB_CMDLINE_LINUX_DEFAULT so it looks like
GRUB_CMDLINE_LINUX_DEFAULT="quiet acpi_backlight=vendor"

Save the file and then update grub:
# update-grub

samsung-tools
It may or may not be ok to install the Ubuntu package for samsung-tools on Squeeze, but since it's got binaries in it, this is risky. I decided to download the sources and build a package on the Squeeze-equipped R510 instead. Start by getting some build tools:
# apt-get install build-essential devscripts fakeroot

Then from https://launchpad.net/~voria/+archive/ppa get the Maverick *.tar.gz sources for samsung-tools. Expand the *.tar.gz and inside the directory that has the debian directory (i.e., not in the debian directory, but in the directory immediately above), open a term and:

dch -l {your initials}

and add comment like "Compiled for Debian." Close the editor and in the term build the package with:
dpkg-buildpackage -rfakeroot -us -uc

You may need to add additional dependencies if it fails. Pay attention to the error messages. Assuming it completes, this will generate a *.deb package file. Install it using gdebi or whatever.

After rebooting, you should now have working brightness buttons and a host of other working {Fn}-{Fsomething} keys. You will also have a new app under System->Preferences->Samsung Tools Preferences that you can use to change keybindings, etc and/or run as a Gnome panel app.

If it doesn't work
If the above doesn't work, you may be interested in playing with brightung. I haven't played with it except to confirm that (as root)

# setpci -s 00:02.0 F4.B={some-hex-number}

changes the brightness on my R510.

Workaround for installing desktops in Squeeze

I've done a couple new Debian Testing installations in the last couple days and have noticed something strange in the installer. At a point in the installation process, you will be offered a menu of choices for major package bundles to be installed. If you want a desktop environment, you're supposed to select "Desktop environment." In the past when I did this, the following screen would offer you a choice of DTEs including Gnome, KDE, Xfce, and LXDE. However, the last few installs I tried did not. And exactly what it installs I'm not sure because I wasn't willing to wait 3 hours (at my connection speeds) for the download and install process to complete. So here's the workaround:

First, using the installer, install the system you want but do not install a desktop environment. 

When the installation completes, login using the command line. Then become root
su

Next, make sure you have tasksel installed:
# apt-get install aptitude tasksel

Finally, use tasksel to install your desktop. To install Gnome:
# tasksel install gnome-desktop --new-install

Reboot:
# reboot

and when your computer restarts, you should be good to go.

September 29, 2010

Scrpit for building Debian Squeeze libcairo2 with Ubuntu patches

[Update 2011-06-25: Indeed, you should consider this post obsolete. See this post for more info.] 
[Update 2011-06-24: This whole business may be unnecessary as it appears installing a recent version of Iceweasel from http://mozilla.debian.net/ also installs new libcairo2 with decent font rendering. I've yet to do careful comparisons, but it's possible that this solves both "ugly rendering in general" as well as "ugly rendering in Firefox" issues.]
[Update 2011-03-06 Reader datSilencer points out that the location of the Arch patch has changed. I have updated the script to reflect the change.]

Based on the post I wrote earlier, which is itself based on work published in a CrunchBang Linux Forum thread and by quanliking, I put together a script for quasi-automatically building libcario2 for Squeeze using the Ubuntu and Arch patches.

You can get the script at http://download.tuxfamily.org/skinny/libcairo2-patched/build-libcairo2.sh.

Prerequisites
  • Enable sources in your /etc/apt/sources.list (i.e.,  make sure sources.list has something similar to deb-src http://ftp.us.debian.org/debian/ squeeze main non-free contrib in it). If you make any changes, be sure to # apt-get update
  • # apt-get install build-essential devscripts fakeroot
  • # apt-get build-dep cairo
To use
  1. Download build-libcairo2.sh into the directory where you plan to build the packages. I recommend you start with a dedicated and empty directory.
  2. Open the script in a text editor and change the constants at the top as documented.
  3. Make the script executable and execute it:
    $ chmod +x build-libcairo2.sh
    $ ./build-libcairo2.sh
  4. Part of the way through, it will prompt you to fill in a line that opens in your default CLI editor. Do what it asks.
  5. When it's finished, open a term and follow the directions to install.
Rebuilding
When it comes time to rebuild (i.e., after a new Debian release) you must start over with an empty directory. Or at the very least, you must rename the top-level folder named libcairo2 that your previous build generated. This is to make sure that you get the most recent everything and that there are no goofy problems that might lead to a build that melts Arctic ice or increases the mercury content of fish.

Todo
An obvious bit of low-hanging fruit is to make entering of version info interactive, but it's arguable that that would be easier and less error prone that editing the script.

To round this out, we also need an additional script or package that adds the needed files from Ubuntu's fontconfig-config package to /etc/fonts/conf.avail and /etc/fonts/conf.d.

Notes
I uploaded the i386 packages that I built for my own use to http://download.tuxfamily.org/skinny/libcairo2-patched. Feel free to try these if you don't feel like building them yourself. However, I'm not making any promises that I'll keep these up-to-date.

Legal disclaimer
I have tested the code and packages mentioned here to make sure they don't bruise kittens or eat children. However, I wrote and built this stuff for my own use and have made it available here with no warranty of any kind whatsoever in the hopes it might be useful to others. Use at your own risk.

July 15, 2010

Firefox 3.6 with pretty fonts in Debian Squeeze (easier version)

[Update 2011-06-25: You should consider this post obsolete. See this post for more info.] 
 
If all the Mercurial and Namoroka in my previous posts about building and installing Firefox 3.6 in Squeeze has your head spinning a bit, here's a simplified version that gets the sources via FTP. As was the case in the previous build, this version enables cairo so you get nicer font rendering. This version also configures the build to use official Mozilla Firefox branding so you don't get Deer Park icons and such.

Preproduction
1) Create a working directory. Use a file manger or whatever you are comfortable with to do this. I called mine ~/firefox-release.

2) Get all the tools and things you need to build Firefox. In a terminal as root (using su):

# apt-get build-dep iceweasel
# apt-get install libasound2-dev libcurl4-openssl-dev libnotify-dev libxt-dev libiw-dev mesa-common-dev autoconf2.13 yasm
# apt-get install libidl-dev


Get and build
1) Get the source code. Open a web browser or ftp client and go to ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/3.6.6/source/. Download firefox-3.6.6.source.tar.bz2 into ~/firefox-release. (If 3.6.6 is no longer the most recent version, then replace 3.6.6 above with whatever the most recent 3.6 happens to be.)

2) Extract the archive you downloaded. Use tar -jxvf *.tar.bz2 on the command line or whatever GUI tool you are comfortable with. This will give you a mozilla-1.9.2 directory inside ~/firefox-release.

3) Make a configuration file. Create a new file inside ~/firefox-release/mozilla-1.9.2 called mozconfig. Open mozconfig inside a text editor and paste in the following text:

. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/ff-release
#mk_add_options MOZ_MAKE_FLAGS="-j4"
ac_add_options --disable-debug
ac_add_options --disable-tests
ac_add_options --enable-optimize
ac_add_options --enable-official-branding
ac_add_options --enable-system-cairo

Save the file and exit the editor.

3) Build the beast by opening a terminal in ~/firefox-release/mozilla-1.9.2 and entering the following command:

make -f client.mk

Once the compile is done, the binaries will be in
~/firefox-release/mozilla-1.9.2/ff-release/dist/bin/.
As a test, execute the file firefox to make it go.

"Install"
1) Copy the contents of the bin directory to /opt, converting links to actual files. Do not try to copy the files with a file manager because it probably won't convert the links to files--which will render your "install" nonfunctional. Instead, open a terminal and go to ~/firefox-release/mozilla-1.9.2/ff-release/dist/. Then become root (using su) and do:

# cp -R -L bin /opt/firefox-release
# chown root:root -R /opt/firefox-release


You should now have a new directory in /opt called firefox-release. Inside it will be an executable file called firefox. If all went well, executing this file (NOT as root) will launch the browser.

2) Create a command that lets you launch the browser. As root, make a softlink from /usr/local/bin/firefox to /opt/firefox-release/firefox:

# ln -s /opt/firefox-release/firefox /usr/local/bin/firefox

3) Create a desktop file to introduce the new stuff to the menu. As root, create a file called firefox-release.desktop in /usr/local/share/applications (adding any directories that aren't already present.) Paste the following into firefox-release.desktop:

[Desktop Entry]
Encoding=UTF-8
Name=Firefox Release
Comment=Browse the World Wide Web
GenericName=Web Browser
X-GNOME-FullName=Firefox Web Browser
Exec=firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/firefox-release/icons/mozicon128.png
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;
StartupWMClass=Firefox-bin
StartupNotify=true
Name[en_US]=Firefox Release

Save the file and exit the editor.

You're done.

July 14, 2010

Fixing OpenOffice.org font rendering in Debian Squeeze

I guess I'm on a roll with font rendering improvements...

After patching libcario2 in Squeeze, I noticed font rendering in OpenOffice.org was really awful. It may have been equally awful before and I never noticed. In any case, it's now something that needs attention.

Ugly fonts in OO.org have been reported under Ubuntu and other distributions as well. A good explanation of the problem (in Ubuntu, at least) and a workable solution is offered by Mike Kasic about halfway down the bug report at https://bugs.launchpad.net/ubuntu/+source/cairo/+bug/271283. I tried his suggestions on my Squeeze installation, and it worked. If you don't want to be bothered filtering through the bug report, here's the executive summary.

Fixing just the session
Open a terminal and do:
echo "Xft.lcdfilter: lcddefault" | xrdb -merge

Making the fix persist across sessions
echo "Xft.lcdfilter: lcddefault" >> ~/.Xresources

Apply the fix for all users all the time
As root:
# sudo sh -c 'echo "Xft.lcdfilter: lcddefault" > /etc/X11/Xresources/lcd-filter-lcddefault'

Note: I have only tried the first two above. I have not tested applying the change to all users.

The fix also works on my Sabayon Linux 5 install that uses the lcdpatch in cairo.

"Installing" handmade Firefox 3.6 in Debian Squeeze

[Update 2011-06-25: You should consider this post obsolete. See this post for more info.]

Yesterday we saw how to build Firefox 3.6 from sources. This post shows you how to "install" it.

The reason I put "install" in quotes is because it's arguable that what we're going to do is a real installation. In a real Linux installation, you splay the various bits and pieces of your app into /usr/local/bin, /usr/local/share, /usr/local/lib, and various other places (or /usr/bin, /usr/share, /usr/lib if it's an official distribution package). What we are going to do here is take the easy way out--but a way that lots of "packages" take. We're going to dump stuff into /opt.

If you open up {whatever}/firefox-mercurial/192src/objdir-ff-release/dist/bin/ (or wherever you built your sources), you'll see that quite a few of the items in the bin directory are relative links to resources outside bin. If we try a conventional copy of the bin directory to /opt, what we get won't work because the targets of those links won't be copied. You could copy the whole objdir-ff-release to /opt, which will copy the needed link targets, but this will produce something many MB more than we need. The solution is to convert the links into targets themselves when you copy the file. This is actually pretty easy to do using the command line.

Copy the bin
Open a terminal in {whatever}/firefox-mercurial/192src/objdir-ff-release/dist. From there, become root (using su) and then:

# cp -R -L bin /opt/ff-from-src
# chown root:root -R /opt/ff-from-src


You should now have a new directory in /opt called ff-from-src. Inside it will be an executable file called firefox, and what used to be links will now be actual files. If all went well, executing this file (NOT as root) will launch the browser.

Making commands
We will next do a couple things to let you launch your new Firefox as a command and add an item to your menu.

1. Using whatever mechanism you are most comfortable with, make a softlink called firefox in /usr/local/bin to /opt/ff-from-src/firefox. You'll need to do this as root.

2. Add a png icon called firefox-namoroka.png to /usr/local/share/pixmaps/mozilla. You'll probably need to add the pixmaps and mozilla directories. Again you'll have to be root to do this. The icon can be whatever you want the icon to be in your menu. I used this one, even though it's the same one that Swiftfox uses. I wanted an icon that said "Firefox" but that differentiated itself from the stock FF icon. I scaled the icon to 128x128. Another nice icon is this one, but in spite of the attribution given on the page, I'm not sure it's actually GPL or where it originally came from.

3. Create a file called firefox-namoroka.desktop in /usr/local/share/applications again adding any directories you need and again as root. Copy/paste the following into firefox-namoroka.desktop:

[Desktop Entry]
Encoding=UTF-8
Name=Firefox Namoroka
Comment=Browse the World Wide Web
GenericName=Web Browser
X-GNOME-FullName=Firefox Web Browser
Exec=firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/usr/local/share/pixmaps/mozilla/firefox-namoroka.png
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;
StartupWMClass=Firefox-bin
StartupNotify=true
Name[en_US]=Firefox Namoroka

You should now have an entry in your desktop menu and other desktop integration niceness.

July 13, 2010

Firefox 3.6 with pretty fonts in Debian Squeeze

[Update 2011-06-25: You should consider this post obsolete. See this post for more info.] 

Iceweasel 3.6 has yet to trickle down to Debian Testing and very well may not make it before the freeze. However, some of us would like to have some 3.6iness in spite of this. If you've tried downloading SwiftFox, IceCat or the Firefox 3.6 binaries, you know that you get a 3.6, but the font rendering looks poopy.

Here's what I did to compile FF 3.6 from sources and get the same smooth font rendering that you get with Iceweasel 3.5 from the Squeeze repo. I'm not an expert, but this seems to have worked.

The following is based mostly on Mozilla's documentation on a Simple Firefox Build and Linux Prerequisites.

Preproduction
First, create a working directory. I called mine firefox-mercurial. The reason for the name will become obvious shortly.

Next, get the tools you need to build stuff. Since there's no firefox package in the Debian repos, I used (as root):

# apt-get build-dep iceweasel

Then install a bunch of other stuff that is supposedly needed:

# apt-get install mercurial libasound2-dev libcurl4-openssl-dev libnotify-dev libxt-dev libiw-dev mesa-common-dev autoconf2.13 yasm

You will also have to add:

# apt-get install libidl-dev

This isn't documented anywhere that I know of. I found this out the hard way after my first attempts to compile failed.

Get sources
With a regular user terminal open in firefox-mercurial, use mercurial to get the sources:

hg clone http://hg.mozilla.org/releases/mozilla-1.9.2/ 192src

This will get you the latest, most update, bleeding edge version of 3.6--which may or may not be the same as the release version. For example, at the time of this writing, the latest version is 3.6.8pre and the latest release is 3.6.6. To specify the exact version you want, use #{tag}, where {tag} is  one of tags listed at http://hg.mozilla.org/releases/mozilla-1.9.2/. For example, to get and build FF 3.6.6:

hg clone http://hg.mozilla.org/releases/mozilla-1.9.2/#FIREFOX_3_6_6_RELEASE 192src

Getting the sources will take a long time, but not nearly as long as compiling will later on.

Next we need to move into the 192src directory and set up the mozconfig file that tells the system how to build firefox:

cd 192src
echo '. $topsrcdir/browser/config/mozconfig' > mozconfig
echo 'mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-release' >> mozconfig
echo 'mk_add_options MOZ_MAKE_FLAGS="-j4"' >> mozconfig
echo 'ac_add_options --disable-debug' >> mozconfig
echo 'ac_add_options --disable-tests' >> mozconfig
echo 'ac_add_options --enable-optimize' >> mozconfig
echo 'ac_add_options --enable-system-cairo' >> mozconfig


The objdir-ff-release is the name of the directory that built stuff will end up in. You can change this name if you want. The line with --enable-optimize is optional. The last option above, --enable-system-cairo, I found looking through the list of available options, and I'm pretty sure it's what gives you nice font rendering in GTK+ environments.

Build the beast with

make -f client.mk

The build will take forever. Once the compile is done, the binaries will be in
{whatever}/firefox-mercurial/192src/objdir-ff-release/dist/bin/.
Execute the file firefox to make it go.

When you make it go, you'll notice that the app is identified by its code name, Namoroka.

Updating
I have not yet tried this, but according to Mozilla's documentation, to build a new version you'll need to update the sources with

hg pull -r default
hg update


I suspect you do this in the 192src directory and I suspect you'll need to rebuild as above afterward. Also, I suspect that in place of default above you'll want to use a valid tag (as when you first cloned the sources), but until I actually update I won't be able to say for sure.

Extra credit
Once I've done some more testing, I will be move the built files to /opt/firefox and add a *.desktop entry for it. The big question is whether I should call it 'Firefox' or 'Namoroka'.

July 09, 2010

Ubuntu font rendering in Debian Squeeze

[Update 2011-06-25: Confirmed. Updating Iceweasel from http://mozilla.debian.net/ fixes fonts. See this post for more info. So there's no longer any real need to do what's below.]
[Update 2011-06-24: This whole business may be unnecessary as it appears installing a recent version of Iceweasel from http://mozilla.debian.net/ also installs new libcairo2 with decent font rendering. I've yet to do careful comparisons, but it's possible that this solves both "ugly rendering in general" as well as "ugly rendering in Firefox" issues.]
[Update 2011-03-08:]  Reader datSilencer points out that the location of the Arch patch has moved. Therefore, the process for extracting and applying the Arch patch won't work. I am updating the script but I won't be updating this post. If you want to do things manually, please consult the script for the needed changes.]
[Update 2010-09-23: I made a script to semi-automate a lot of the following.]

I love Debian. I really do. But one thing I don't love about Debian is the way it renders fonts in GTK. Or rather, the way Ubuntu renders fonts has spoiled me. After reading about how some people have successfully patched their libraries to use the same changes used by Ubuntu, I've finally succeeded myself. It's been so gratifying and such a good learning experience that I wanted to share.

The process below is based on information from the CrunchBang Linux Forums and from one quanliking. Huge, huge thanks to those people.

To get Ubuntu font rendering in Debian Squeeze, we need to download, patch, rebuild, and reinstall the libcairo2 package. If this breaks your system don't sue me. I am not an expert nor do I play one on TV.

Pre-production
Begin by making sure downloading of package sources is enabled for apt. The line below should be in /etc/apt/sources.list and not commented out:

deb-src http://ftp.us.debian.org/debian/ squeeze main non-free contrib

The actual address will differ depending on which mirror you set up your system to use, but there should be a line that begins "deb-src", has a mirror's address in the middle, and ends with "squeeze main non-free contrib" or "testing main non-free contrib".

Install the needed build tools (as root):

# apt-get install build-essential devscripts fakeroot
# apt-get build-dep cairo


As a regular user, create a new directory called patched-packages in your home directory.

Get the patches
Open the patched-packages directory you created above in a terminal (i.e., the prompt should read something like username@computername:~/patched-packages$).

At the command prompt:

mkdir libcairo2
cd libcairo2
mkdir downloaded-patches


We now need to get two sets of patches, one from Ubuntu and the other from Arch Linux. To get the Ubuntu patches, go to http://packages.ubuntu.com/lucid/libcairo2 and look at the list of links on the right. We want the file cairo_1.8.10-{#}ubuntu1.debian.tar.gz. Download it into ~/patched-packages/downloaded-patches and expand it. This should produce a new directory inside ~/patched-packages/downloaded-patches called debian (i.e., you should now have a ~/patched-packages/downloaded-patches/debian).

I'm not yet sure what the original source of the Arch Linux patch is, but apparently we need it. So go to http://aur.archlinux.org/packages.php?ID=17327 and download the file cairo-respect-fontconfig.patch into ~/patched-packages/downloaded-patches

You're done getting patches.

Get the sources
We now need to get the Debian source package for libcairo2. In a terminal inside ~/patched-packages/libcario2,

mkdir deb-sources
cd deb-sources
apt-get source cairo
cd ./cairo-*


Then copy the patches we downloaded earlier to the Debian package's patches directory:

cp ../../downloaded-patches/cairo-respect-fontconfig.patch ./debian/patches/
cp ../../downloaded-patches/debian/patches/04_lcd_filter.patch ./debian/patches/
cp ../../downloaded-patches/debian/patches/06_Xlib-Xcb-Hand-off-EXTEND_PAD-to-XRender.patch ./debian/patches/


Next, apply the patches to the sources:

patch -p1 -i ./debian/patches/cairo-respect-fontconfig.patch
patch -p1 -i ./debian/patches/04_lcd_filter.patch
patch -p1 -i ./debian/patches/06_Xlib-Xcb-Hand-off-EXTEND_PAD-to-XRender.patch


We now need to modify the changelog to indicate that we've diddled with the package and set a version increment:

dch -i

This will open a text editor. Once there, add

David Turner's ClearType-like LCD filtering patch and fix.

after the asterisk at the top and then save and exit.

(Note: Instead of dch -i above you can also use dch -l {your initials}.)

Build and install
Time to build it. Continuing from where we were in the terminal above (i.e., inside something like ~/patched-packages/libcairo2/deb-sources/cairo-1.8.10) do

dpkg-buildpackage -rfakeroot -us -uc

The result should be a bunch of new packages inside ~/patched-packages/libcairo2/deb-sources/

Look if you don't believe me. All that's left is to install. Open a root terminal and go to the ~/patched-packages/libcairo2/deb-sources/ directory. Then do:

# dpkg -i *.deb

This will install all the debs that were made, of which you may actually only need a subset. Apart from taking up some disk space the extra packages won't hurt anything, and if you install a package in the future that needs one of these, you'l be glad you installed them now.

Congrats. You should now have (IMHO) much improved font rendering. This should hold you until Debian releases a new libcairo2. If the new libcairo2 release doesn't have the "Ubuntu patches" already built in, you'll have to repeat the above process, making sure you get patches that are appropriate for the new version and that there are no additional patch files. (If there are, you will need to copy/add them before rebuilding.)

Rolling back your system to the original Debian packages should be as easy as using Synaptic to "Package -> Force Version..." to the original libcairo2 packages.

Happy building.

May 11, 2010

Getting your menu icons back in GNOME 2.30

According to this post, the Interface tab in GNOME's Appearance Preferences has been removed in GNOME 2.30. I can confirm that as of this writing the tab isn't available under Debian Squeeze.

Thia means if you want to have icons in menus enabled (who doesn't?) you need to resort to gconf-editor (i.e., Applications -> System Tools -> Configuration Editor) and set the key:

/desktop/gnome/interface/menus_have_icons

I mean really. Who doesn't want icons in their menus?

January 23, 2010

Squeeze and the Java plugin (SOLVED)

Another Squeeze issue popped up: the Sun Java plugin (i.e., sun-java6-plugin) doesn't work. It took a bit of poking around to find a fix, but here it is. As root in a terminal:

# nano /etc/sysctl.d/bindv6only.conf

Then change
net.ipv6.bindv6only = 1
to
net.ipv6.bindv6only = 0

Finally,
# invoke-rc.d procps restart

I have no idea what other positive or negative ramifications this will have to your system, so proceed with caution. I'm pretty sure you can undo any damage by setting the 0 back to 1 and doing the invoke-rc.d call over.

FWIW, the icedtea6-plugin doesn't work either, but I haven't been able to figure out that one.

January 16, 2010

Squeeze and GRUB dual boot problems (SOLVED)

Earlier this evening, I installed a command-line version of Debian Squeeze (i.e., still "testing" as of this writing) from the netinstall CD alongside a regular Ubuntu Karmic installation and had an issue with GRUB that nearly had me cleaning my underwear.

Toward the end of the installation, the Debian installer told me that it saw I had Ubuntu installed and so would I want to install GRUB? It also assured me that it recognized that I had Ubuntu installed and that everything would be ok.

I've been through similar prompts with dual-boot installations before, and indeed everything has always gone just swimmingly. So, I said, "Sure." What I didn't know was that Squeeze is using the new and possibly-not-entirely-ready-for-prime-time GRUB 2. (I guess Karmic is as well.)

When I rebooted, GRUB gave me options for the new Squeeze install, but any trace of the Ubuntu install was gone. Hunting for /boot/grub/menu.lst gave me nothing. That's when I discovered that Squeeze installed GRUB 2 and most of the GRUB repair stuff on the Internet was obsolete. I was about the resort to drastic measures when this post inspired me to try

# update-grub

and it worked.