Older blog entries for Kay (starting at number 78)

Minecraft and Gnome Shell

If you are running Minecraft on Linux with Gnome 3 then you might have noticed that it doesn't integrate well into Gnome Shell as you can see in these screenshots:

Java class name instead of real application nameNo Dash menu

So instead of having a nice application name like Minecraft Gnome Shell displays the Java class name. This is not really a problem of Minecraft but more a problem of bad Linux integration of Java applications in general. In Gnome 2 and other desktop environments this application name wasn't really important but since Gnome 3 it is crucial to have a valid application name because the Dash (The dock of Gnome Shell) uses it to connect the running application with its application launcher. And that's another problem: Minecraft doesn't create an application launcher. It only provides a JAR file you have to run somehow. And because this launcher doesn't exist and it can't be connected to the running application because of the bad application name you don't get the usual menu in the Dash to add Minecraft to your favorites.

All this can't be tolerated and must be fixed. In this article I will explain how.


Continue reading "Minecraft and Gnome Shell"

Syndicated 2012-09-30 20:49:09 from K's cluttered loft

Minecraft on Linux

Installing Minecraft (version 1.3.1) on Linux is not always as simple as you might think. It's a Java application so it should run on all platforms supported by Oracle but unfortunately sometimes (For some unknown reasons) this doesn't work out of the box. This article describes how to get it running on a current Ubuntu Linux 12.04 on a 64 bit machine and how to create a desktop entry for it so you don't have to start it with this long command mentioned on the Minecraft website.


Continue reading "Minecraft on Linux"

Syndicated 2012-08-14 09:01:06 from K's cluttered loft

How to follow an organization on GitHub

For some reason GitHub does not display a Follow button on organization pages. So you can only follow normal users or repositories. This is pretty sad because it perfectly makes sense to follow an organization if you want to be informed about new repositories created by this organization. Following the organization members instead isn't an option because then you are also notified about their personal activity which might be boring to you. And some members are not even displayed as organization members because membership can be hidden.

Even more confusing is the fact that following an organization technically works. You can add yourself to the follower list and you are also correctly informed about new projects created by this organization. So why is GitHub not showing this button? Don't know. So you have to hack yourself into the follower list. This can be done with a single JavaScript command which you can enter into the JavaScript console of your browser (Naturally you have to be logged in into GitHub):

$.post("https://github.com/users/follow?target=organizationName");

You can also check the follower list of an organization (The link to this list is also hidden on GitHub). Here is an example URL: https://github.com/openwebos/followers. And when you check the Following list of a user which follows an organization then you can even see a Follow/Unfollow button for the organization. This is most likely a bug, GitHub simply forgot to remove this button when they introduced organizations (Which are simply special kinds of users).

Now I wonder: If it is possible to follow organizations and even notifications about new organization repos works then why isn't it an official feature?

Syndicated 2012-05-25 14:58:24 from K's cluttered loft

Fixing JavaScript Console in older browsers and IE

The JavaScript console as introduced by Firebug years ago has grown to a de facto standard in many web browsers. Especially the Webkit JavaScript console in Chrome/Chromium and Safari is extremely well done. Newer Firefox versions now also come with a built-in console. Even Internet Explorer comes with a basic console-like thing but unfortunately it sucks...

So far I used custom logging mechanisms or log4javascript to log messages in my JavaScript applications. Thanks to the JavaScript console this would be unnecessary if all browsers had descent support for it. But unfortunately the console implementations in some browsers are incomplete or completely absent. So even this harmless line of code in your application can prevent execution in Internet Explorer when the development panel is closed (In which case window.console is not defined at all):

console.warn("Config not found. Using defaults.");

So to be able to use all console features without worrying about missing browser-support I wrote a small library called console-shim which detects the implemented console features and tries to complete them. Some features are emulated so they fully work in all browsers while other features are silently ignored. If console logging is not supported by the browser at all then console-shim tries to use log4javascript if available or it silently ignores all logging attempts. See the README for a full list of replacement implementations for missing functionality.

Syndicated 2012-05-17 13:11:19 from K's cluttered loft

How to setup a modern HP printer in Ubuntu Linux

Are you the (un)lucky owner of a modern HP printer which needs a closed-source binary plug-in? And are you using Ubuntu Linux? Then you might know the detailed error message Plug-in install failed which occurs when you try to setup the printer with HP Toolbox (From the hplip-gui package shipped with Ubuntu):

Looks like there is a permission problem somewhere. Not sure if it is Ubuntu's or HP's fault. Running the HP Toolbox as root might fix the problem but unfortunately it refuses to run as root. But there is an easy way to work around this problem. When you try to install the plug-in the HP Toolbox downloads a plug-in installation script from an HP server to your /tmp directory. It then executes it (Without root privileges I guess) which fails. That's why you get the Plug-in install failed error message. Cancel all dialogs and close the HP Toolbox and execute this command in your terminal:

sudo bash /tmp/hplip-3.12.2-plugin.run.1

The version number may be different so check out which files are located in your /tmp directory first. You'll have to confirm the license and after the installation is complete it will print Done to the console. When it didn't print Done then something went wrong. Maybe you forgot to execute it with sudo? When the installation was successful then start the HP Toolbox again and setup your printer. The tool will not try to install the plug-in again because this time it is already there and it works.

Happy printing (and happy scanning and faxing if your printer supports it)!

Syndicated 2012-05-06 13:54:18 from K's cluttered loft

Self-made Gubuntu

In 2010 the world was still in order: Kubuntu for KDE, Xubuntu for XFCE, Lubuntu for LXDE, Ubuntu for Gnome. This has changed now. The latest Ubuntu LTS release (And the two previous Non-LTS releases) are using Unity as user interface instead of Gnome. Unity is based on Gnome 3 but it is pretty different to a standard Gnome 3 environment (Which uses Gnome Shell). Hopefully some day there will be something like a Gubuntu distribution which focuses on a standard Gnome environment with Gnome Shell as user interface. But for now we have to get rid of Unity manually. This article explains how to do it and also describes some additional tweaks and hacks to make Gnome more usable.


Continue reading "Self-made Gubuntu"

Syndicated 2012-05-05 14:48:51 from K's cluttered loft

Workaround for borderless Java Swing menus on Linux

Since years Linux users are plagued by a bug which affects the rendering of Swing popup menus. When using a modern GTK theme (Like Gnome's Adwaita or Ubuntu's Ambiance and Radiance) then menus in Java Swing applications have no borders and no separators:

Several bug reports exists (Like #6925412) but it seems to be unclear if this is a bug in the affected GTK themes or a bug in Java's GTKLookAndFeel class. Fact is: I'm pretty sure this bug will not be fixed anytime soon so we have to find a workaround and in this article I will show you two different approaches.


Continue reading "Workaround for borderless Java Swing menus on Linux"

Syndicated 2012-04-12 16:49:00 from K's cluttered loft

jQuery Fullscreen Plugin

Modern browsers (Like Chrome and Firefox) provide an interesting new feature: A fullscreen mode which can be controlled by JavaScript. It is even possible to switch a single HTML element to fullscreen. This is useful for videos or images for example. Unfortunately browsers currently only provide the necessary methods with the usual browser-specific prefixes:

// Firefox
element.mozRequestFullScreen();
document.mozCancelFullScreen();
document.mozFullScreen;

// Chrome
element.webkitRequestFullScreen();
document.webkitCancelFullScreen(); 
document.webkitIsFullScreen;

To simplify the usage of this new feature I wrote a small jQuery plugin.


Continue reading "jQuery Fullscreen Plugin"

Syndicated 2012-04-10 17:37:36 from K's cluttered loft

Shell scripts and space characters in command line parameters

I'm using Linux for more than 10 years now and it is embarrassing that I missed this shell feature for so long. But first let's explain the problem: Let's say we want to write a shell script which simply starts some application and which passes all command line parameters to this application. This is often useful if an application is installed in some directory which is not in the PATH and you want to put a starter script into ~/bin which is in PATH. Example:

#!/bin/sh
# Filename: ~/bin/startmyapp
cd ~/opt/myapp
exec ./myapp $*

$* is a place holder for all command line parameters which were passed to this shell script. Now let's feed some command line parameters to it:

startmyapp arg1 "arg2 with spaces" arg3

The ~/opt/myapp/myapp program is now called like this from the shell script:

./myapp arg1 arg2 with spaces arg3

So now there are five parameters instead of three. Bad thing. Using "$*" instead of $* also doesn't work because then all command line parameters are passed as a single parameter to the program. So far I never searched for a solution to this problem. Instead I always worked around this problem somehow. But today I took some time to find a solution and found it pretty fast. It simply looks like this:

#!/bin/sh
# Filename: ~/bin/startmyapp
cd ~/opt/myapp
exec ./myapp "$@"

This $@ parameter was completely new to me. The difference between $* and $@ is explained here.

Syndicated 2012-02-26 15:41:34 from K's cluttered loft

How to implement a Single Instance Application in Java

Recently I started processing command-line arguments in one of my Java Swing applications (Xadrian) so the application can load files directly on startup. This allows connecting the application with some mime-type or file extension and load files into the application by double-clicking the files. But unfortunately this isn't really usable because everytime a new instance of the application is launched by the operating system. So I searched for some technique to prevent this and found two articles: The first one explains how to use a lock file to prevent a second application instance while the second one explains how to use a local server socket to do the same.

The problem with the first solution is obvious: Even with a shutdown hook it is possible that the lock file is not removed properly (When JVM crashes for example). This prevents the application from being restarted. The user has to remove the lock file manually to be able to start the application again which is pretty annoying. The second solution doesn't have this problem because the server socket will be closed even when the JVM crashes. But this solution has a different problem: The port number must be fixed. And if there is already some other service using this port then this can cause a lot of confusion.

Both solutions have another problem: Just preventing the launch of a second instance isn't enough. When I double-click some data file and the operating system tries to open this file with a second instance of the application then I want the data file to be opened with the first instance instead. So the second instance must give the command line arguments to the first instance.

I haven't found a library which already does this so I had to write my own library.


Continue reading "How to implement a Single Instance Application in Java"

Syndicated 2012-02-09 21:55:25 from K's cluttered loft

69 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!