2011-08-06

How to set up Skype notifications on Linux to be non-distruptive

This blog post presents my Skype notification setup on Linux. This setup contains no audio notifications and only a few visual notifications which don't disturb my regular work.

In the Skype Options dialog box, select the Chat tab, and set it up like this:

  • When somebody starts a chat with me...: Create a minimised chat window
  • Show emoticons: yes
  • Show animated emoticons: no

In the Skype Options dialog box, select the Notifications tab, and set it up like this:

  • Skype Login: no Enable Event
  • Skype Logout: no Enable Event
  • Skype Login Failed: Enable Event, no sound file
  • Contact Came Online: no Enable Event
  • Contact Went Offline: no Enable Event
  • First Chat Message Received: Enable Event, no sound file, Display pop-up notification
  • Chat Message Received: Enable Event, no sound file, Display pop-up notification
  • Chat Message Sent: no Enable Event

Apply the settings, and close the Options dialog box.

How to set up a compact desktop theme on Ubuntu Lucid

This blog post explains how to set up a compact GNOME desktop theme on Ubuntu Lucid, i.e. such a theme which consumes little screen real estate, leaving space for the contents you work on.

Install and activate the necessary small fonts (FixedSC and Helvetica), as described in this blog post.

Select the FixedSC font in GNOME Terminal.

Run this command (without the $) to install GNOME themes:

$ sudo apt-get install gnome-themes{,-extras,-more,-selected,-ubuntu}

In System / Preferences / Appearance / Theme / Customize, select the following themes:

  • Controls: Simple
  • Window Border: Mist
  • Icons: Mist

Some of the changes take effect immediately, but you may have to restart some applications.

How to set up nicely hinted default fonts on Linux

This blog post explains how to set up a per-user default font configuration under Linux (tested on Ubuntu Lucid), which contains easy-to-read fonts in small sizes and properly hinted rendering.

Install the Microsoft core fonts (e.g. Times New Roman, Arial, Courier New), using the following command (without the $ sign):

$ sudo apt-get install msttcorefonts

Create (or overwrite) the file ~/.fonts.conf with the following contents:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>

<!-- Accept bitmap fonts -->
  <selectfont>
    <acceptfont>
    <pattern>
      <patelt name="scalable"><bool>false</bool></patelt>
    </pattern>
    </acceptfont>
  </selectfont>

<!--  Enable proper hinting (medium) and disable subpixel rendering (rgba=none)
      for the Microsoft Core fonts (msttcorefonts) with high quality hints.
  --> 
  <match target="font">
    <test name="family"><string>Andale mono</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>Arial</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>Arial Black</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>Comic Sans MS</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>Courier New</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>Georgia</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>Impact</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>Times New Roman</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>Trebouchet MS</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>Verdana</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>Webdings</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>

<!--  Just a safe bet: enable proper hinting for the DejaVu font family.
      Bitstream Vera is not shipped on Ubuntu Lucid anymore (but there was a
      package on Ubuntu Hardy).
  --> 
  <match target="font">
    <test name="family"><string>DejaVu Sans</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>DejaVu Sans Mono</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>DejaVu Sans,DejaVu Sans Condensed</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>DejaVu Sans Condensed</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>DejaVu Sans,DejaVu Sans Light</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>DejaVu Sans Light</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>DejaVu Serif</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>DejaVu Serif,DejaVu Serif Condensed</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>
  <match target="font">
    <test name="family"><string>DejaVu Serif Condensed</string></test>
    <test name="pixelsize" compare="more"><double>7.5</double></test>
    <edit name="hinting"><bool>true</bool></edit>
    <edit name="hintstyle"><const>hintmedium</const></edit>
    <edit name="rgba"><const>none</const></edit>
  </match>

<!-- Set font family preferences for Firefox. Chrome seems to ignore these.
     Please note that /etc/fonts/conf.d/60-latin.conf has more defaults, which
     we don't have to repeat here.
  -->
  <alias><family>serif</family><prefer>
    <family>Times New Roman</family>
  </prefer></alias>
  <alias><family>sans-serif</family><prefer>
    <family>Arial</family>
  </prefer></alias>
  <alias><family>monospace</family><prefer>
    <family>DejaVu Sans Mono</family>
  </prefer></alias>
</fontconfig>

The hintmedium setting above is especially important, because it turns on the proper hinting for Times New Roman etc., which makes these fonts easy to read at small sizes. The default is slight hinting (instead of medium), which is wrong, and it remains wrong (because of a bug) even if you select it at System / Preferences / Appearance / Fonts / Details / Hinting / Medium. The proper way to get the medium hinting is to write a ~/.fonts.conf file, as above.

After changing ~/.fonts.conf log out and back in, or restart all applications for the changes to take effect.

Google Chrome doesn't pay attention to the default fonts specified in ~/.fonts.conf. In Chrome, visit chrome://settings/fonts, and change the defaults to:

  • Standard Font: Times New Roman
  • Serif Font: Times New Roman
  • Sans Serif Font: Arial
  • Fixed-Width Font: DejaVu Sans Mono

You may want to change the window title and dialog box fonts as well. You can do that in System / Preferences / Appearance / Fonts. See this blog post for some crisp (i.e. non-antialiased), small font size defaults. Don't forget to install the FixedSC and Helxetica fonts first, as documented there.

How to set up English search in Google Chrome

This blog post explains how to set up the default search engine to Google in English language in Google Chrome.

By default, if Google is the default search engine in Google Chrome, it returns the search result in the language of the country which is autodetected as the location of the computer. This is bad behavior for most English-speaking travelers, who always want the search results in English, no matter which country they are visiting.

To fix it for yourself, go to chrome://settings/searchEngines in Chrome, and add a new search engine named Google in English, the shortcut (second column) being gg , and the URL being http://www.google.com/search?hl=en&q=%s . Save it, make it the default, and remove all other search engines with Google in their name.

From now on, you can type a search query to the address bar (optionally prefixed by gg and a space), and you will get Google results in English.

Unfortunately the search engine setting is not synchronized between your Google Chrome installations, so you have to configure it manually on each machine and login account.

2011-08-04

How to disable cursor blinking in GNOME applications

This blog post explains how to make the cursor not blink in text input and text area widgets in GNOME applications (including GNOME Terminal). The settings have been tested and found working on Ubuntu Lucid.

Run the following commands (without the leading $) in a terminal window:

$ gconftool-2 --set /desktop/gnome/interface/cursor_blink --type boolean False
$ gconftool-2 --set /apps/gnome-terminal/profiles/Default/cursor_blink --type boolean False
$ gconftool-2 --set /apps/gnome-terminal/profiles/Default/cursor_blink_mode --type string off

Changes take effect immediately, there is no need to restart running applications.

These changes also affect Google Chrome (including the address bar and input fields and textarea fields on the page). However, changes don't take effect within a pages in existing tabs, so you should close them, and create new tabs.

If some cursors still Please see this noblink page to disable blinking in Emacs, XEmacs, GVIM, GTK, Gimp, Qt, LessTif, Mozilla Firefox, Mozilla Thunderbird, Google Chrome, TCL/Tk, Linux console and Microsoft Windows.

How to write hello-world in both Java and C++

This blog post explains hwo to write a hello-world program which compiles in both Java and C++.

The following solution makes use of the language difference that //...\ continues the one-line comment in C++, but not in Java.

//\
class t{public static void main(String[]a){System.out.print/*
#include<stdio.h>
int main(){if(1){return!printf//*/
("Hello, World!\n");}}