Display Chinese PDF properly with Evince on Ubuntu

This note is about how to resolve the problem: Chinese PDFs do not display properly and all the Chinese characters are BLANK in Evince (a PDF reader based on Poppler library in GNOME).

The issue is related to the data files (poppler-data, a package for encoded data) which do not install by default. We can install it and make the PDF display works with:

# apt-get install poppler-data.

Now the characters shown correctly. If the characters are shown as unknown symbols, it may related to the font configurations. You can alter your font settings using Droid fonts with this reference: 套用 Droid 字型到 ubuntu linux. Enjoy it. 🙂

Install java-7-oracle with PPA on Ubuntu

This note is based on Howto- Install Oracle Java7 in Ubuntu12.04 Precise Pangolin | PPA. The download procedure in oracle-java7-installer package is broken. We should modify it for the rest automatically installation. The summary of my steps are listing:

1. Purge installed JDKs:
# apt-get purge openjdk* sun-java6*

2. Add repository for installation:

# add-apt-repository ppa:eugenesan/java
# apt-get update

3. Modify the installation procedure:
# vim /var/lib/dpkg/info/oracle-java7-installer.postinst
Comment out lines 103-106 which refers to download JDK. The contents may seems like:

WGETRC=wgetrc wget $PARTNER_URL \
|| fp_exit_with_error “download failed”
rm -f wgetrc

4. Manual download JDK source and move it into installation directory:
# mv {source} /var/cache/oracle-java7-installer/
The type (x86/x64) and name of the source can be found within the directory (if you had try to install). Eg: jdk-7u3-linux-x64.tar.gz.

5. Resume the installation:
# apt-get install oracle-java7-installer
All things done. Happy enjoy. 🙂

Suppress massively SNMP notices in message log

In my CentOS, with SNMP, it arise much more SNMP logs in message periodically. Like this:

Connection from UDP: []:xxxxx
Received SNMP packet(s) from UDP: []:xxxxx

Although the notices are harmless, it may drown out other useful messages. To suppress these messages, we can modify the parameters passed to SNMP daemon.

There is a default configuration in /etc/sysconfig/snmpd.options with a comment out option line:

# OPTIONS=”-Lsd -Lf /dev/null -p /var/run/snmpd.pid -a”

This line indicate SNMP’s log facility via syslog is for daemon (-Lsd) and it will log all levels (there are 7 levels). To suppress the notices, the configuration is modified as:

OPTIONS="-LS0-4d -Lf /dev/null -p /var/run/snmpd.pid -a"

. The parameter -LS is to specify the level we want to log, and we set level 0 to 4 (emergency, alert, critical, error, warning) for it. Whereas the level 5 is for notice, 6 for info and 7 for debug are not what we need.

Finally, the log is clearly as usual. 😛

Disable automount of GNOME

In GNOME Shell, automount is convenient while devices inserting into computer. But it is annoying for me because I’m booting from an USB stick. The rest partitions in USB will be mounted and popup a notification to ask what action should be taken.

To disable the auto-mounting behavior built-in Nautilus (the file manager of GNOME), we need to change the configurations via dconf-editor or gsettings with the path:

org.gnome.desktop.media-handling automount

For example, to DISABLE the behavior via command-line:

$ gsettings set org.gnome.desktop.media-handling automount false

. Other wise, just set as true to enable it. Enjoy it. 🙂

The reference is: How to disable automount in nautilus’s preferences.

Set MySQL default character set as UTF8 on CentOS

The default character set of MySQL installed in CentOS 5 is latin while a feasible one for CJKs is UTF-8.

mysql> SHOW VARIABLES LIKE '%character%';
| Variable_name | Value |
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |

To enable whole system UTF-8, we need to add the following codes in /etc/my.cnf:
default-character-set = utf8

character-set-server = utf8

mysql> SHOW VARIABLES LIKE '%character%';
| Variable_name | Value |
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |

There are lots of additional settings in my Gentoo box, but it seems we don’t need right now. Maybe it can be use later. enjoyt it. 😉

[120302] The parameter default-character-set = utf8 for server configuration in 5.1.61 (or 5.1) is deprecated. We should use character-set-server = utf8 instead.

Use RTL8192SE wireless card in Gentoo with kernel 3

Although I had solve this problem earlier, I forgot the solution when I built a new system today. The configuration in kernel’s menuconfig is:

Symbol: RTL8192SE [=m]
Type  : tristate
Prompt: Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter
Defined at drivers/net/wireless/rtlwifi/Kconfig:13
Depends on: NETDEVICES [=y] && WLAN [=y] && MAC80211 [=m] && EXPERIMENTAL [=y]
-> Device Drivers
-> Network device support (NETDEVICES [=y])
-> Wireless LAN (WLAN [=y])
Selects: FW_LOADER [=y] && RTLWIFI [=m]

But after reboot, it still not loaded. Via dmesg, it caused by firmware missing. There’s a package named rtl8192se-firmware in portage tree but it is NOT the one we need. What we need to do is to:
# emerge linux-firmware.
After this step, it works. 🙂

Use GCIN and gnome-shell on Gentoo

Despite the common usage of input method is iBus, GCIN is still my favorite one for Chinese. But with the upgrading of GNOME 3 (gtk3) and in Gentoo, there are notes should be wrote down.

1. The GCIN package is not provided officially by Gentoo’s portage tree. But with hard works of gentoo communities in gentoo-zh (from gentoo-taiwan and gentoo-china), we can use GCIN via layman:

# layman -L
# layman -a gentoo-zh

2. Add gtk3 use flag for GCIN in /etc/portage/package.use:
# echo 'app-i18n/gcin gtk3' > /etc/portage/package.use
3. Some note to make GCIN works is listing in Linux/X window gcin 無法使用的檢查事項.For example:
a) My own configuration for environment variable declare is in ~/.xprofile:

export GTK_IM_MODULE=gcin
export QT_IM_MODULE=gcin
export XMODIFIERS=@im=gcin

b) To install GCIN’s module in gtk2/3 on x86 (i686) Gentoo OS:

# gtk-query-immodules-2.0 > /etc/gtk-2.0/i686-pc-linux-gnu/gtk.immodules
# gtk-query-immodules-3.0 --update-cache

[20120209 edit]
The latest version since 2.7.1 disable the En input method (IM) for switching by default. And for my newly installed gentoo box, I cannot switch IM if the default method is set as En.

It is not convenient when I set other IMs as default, because I need to change to En by pressing an additional shift key or ctrl-space hotkey.

Help from GCIN forum by coolcd, the solution is to close the default attribute after IM launch. The setting is to un-check the box in gcin-tools for:

Default input method and toggle key > Toggle on input mode by default (non-XIM only)

After restart GCIN, the IM mode by default is En that like most IME done.

Enjoy it. 🙂