08 December 2011

Lightweight Qt-based DE?

The last couple days, I've been wondering if it might be possible/worthwhile/stupid to build a Qt-centric lightweight desktopish environment. In other words, something to be to KDE what Xfce/Fluxbox/Openbox are to GNOME.

Today, I decided to do a bit of Googling and discovered Egg Window Manager, Qt Window Manager, and R Window Manager. I've yet to try any, but it's nice to know that there are people working on this.

Update [2012-01-12]: Reader CTown points out Razor-qt--a Qt-based desktop environment--is available as well. It's apparently a member of the QtDesktop project. It's worth pointing out that Razor-qt uses Openbox by default, and Openbox, while being a really nice WM, uses GLib--a GTK+ dependence. But maybe in combination with  one of the WMs above ...

23 November 2011

Installing Oracle Java in Wheezy

This is going to be something of a living document. Earlier today I moaned about how Oracle's Java has been removed from Debian and how OpenJDK just isn't really working for me (yet, I hope). Herein I will document progress I am making toward making the non-free Java binaries downloaded directly from Oracle work. I will update this post as I make progress.

The following applies to Java 6. I don't know what needs to change for Java 7. Is this the best way to do this? Probably not. If you know of something better, please let me know.

Get and deflate the JRE binaries
  1. Go to the Oracle Java for Linux page and follow the directions to download the *.bin (i.e., Linux self-extracting) file. (I opted not to use the RPM version even though Alien is available in Debian to install RPMs. The Java RPM is so full of stuff and Alien is so less than 100% reliable that I didn't want to risk messing up my system.)
  2. As root, make a directory /opt/java
  3. Copy the *.bin you downloaded above into /opt/java and issue the following commands in a terminal (as root):
    # chown root:root {name-of-the-file-you-downloaded}
    # chmod a+x {name-of-the-file-you-downloaded}
    # ./{name-of-the-file-you-downloaded}
    The first one makes sure the file is owned by root, the second one makes the file executable, and the third one executes the file -- which deflates all the Oracle Java goodness into a directory called something like jre1.6.0_xx.
  4. Create a link called jre to the directory jre1.6.0_xx (or whatever) created above. This link will make updating the binaries much easier in the future. Use this link from now on to reference files in the jre1.6.0_xx (or whatever) directory.
Point the system to the new java executable
  1. Use your favorite method to install the galternatives package from the repositories. Galternatives gives you a nice GUI interface to the "Debian alternatives" system. We will need this to override the default system alternative you may already have for the java command.
  2. Open Galternatives and look for an entry in the "Alternatives" column on the left called "java". If you don't have a "java" entry, skip the next step.
  3. When you click on the "java" entry in Galternatives, the right pane should show you a list of available alternatives that you can set your system to use as the java command. Click the "Add" button on the bottom of the window and navigate to /opt/java/jre/bin/java . After you close the file browser dialog and return to the main window, click the radio button next to the /opt/java/jre/bin/java choice to tell the system that you want to use that java to handle java commands. Skip the next step and go directly to Testing.
  4. Do this step only if you did NOT have a "java" entry in Galternatives. Create a soft link from /usr/bin/java to /opt/java/jre/bin/java . (Changing the /usr/bin/java link when it has been set by the Debian alternatives system may give you a whole lot of future pain, so mind the caution!)
  1. Open a terminal and enter the command
    $ java -version
    The resulting output should give you a version number that matches what you downloaded above. If it doesn't, something went wrong.
You should now have a system that will run Java apps using the Oracle JDK you downloaded. Applets will not yet be working. We'll tackle that next.

Configure browser plugin
The directions for installing the browser plugin given by Oracle may leave some browsers out in the cold. I put together a script that creates a link to the plugin in all the locations that the last debian sun-java1.6 plugin package did.
  1. Download the script from here.
  2. Look it over to make sure it's configured correctly for your system.
  3. In a terminal (as root):
    # chmod a+x {name-of-the-file-you-downloaded}

    # ./{name-of-the-file-you-downloaded}
  4. Restart your browser and test that applets are working by going to the Oracle Java test page.
I tested the above with Iceweasel, Chrome, and Opera and they all worked as expected. On one of my machines, I had to re-enable the plugin in Chrome. To do that, enter chrome://plugins in the URL bar and the rest should be obvious.

If you study the script carefully, you will see that there are commented-out bits that you can use to remove the links it created. Lemme know if you need to do this but can't figure out what to do.

Configure Webstart
In Iceweasel and Opera, configuring Java Web Start for me was as simple as going to a page that had a Java Web Start app in it (e.g., this one), clicking on it, and then directing the browser to use /opt/java/jre/bin/javaws.

I was able to get Chrome to work in a roundabout way by first downloading a *.jnlp file and then using my file manager (Thunar in Xfce) to tell it to open *.jnlp files with javaws by default. After that, in Chrome I downloaded a *.jnlp file again and then (still in in Chrome) I clicked the arrow next to the file name and selected "Always open files of this type." There may be a better way to do this.

Put the Java binaries on the PATH
There's a bunch of execuatables in /opt/java/jre/bin that will make life a lot easier if they are on the PATH. To that end,
  1. As root, copy the file found here to /etc/profile.d/oracle_java_mfk.sh  (the actual name isn't really that important as long as it ends with .sh).
  2. Reboot.
On reboot, the executables in /opt/java/jre/bin will be available on the command line, which is as God, er, Oracle, intended. Feel free to test by opening a terminal and entering
$ which keytool
The result should point to the executable in /opt/java/jre/bin. If doing this spooks you (it is, after all, a system file), you can still get by without. But you will have to launch things like the Java Control Panel and other goodies from the /opt/java/jre/bin directory rather than as a command or by using one of the convenient GUI desktop entries (discussed below).

Install desktop files
There are a bunch of files in /opt/java/jre/lib/desktop that help to integrate the JRE into you system. These aren't critical, but they're probably nice to have. At the very least, they add a menu entry to start the Control Panel. I have written a script to install these files here.

Note that this script copies stuff into your system, which means 1. it will clobber resources you might already have (which you shouldn't if you completely removed the Wheezy sun-java6 packages) and 2. it makes uninstalling a tedious process of manually deleting the files that were copied over. Don't delete the directories mentioned in the scripts! There is probably stuff in those directories that your system needs. Instead, look at the files in the directories and subdirectories in /opt/java/jre/lib/desktop and delete each of those manually. (For more info on MIME stuff see http://developer.gnome.org/integration-guide/stable/mime.html.en).

Install Java fonts
Oracle Java includes a group of fonts from the Lucida family of typefaces. Yup, I've got another script for installing those, and you'll find it here. More than you ever wanted to know about fonts in Debian is here.

Updating the system
When a new version of the JRE is released, updating should really be just a matter of deleting everything in /opt/java and repeating the steps in the Get and deflate the JRE binaries section. If you want to be really thorough though, you'll also want to repeat Install desktop files and Install Java fonts sections.

The somewhat massive gorilla in the room now is, "How do you know if an update is available." Sadly, for this I have no brilliant solution. That means you should probably check the Java SE Downloads page occasionally to see if one has been released.

Update 2011-11-26: Added Install desktop files section. Added the Install Java fonts section.
Update 2011-11-27: Changed path to javaws executable and updates info on getting Webstart to work with Chrome. Added comments about (not) getting notified of updates in Updating the system. Added how to configure plugins in Chrome to Configure browser plugin.

Debian drops Oracle Java

I am sorta bummed that the Debian devs have decided to ditch Oracle Java. At the present time, there are no sun-java6 packages in Wheezy, and sid has old builds (for some reason). It is unclear to me whether Oracle Java was dropped because of licensing issues or because it has unresolvable security issues. I assume the former even though the bug report gives the impression of the latter.

In theory, the free OpenJDK packages provide a sufficiently stable and functional alternative to Oracle Java. But if you read up enough on this, you'll find that people are still having issues with OpenJDK. I am among them. In particular, I am finding OpenJDK provides noticeably slower performance than Oracle Java. With things like Processing and FreeRouting, the difference is quite noticable.

Of course I would prefer to use the free OpenJDK over the proprietary Oracle Java -- but OpenJDK just doesn't seem up to the job yet, at least not for the kinds of things I need Java for. There is a bit of a vicious cycle here -- OpenJDK is unlikely to get the kinds of optimizations it needs unless people are actually using it and bump into its limitations. To this end, I will happily take a bit of a performance hit or other inconvenience, but not as much as I am seeing.

I am now trying to rip out all the sun-java6 and OpenJDK stuff on one of my computers and install the full-fledged Oracle Java experience (JRE, browser plugin, Webstart, and JDK) from the Oracle site. I'm working with the JRE only at the moment, and it's proving to be a pretty painful process. More later if I succeed.

25 September 2011

Selecting sudo/su authentication mode (without gconf-editor)

This may be Debian-specific.

Apps like 'Synaptic' and 'Root Terminal' when launched from a desktop menu (e.g., your panel's applications menu) will ask for authentication. By default, Debian uses gksu for these tasks. However, it's possible and quite easy to configure things so gksudo is used instead. The following assumes you have already configured your system and user to use sudo.

I first learned how to do change the setting by using gconf-editor. If you have gconf-editor installed, go to the entry for /apps/gksu and click the checkbox next to sudo-mode. But that's the fiddly way to do it. I just discovered by accident a much easier way -- one that doesn't require gconf-editor. Simply launch:

$ gksu-properties

as user (not root) and set Authentication mode to su (to use gksu) or sudo (for gksudo). While you're there, you can also disable screen grabbing, though why you'd want to I'm not really sure.

Note that this is a per user setting. There's probably a system-wide config for this, but I'm feeling too lazy to find it.

18 July 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.

25 June 2011

Fixing ugly LibreOffice UI in Squeeze

I removed OpenOffice.org from my recently Lenny-to-Squeeze updated machine and installed LibreOffice from backports instead. A succinct how-to for doing that is available here.

The installation went without a hitch, and LibreOffice started just fine. But the UI was ghastly, horribly, I would-rather-look-at-and-smell-a-garbage-bin ugly.

Easy fix:

# apt-get -t squeeze-backports install libreoffice-gtk


There is a libreoffice-gnome package as well. I don't know what the difference is yet, but I suspect it would be a good idea to go through all the libreoffice backports for Squeeze to see if there's anything else I missed.

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.]

11 June 2011

Colorful GNOME-colors

One of my favorite icon sets is the GNOME-colors series. The shapes, contrast, perspectives, and luster (not too shiny) are all just right. One thing that wish it had a bit more of though was color diversity. When you use gnome-brave, for example, things become just a bit too blue for my taste. And I don't mean from just an aesthetic perspective--it impacts usability for me as well.

So, I wrote a little (translation: longish) script that will make a new hybrid icon set from all the icon sets in the whole GNOME-colors pantheon. The script was written for Ubuntu/Debian and is I hope self explanatory. The basic idea is that it makes a copy of one of the sets (I chose gnome-brave because it's closest to what I want) and then selectively copies over the bits from the other sets. Hacking the script for other distributions and/or local installations should be pretty straight forward. The script includes a full list of the icons that are part of the Ubuntu package; ones that do not deviate from the default are commented out.

After running the script, you will have to move the directory it generates to ~/.icons or to /usr/local/share/icons.

Odd and pesky details:
  • Requires at least bash 4.  
  • Assumes you have the gnome-colors package installed.
  • Don't try running this from within Geany. For some reason, Geany chokes on declare -A statements. It works just fine if you run it inside a terminal.
You can download the script from http://download.tuxfamily.org/skinny/misc/make-gnome-colors-hybrid.sh. I would show it here except that I'm tired of fighting Blogger's inability to properly implement pre and code tags or provide some other means of sharing code without messing it up.

02 April 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
if [ -d "$QTSDK_LOCATION/qt/bin" ] ; then
if [ -d "$QTSDK_LOCATION/bin" ] ; then
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]
Exec=designer %F
Name=Qt Designer
GenericName=GUI designer for Qt applications

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.

23 March 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.

02 February 2011

OpenOffice.org + dark theme + Openbox

I've been noodling with the very, very dark aud-Default GTK+ theme--which also happens to play very well with the Onyx Openbox theme. However, as nicely as it plays with Onyx, it plays very, very badly with OpenOffice.org. If you get your Google on, you'll find a number of workarounds for OO.org and dark themes. What I wanted is an easy to implement and (more importantly de-implement) solution. A solution in the Crunchbang Linux forums spells out just the ticket. In your ~/.config/openbox/autostart.sh file, add the line:


This will make OO.org fallback to its native theme ... ugly as sin, but usable.

Note that if you are having the opposite problem--that you can't get OO.org to render with your GTK theme--then try adding:

export OOO_FORCE_DESKTOP=gnome

instead. This suggestion is from the #! forums and Urukrama's blog.

There are a few other usability issues I'm having with aud-Default , but I'm willing to work at it some more given the sweet way it renders entries in fbpanel's taskbar.

02 January 2011

Fixing overzealous hard drive head parking

Debian Squeeze on my Samsung R510 has been working very well, with one exception: pause... pause... click... pause... pause... pause... click... The hard drive seems to be overzealous about parking its heads. There are some (strawman alert?) who feel that heavy head parking actually reduces the life of a drive. Whether or not that's the case, I find the frequent clicking to be downright annoying on this otherwise intensely quiet computer.

As is the case with many things in Linux, a fix is at hand. Many thanks to SammyNetbook for pointing the way. The frequency of head parking can be changed by lowering the aggressiveness of APM power saving through the hdparm command. In the case of my lappy, running

# hdparm -B 254 /dev/sda

(as root) solved the headparking issue. (There maybe lower levels that work as well, but I'm happy enough with the result now that I haven't experimented.)

Running the command at startup
The effect of the above command ends at restart. To automatically run it when my lappy starts up, I used init.d. I first created a file mfk-hdsilence.sh in /etc/init.d:
#! /bin/sh
# /etc/init.d/mfk-hdsilence.sh

# Some things that run always
hdparm -B 254 /dev/sda

exit 0

Then to activate this:
# update-rc.d mfk-hdsilence.sh defaults

I got a warning when I did this, but it seemed safe to ignore. Result? A non-clicky, super silent lappy. Life is good.

Update: it seems suspending the lappy resets the drive's APM, so I'll need to figure out a way to rerun hdparm when waking up. I am currently experimenting with placing a file 30_mfk-hdsilence.sh in /etc/pm/sleep.d:

#! /bin/sh
# 30_mfk-hdsilence.sh

# silence aggressive head parking
case ${1} in
  hdparm -B 254 /dev/sda

exit 0

It seems to be working, but I'll need to live with it for a while to make sure. Suspending under Linux is always stressful for me.