Google
 

Tuesday, April 07, 2009

Easy bandwidth shaping in Linux

There is an extensive and nicely written HOWTO on this topic but here I'm talking about some really easy to use bandwidth shaping tools -- wondershaper and trickle.

Wondershaper
This is the easiest tool I have found to limit bandwidth of a particular interface. All it takes is,


$ sudo wondershaper {interface} {down} {up}
the {down} and {up} are bandwidth in kilobits. So for example if you want to limit the bandwidth of interface eth1 to 256kbps uplink and 128kbps downlink,

$ sudo wondershaper eth1 256 128
To clear the limit,

$ sudo wondershaper clear eth1
Easy, eh?

Trickle
Unlike wondershaper, which limits the bandwidth to an entire interface, trickle is user-space bandwidth limiting tool. The syntax is,

$ trickle -u {up} -d {down} {program}
Both {up} and {down} and bandwidth in KB/s. Now if you invoke it as,

$ trickle -u 8 -d 8 firefox
It will fire up Firefox, limiting the bandwidth to 8KB/s. This is very useful specially if you are a web developer and want to test your application under various bandwidth conditions.

Furthermore, you can also run trickle as daemon (trickled) which can limit the bandwidth to several programs.

Friday, April 03, 2009

Fixing Nepali Unicode in Ubuntu

Setting up to type Unicode Nepali in Ubuntu is easy (just add Keyboard Indicator applet and add Nepali Layout). For more, follow this article in Ubuntu Nepali wiki. However there are few glitches.

Incomplete keyboard layout
The Nepali Romanized Keyboard layout shipped with Ubuntu (located at /usr/share/X11/xkb/symbols/np) is incomplete. The definition for the whole upper row (1-0 keys) are missing. Also, more importantly, zero-width joiner (ZWJ) and zero-width non-joiner (ZWNJ) characters are wrongly defined (ref: standard layout map).

You can find the working version here: http://www.nepalinux.org/input/ne. So lets, fix it. Fire up your terminal


$ cd /usr/share/X11/xkb/symbols/
$ sudo mv np np.bak
$ sudo wget http://www.nepalinux.org/input/ne -O np
Glyph missing
The devanagari fonts included in the standard Ubuntu installation has few Nepali specific glyphs missing. Most notably, 'pareli ra' or 'samyukta ra' (whatever it is called, the one you use in the word 'paryo').

Well, the fix is to install a font file which has this glyph. My recommendation is Lohit Nepali, available at http://nepalinux.org/fonts/. At terminal,

$ cd /usr/share/fonts/truetype
$ sudo wget http://nepalinux.org/fonts/Lohit-Nepali.ttf
$ sudo fc-cache -fv
Now if you want a specific font file (say, Kalimati) to be used as default devanagari font file, follow the following procedure.

Create a file in /etc/fonts/conf.avail/

$ sudo gedit /etc/fonts/conf.avail/64-ttf-nepali.conf
and paste the following content

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<alias>
<family>serif</family>
<prefer>
<family>Kalimati</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Kalimati</family>
</prefer>
</alias>
</fontconfig>
Now, create a symbolic link to it in /etc/fonts/conf.d/

$ sudo ln -s /etc/fonts/conf.avail/64-ttf-nepali.conf /etc/fonts/conf.d/64-ttf-nepali.conf
You might have to restart X to see the changes.