Wednesday, September 2, 2009

Finding Files On The Command Line

One of the things I like about Linux is the command line. I have used nautilus, gnome-commander, konqueror, kommander, dolphin and thunar to manage files in Linux and these file managers are great for what they do. But there are times when one simply wants to find a file when working on the command line without having to open a GUI application.

From the find man page:

GNU find searches the directory tree rooted at each given file name by evaluating the given expression from left to right, according to the rules of precedence until the outcome is known at which point find moves on to the next file name.

Find empty directories:

find /path -depth -type d -empty

Find empty files:

find /path -depth -type f -empty

Find a file with a specific name:

find /path -name name_of_file

Find a files with specific extensions:

find /path -name "*.given_extension"

Find files with specific permissions which have a ".txt. file extension:

find /path -name '*.txt' -perm 644

Find files with some given permissions:

find /path -perm -permision_bits

Find files with a given name and any extension:

find /path -name 'given_name.*'

Find files modified in the latest blocks of 24 hours:

find /path -mtime n

Where n is:

* 0 for the last 24 hours
* 1 for the last 48 hours
* 2 for the last 72 hours

Find files that were accessed in the latest blocks of 24 hours:

find -atime n

Where n is:

* 0 for the last 24 hours
* 1 for the last 48 hours
* 2 for the last 72 hours

Find files according to owner:

find /path -user root

One can also pipe find commands to the xargs command to execute commands on files.

Find and delete files:

find /path -name mytestfile | xargs rm

See man find and man xargs for more information about these powerful commands.

Many new Linux users are intimidated by the command line and this feeling should be overcome from the onset because the command line can be faster and more powerful than most GUI applications.

Friday, July 31, 2009

how to install tinyos in debian/boss/ubuntu.

vim /etc/apt/sources.list
deb http://ftp.se.debian.org/debian lenny main contrib non-free
deb http://tinyos.stanford.edu/tinyos/dists/ubuntu feisty main

#apt-get update
#apt-get install tinyos-2.0.2


which installs following packages.
avr-binutils-tinyos avr-gcc-tinyos avr-libc-tinyos avr-optional-tinyos
avr-tinyos avr-tinyos-base avrdude-tinyos deputy-tinyos graphviz gsfonts-x11
java-common libgraphviz4 libnss-mdns msp430-binutils-tinyos
msp430-gcc-tinyos msp430-libc-tinyos msp430-optional-tinyos msp430-tinyos
msp430-tinyos-base nesc odbcinst1debian1 python-serial sun-java5-bin
sun-java5-demo sun-java5-jdk sun-java5-jre tinyos-2.0.2 tinyos-base
tinyos-required-all tinyos-required-avr tinyos-required-msp430 tinyos-tools
ttf-liberation unixodbc
after installation setup require to be done
add in .bashrc or /etc/profile
#Sourcing the tinyos environment variable setup script
source /opt/tinyos-2.0.2/tinyos.sh


Installing a TinyOS enviromnent has five basic steps; Windows requires an extra step, installing Cygwin, which is a UNIX-like environment. The steps are:

1. Installing a Java 1.5 (Java 5) JDK. Java is the most common way of interacting with mote base stations or gateways that are plugged into a PC or laptop.
2. Windows only. Install Cygwin. This gives you a shell and many UNIX tools which the TinyOS environment uses, such as perl and shell scripts.
3. Installing native compilers. As you're compiling code for low-power microcontrollers, you need compilers that can generate the proper assembly code. If you using mica-family motes, you need the AVR toolchain; if you're using telos-family motes, you need the MSP430 toolchain.
4. Installing the nesC compiler. TinyOS is written in nesC, a dialect of C with support for the TinyOS concurrency model and component-based programming. The nesC compiler is platform-independent: it passes its output to the native compilers, so that it can take advantage of all of the effort put into their optimizations.
5. Installing the TinyOS source tree. If you want to compile and install TinyOS programs, you need the code.
6. Installing the Graphviz visualization tool. The TinyOS environment includes nesdoc, a tool that automatically generates HTML documentation from source code. Part of this process involves drawing diagrams that show the relationships between different TinyOS components. Graphviz is an open source tool that nesdoc uses to draw the diagrams.


reference
http://docs.tinyos.net/index.php/Installing_TinyOS_2.0.2#Two-step_install_on_your_host_OS_with_Debian_packages

Sunday, July 19, 2009

How to use Your Mobile Phone as Remote for your Linux Media Player

One of the Accessories that comes shipped with my Dell M1330 laptop is a media Remote control which allows the laptop media player to be controlled remotely. Unfortunately Dell in their wisdom left this cool accessory out of the default configuration of the M1330 that ships with Ubuntu pre-installed. Thankfully there is an even better tool available which is much more useful than the XPS media remote, Its is called Remuco

Remuco is a duplex remote control system for Linux media players and mobile devices equipped with Bluetooth or WiFi.

With Remuco, you can remotely control your favorite media player. You can switch to the next, previous, or any other media within the current playlist, browse your media library and activate other playlists, rate your media, adjust volume, and more. On the mobile device (the remote control), it displays information about the current media, including cover art.

source

**Ok the name is by no means cool or an a good indicator of what it can do, some of its features include**
Features

Remuco allows you to control:

* Playback

*Seek forward or backward in current playing item

*Set the playlist to repeat or shuffle

*Control volume

*Rate,

*Tag Media being played

on your PC from your mobile phone

It also Displays:

*Current playing songs including album art

*Volume level

*Progress level of current playing song and its current rating

Media browser features includes:

*Browse Currently active playlist and apply actions to them

*Browse the play queue and apply actions to them

*Browse the players media library and apply actions to them

*search for items in the player’s media library and apply actions to items in the search result

*browse the local filesystem and apply actions to files

*** Not all feature is available on all media player example Rhythmbox seems to be better support compared or other media player***
Installation

Installation of Remuco is in two part, A player adapter is installed on your PC and the client on your mobile device

How to install the player adapter:

(K)Ubuntu

First you need to add the 3rd party repository to your sources.list this can be done from synaptic

System -> Administration -> Synaptic Manager -> Settings -> Repositories.

Here you can enable the repositories for Ubuntu Software and Third Party Software.

For Third Party Software select Add -> enter the repository’s address.

Ubuntu 9.04

deb http://ppa.launchpad.net/remuco-team/ppa/ubuntu jaunty main

Ubuntu 8.10

deb http://ppa.launchpad.net/remuco-team/ppa/ubuntu intrepid main

Ubuntu 8.04

deb http://ppa.launchpad.net/remuco-team/ppa/ubuntu hardy main

Now you need install the repository Key

Open your terminal and enter:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 51A6F565

Now you will need to reload your sources by clicking the reload button on synaptic once done search for the team remuco, and you will see a list of remuco adapters for different Media players for linux

e.g I am on kde and i use amarok so i just installed the remuco-amarok package

Other Linux Distros can check here for installation Instructions

you now need to add remuco to the list of startup application

Amarok

The Amarok adapter requires Amarok 2.

The Amarok adapter can be started with:

remuco-amarok

Audacious

The Audacious adapter can be started with:

remuco-audacious

Banshee

The Banshee adapter requires Banshee ≥ 1.4.

The Banshee adapter can be started with:

remuco-banshee

MPD

The MPD adapter requires MPD ≥ 0.13.

The MPD adapter can be started with:

remuco-mpd

Rhythmbox

Start Rhythmbox and activate the plugin Remuco in the menu Edit → Plugins.

Totem

The Totem adapter requires Totem ≥ 2.22.

Start Totem and activate the plugin Remuco in the menu Edit → Plugins.

TVtime

The TVtime adapter requires TVtime ≥ 1.0.

The TVtime adapter can be started with:

remuco-tvtime

NOTE: With the exception of Rhythmbox and Totem, Remuco adapter for other Media players can be started automatically by adding remuco-media-player name to your startup session e.g for amarok add remuco-amarok to (gnome) System/Preference/Sessions (or startup application). (KDE) System-settings/ Advance Autostart
Client side installation

Installation on your mobile can be done by downloading remuco package here (the latest version on remuco in blog time is 0.9.0) extract the .tar.gz and goto /client/app/ and send the .jar file to your mobile device and install it from there

(Note: The client requires a mobile device with JavaME support (MIDP ≥ 2.0, CLDC ≥ 1.1). If you use Bluetooth to connect to a player adapter, additionally JSR-82 (Java Bluetooth) must be supported.)

Once installed on the device in my case i open terminal and run the following command remuco-amarok then i start amarok and start the client on my Nokia E71

Connected remuco to my laptop, it did its thing and yola i was able to control my amarok player from my phone.

Remember to first go to More and key-binding to set your own control key preference

Happy listening and I hope this helps someone .. (sorry if this is badly written haven’t had time to blog in a while been very busy :-( so am a bit rusty i guess)


reference
http://bigbrovar.wordpress.com/2009/07/13/how-to-use-your-mobile-phone-as-remote-for-your-linux-media-player/
http://remuco.sourceforge.net/index.php/Getting_Started#Installation

Thursday, July 16, 2009

How to Extract pages from PDF files

There are a number of ways to extract a range of pages from a PDF file: there are PDF related toolkits for doing it, or you can use Ghostscript directly.

For example, to extract pages 22-36 from a 100-page PDF file using pdftk:

$ pdftk A=100p-inputfile.pdf cat A22-36 output outfile_p22-p36.pdf

Or use a combination of xpdf-utils (or poppler-tools) with psutils and the ps2pdf command (which ships as part of Ghostscript):

$ pdftops 100p-inputfile.pdf - | psselect -p22-36 | \
ps2pdf14 - outfile_p22-p36.pdf

Or, just use Ghostscript (which, unlike pdftk, is installed nearly everywhere; and you've been using it in the last command anyway):

$ gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
-dFirstPage=22 -dLastPage=36 \
-sOutputFile=outfile_p22-p36.pdf 100p-inputfile.pdf

Regarding speed and efficiency of the processing and more important the quality of the output file, the 2nd method above is for sure the worst of the 3. The conversion of the original PDF to PostScript and back to PDF (also known as "refrying" the PDF) is very unlikely to completely preserve advanced PDF features (such as transparency information, font hinting, overprinting information, color profiles, trapping instructions, etc.).

The 3rd method uses Ghostscript only (which the 2nd one uses anyway, because ps2pdf14 is nothing more than a wrapper script around a more or less complicated Ghostscript commandline. The 3rd method also preserves all the important PDF objects on your pages as they are, without any "roundtrip" conversions....

The only drawback of the 3rd method is that it's a longer, more complicated command line to type. But you can overcome that drawback if you save it as a bash function. Just put these lines in your ~/.bashrc file:

function pdfpextr()
{
# this function uses 3 arguments:
# $1 is the first page of the range to extract
# $2 is the last page of the range to extract
# $3 is the input file
# output file will be named "inputfile_pXX-pYY.pdf"
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
-dFirstPage=${1} \
-dLastPage=${2} \
-sOutputFile=${3%.pdf}_p${1}-p${2}.pdf \
${3}
}

Now you only need to type (after starting a new copy bash or sourcing .bashrc) the following:

$ pdfpextr 22 36 inputfile.pdf

which will result in the file inputfile_p22-p36.pdf in the same directory as the input file.

Wednesday, July 8, 2009

How to install Firefox 3.5 in BOSS/Linux operating system

First download firefox from http://www.mozilla.com/en-US/firefox/firefox.html
extract it.(considering that it extracted at /opt folder)
Next, make a shortcut to the firefox executable - right click on the desktop, click on Create Launcher, and at the Command field enter the command below:
/opt/firefox/firefox -P
The -P switch will start Firefox 3.5 using the profile manager, so from here all you need to do is to create a new profile for your Firefox 3.5:
if default profile is used then create new profile ex. BOSS and then path to dir.
Additionally, you can specify the --no-remote switch (firefox --no-remote -P) so you can run both your currently 3.0.11 and 3.5 instances at the same time. The --no-remote switch doesn't connect Firefox to a currently running instance.

Thursday, June 18, 2009

X RandR is used to configure which display ports are enabled (e.g. LCD, VGA and DVI)

Contents
* 1 Overview
* 2 Supported drivers
* 3 xorg.conf
* 4 Using $ xrandr
o 4.1 First discover what we have
o 4.2 Using xrandr to do useful things
o 4.3 Now automate it on login
o 4.4 Sample Fn-F7 script
o 4.5 GUIs
* 5 Summing up
o 5.1 the Virtual screen
o 5.2 Output port names
o 5.3 Note for Gnome users
o 5.4 Note for Ubuntu Gutsy users
* 6 Gleanings
o 6.1 Notes from xserver-xorg-video-intel.readme
o 6.2 Xorg mailing list
o 6.3 Notes for X31, X32, T30 / Radeon 7000, Radeon 7500 users
+ 6.3.1 Further Note
* 7 References

Overview

X RandR is used to configure which display ports are enabled (e.g. LCD, VGA and DVI), and to configure display modes and properties such as orientation, reflection and DPI.

This is the simplest and most powerful way to get multi-monitor systems working using recent versions of Linux such as Ubuntu 7.10 and Fedora 8 with graphics chipsets such as the Intel 945GM/GMS and ATI Radeon found in Thinkpads.

xrandr is the command line interface to the RandR X extension. As usual with X, good documentation is hard to find; first try the following commands:

* $ xrandr --help
* $ man xrandr

* for Intel graphics: $ man intel
* for ATI graphics: $ man radeon

The rest of this page refers to a laptop with a built in 1024x768 pixel screen and an external 1600x1200 VGA monitor. Simply replace the relevant numbers with your own system specifications and all should work fine.
Supported drivers

Ubuntu 7.10 Gutsy Gibbon

* X.org intel driver, version ??? (included in Xorg ???) and later. Ubuntu version: 2:2.1.1-0ubuntu2 with xrandr 1:1.2.2-0ubuntu1

* X.org radeon driver, 6.7.192 and later (in ubuntu gutsy and hardy, but they still have very serious issues for some Thinkpads).

xorg.conf

Recent versions of xorg.conf intended for use with xrandr 1.2 considerably simplify the video section of the configuration. If you upgrading from an earlier version you may find your existing xorg.conf works against the effective deployment of xrandr. So it is best to start with a new Xorg configuration.

An updated Xorg.conf should:

* omit dual Device/Screen/Monitor sections
* omit MonitorLayout option and Screen lines from the remaining Device section
* omit dual Screen lines from the ServerLayout section
* omit RightOf/LeftOf indication to the remaining Screen line in ServerLayout section
* add a "Virtual 2048 2048" line in SubSection "Display" to create a large virtual screen

To create a new xorg.conf for Ubuntu and other Debian based distributions, connect the external display to the VGA port, turn on that display, and run

$ sudo dpkg-reconfigure -phigh xserver-xorg

The resulting /etc/X11/xorg.conf should include something like

Section "Device"
Identifier "Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
Driver "intel"
BusID "PCI:0:2:0"
# ADD THIS IF YOUR LAPTOP DOES NOT HAVE A TV CONNECTOR or DOCKING STATION
Option "monitor-TV" "TV"
EndSection
Section "Monitor"
Identifier "Generic Monitor"
Option "DPMS"
EndSection
# ADD THIS IF YOUR LAPTOP DOES NOT HAVE A TV CONNECTOR or DOCKING STATION
Section "Monitor"
Identifier "TV"
Option "Ignore" "True"
EndSection
Section "Screen"
Identifier "Default Screen"
Device "Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
Monitor "Generic Monitor"
DefaultDepth 24

SubSection "Display"
Depth 24
Modes "1600x1200" "1280x1024" "1024x768" "800x600" "640x480"
# ADD A VIRTUAL LINE TO PROVIDE FOR THE LARGEST SCREENS YOU WILL HOTPLUG
Virtual 2048 2048
EndSubSection
EndSection
Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
InputDevice "stylus" "SendCoreEvents"
InputDevice "cursor" "SendCoreEvents"
InputDevice "eraser" "SendCoreEvents"
InputDevice "Synaptics Touchpad"
EndSection


Just a hint: If you want to use TV-out but not VGA for example, you should change these sections:

Section "Device"
Identifier "Intel Corporation Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
Driver "intel"
BusID "PCI:0:2:0"
Option "monitor-VGA" "VGA"
Option "monitor-TV" "TV"
Option "monitor-LVCD" "LVCD"
EndSection

Section "Monitor"
Identifier "VGA"
Option "Ignore" "true"
EndSection

Section "Monitor"
Identifier "LVCD"
Option "DPMS"
EndSection

Section "Monitor"
Identifier "TV"
Option "Ignore" "false"
EndSection


After creating a clean xorg.conf, restart X and logon.

You may find you have a display only on the external VGA screen at its default max resolution; do not worry - xrandr can fix this.
Using $ xrandr
First discover what we have

Open a terminal window to use the command line: 'Applications:Accessories:Terminal'
Hint:
First look at the 'help' and 'man' pages.

$ xrandr --help
$ man xrandr

To find what version of xrandr is running, type the following command:

$ xrandr -v
Server reports RandR version 1.2

To query what screens are connected, type the following: (The output shown indicates nothing is connected to the VGA port.)

$ xrandr -q
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 1920 x 1440
VGA disconnected (normal left inverted right)
LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm
1024x768 60.0*+ 50.0
800x600 60.3
640x480 60.0 59.9
TV disconnected (normal left inverted right)

If you see the 'TV disconnected' line but have neither TV connector nor docking station (eg Thinkpad R60e) then add to the Monitor and Device sections of xorg.conf as noted above. This will prevent the external (VGA) flashing off for a few seconds every time xrandr is used. (Newer versions of the intel driver may fix this.)

The same command as above, but with the VGA monitor plugged in and powered off, should give something like the following output: (The VGA monitor is now shown as 'connected'.)

$ xrandr -q
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 1920 x 1440
VGA connected (normal left inverted right)
1920x1440@60 60.0
1920x1440 60.0
1600x1200@60 60.0
1600x1200 60.0
1280x960 60.0
640x480@60 60.0
LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm
1024x768 60.0*+ 50.0
800x600 60.3
640x480 60.0 59.9
TV disconnected (normal left inverted right)

Powering on the VGA monitor and issuing the same command again will give the following output: (The size and position of the VGA output within the virtual screen is now shown.)

$ xrandr -q
Screen 0: minimum 320 x 200, current 2624 x 1200, maximum 2624 x 2048
VGA connected 1600x1200+1024+0 (normal left inverted right) 367mm x 275mm
1600x1200 60.0*+
1920x1440@60 60.0
1600x1200@60 60.0
640x480@60 60.0
640x480 60.0
LVDS connected 1024x768+0+0 (normal left inverted right) 304mm x 228mm
1024x768 60.0*+ 50.0
800x600 60.3
640x480 60.0 59.9
TV disconnected (normal left inverted right)

For bug reporting and diagnosis use xrandr with the verbose option:

$ xrandr --verbose

Using xrandr to do useful things

In general the commands will specify the output name and either --off or --auto. In the examples here the external screen is named VGA, as used by the Intel driver, with an ATI card the name will probably be VGA-0. In general use $ xrandr -q to discover the appropriate output names for your configuration. The --auto option will select the preferred resolution for each output, this is starred(*) in the $ xrandr -q listing and is normally the best resolution available. It is also possible to set a particular mode eg --mode 1024x768.

First clone the two screens, (the smaller screen will display the top left portion of the virtual screen)

$ xrandr --output LVDS --auto --output VGA --auto --same-as LVDS

To turn off the VGA monitor.

$ xrandr --output VGA --off

To turn the VGA monitor back on, with its viewport to the right of the laptop monitor:

$ xrandr --output VGA --auto --right-of LVDS

This will probably give an error message similar to:

xrandr: screen cannot be larger than 1600x1600 (desired size 2624x1200)

This can be fixed by editing xorg.conf and changing the virtual line (see example above) to something like:

Virtual 2624 1200

Note that the maximum supported size of the virtual desktop for the Intel 945GM series of chipset with 3D acceleration enabled, is 2048x2048. The virtual screen can be larger but DRI will be disabled. This may matter if you like games and compiz desktop effects, or if you want Google Earth to display in better than geological time. Obviously the larger the virtual desktop, the more graphics memory is used. So for good performance with a shared graphics system such as Intel the Virtual should be no larger than necessary.

It is possible to set screen locations as --left-of, --right-of, --above and --below. Assuming displays sizes of 1024x768 and 1200x1600:

$ xrandr --output LVDS --auto --output VGA --auto --right-of LVDS
and
$ xrandr --output LVDS --mode 1024x768 --pos 0x0 --output VGA --mode 1600x1200 --pos 1024x0

are equivalent. Both will place the external monitor to the right of the laptop display within the virtual screen.

If the Virtual size is only 2048 wide the above command will fail as the combined width of the two displays exceeds the maximum virtual size. However it is possible to have overlap the display viewports. So to fit within the 2048 limit:

$ xrandr --output VGA --mode 1024x768 --pos 0x0 --output VGA --mode 1600x1200 --pos 448x0

Now automate it on login

To configure xrandr automatically during the first login, save this script to your computer as /etc/X11/Xsession.d/45custom_xrandr-settings:


# If an external monitor is connected, place it with xrandr

# External output may be "VGA" or "VGA-0" or "DVI-0" or "TMDS-1"
EXTERNAL_OUTPUT="VGA"
INTERNAL_OUTPUT="LVDS"
# EXTERNAL_LOCATION may be one of: left, right, above, or below
EXTERNAL_LOCATION="right"

case "$EXTERNAL_LOCATION" in
left|LEFT)
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
;;
right|RIGHT)
EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"
;;
top|TOP|above|ABOVE)
EXTERNAL_LOCATION="--above $INTERNAL_OUTPUT"
;;
bottom|BOTTOM|below|BELOW)
EXTERNAL_LOCATION="--below $INTERNAL_OUTPUT"
;;
*)
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
;;
esac

xrandr |grep $EXTERNAL_OUTPUT | grep " connected "
if [ $? -eq 0 ]; then
xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION
else
xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off
fi


When X starts, it will be mirrored across both screens until someone logs in. At that point this script will execute and xrandr will position the external monitor.
Sample Fn-F7 script

For further examples of the use of xrandr commands, and scripts to switch the display using the Function key Fn-F7 see Sample Fn-F7 script.
GUIs

Several graphical frontends are available for xrandr (all using GTK):

* Grandr
* URandR
* ARandR
* Zarfy — A GUI to libxrandr. It presents the user with visual representaion of active displays on an interactive map of the screen memory. Features free postioning, configuration saving, scripting for R&R and an alternate gui for switching between monitors.

It is possible to have Fn-F7 run such a GUI, see Sample Fn-F7 script#Having Fn-F7 run a RandR GUI.
Summing up

xrandr enables dynamic resizing of screens, switching both external and laptop screens on and off, and the applications windows can be dragged from one screen to the other. None of this requires configuring anything special for /etc/X11/xorg.conf.
the Virtual screen

A Virtual line is needed in the 'Display' SubSection of the of xorg.conf; it determines the size of the frame buffer into which the displays must fit. Without it the maximum virtual size will be limited to the size of the largest display that was connected when X was started. The maximum virtual size cannot be changed once X starts so needs to be large enough to accommodate the largest combination of displays you want to hotplug without having to restart X. If it is greater than 2048x2048 and you are using an Intel 945 (or less) chip then DRI is not possible. Making the Virtual size square makes rotation easy. A bigger Virtual requires more memory.

monitor windows must fit within the virtual screen
Output port names

Intel driver

* VGA - Analog VGA output
* LVDS - Laptop panel
* TV - Integrated TV output
* TMDS-1 - First DVI SDVO output
* TMDS-2 - Second DVI SDVO output

The SDVO and DVO TV outputs are not supported by the driver at this time.

radeon driver

* VGA-0 - Analog VGA output
* LVDS - Laptop panel
* S-video - Integrated TV output
* DVI-0 - DVI output

Note for Gnome users

Gnome places the menu bar on screen 0 and thus with the Intel chip and driver Screen 0 (the external VGA monitor) will always be the default display if it is connected. This applies even if the external monitor is switched off but the cable connected: if you have a blank laptop monitor check if you have anything plugged in to the VGA port. Also beware that desktop icons and windows can disappear into the invisible parts of the virtual display. (see diagram below). If you want the panel(s) to appear by default on a different head, drag it to the head you want it on and GNOME will keep it there.
Note for Ubuntu Gutsy users

There is a Graphical Configuration Tool, (displayconfig-gtk) included with Ubuntu 7.10. At present it dosn't work too well. It is found in the menu: 'System: Administration: Screens and Graphics'. As using it will wreck your xorg.conf, I recommend removing it.
Gleanings
Notes from xserver-xorg-video-intel.readme

Known Limitations - No support for "zaphod mode" dualhead. This is the mode in which two Device sections are placed in the config file, and doesn't support DRI or many other features. Instead, only "MergedFB-style" dualhead is supported. - No support for X Screens larger than 2048 pixels in either direction before the 965. This reflects hardware limitations in the x direction on those older chips, and limits dualhead functionality. It may be possible to extend the limit vertically on these older chips. - i855 XV may cause hangs. This was present in the previous release, and no workaround is known. - SDVO TV-out cards not supported. This should be fixed in the next release. - Gray output with integrated TV-out and PAL TVs. - EXA support unstable on i845. - Some GM965 systems, such as the Thinkpad T61, probe the TV as being connected even when no output connector is available.

Common issues not caused by the driver - Font sizes (DPI) are wrong. Some displays incorrectly report their physical size, which is harmless on most OSes that always assume 96dpi displays. This can be fixed through quirks for specific monitors in the X Server, and the output of xrandr --prop along with a physical measurement of the screen size in a bug report against the server can help get that fixed. - gnome-panel is located in the middle of the screen. gnome-panel places itself within head #0's boundaries, which doesn't work well with a second head covering the same area as head #0 but larger. - Older resolution-changing applications have poor results in multihead systems. Previous extensions such as RandR 1.1 exposed only a single output to client programs, and those requests map poorly to multi-head systems. Currently, those requests map to just one of the outputs in the RandR 1.2 environment, and those applications need to be updated to RandR 1.2 API when available for better results.
Xorg mailing list

FreeDesktop.org 2007-June 025469 FreeDesktop.org 2007-June 025484 FreeDesktop.org 2007-July 026340

the 3D engine has an 11 bit coordinate space at one point making it impossible to draw to areas beyond 2048x2048. At another point, it has a stride limit of 8192 bytes, so you can't even draw to a subset of a larger frame buffer.

One more bit in both of these registers would have solved the problem for pretty much any supportable monitor configuration (the chip can only support two single-channel DVI outputs at the most; 1920 is the widest size supported at single-channel speeds).

For multiple monitors, the driver could allocate multiple frame buffers and step through them one at a time with appropriate clipping. It would be icky, but could be made to work.

Of course, the latest hardware (965G/965GM) has plenty of coordinate space, which does tend to reduce the odds that someone will get excited enough to go fix the driver for older chips.

The Gnome menu bar lands on Xinerama Screen 0 at this point, which isn't currently something that you can set through RandR. On Intel the allocation to Screen 0 is determined by CRTC order and LVDS only runs on screen 1.

FreeDesktop.org 2007-June 026053

Blanking of external screen when using xrandr

It's checking to see if you have anything connected to the TV output.
To do that, it needs to temporarily unplug the VGA.
You can avoid this by ignoring the TV output
Section "Monitor"
Identifier "TV"
Option "Ignore" "True"
EndSection
Section "Device"
Option "monitor-TV" "TV"
EndSection
If your machine cannot ever have a TV adapter (even with a docking station),
we can add a quirk to the driver to never look at the TV output. That requires
the pci subsystem values (from lspci -n -v) to plug into the quirk table.

default for 'Virtual'

> Version 2.1.1-0ubuntu2 seems to set the default Virtual size (maximum
> screen size) to 1920 x 1920, if there is no entry in xorg.conf. I take
> it the maximum screen size for the i915 chipset family is 2048 x 2048,
> so why not have it at that? This would make dualscreen setups a bit easier.
The default settings is found by taking the largest resolution in either
x or y dimension and making a square from that. This allows for easy
rotation should you want to do so.
I believe you should be able to do dual screen up to 8192x8192, though
only through two monitors (Only two pipes are available for output), but
that 3D acceleration is only supported up to 2048x2048. Thus as soon as
you set your virtual size above 2048x2048, you lose 3D acceleration.
The current driver cannot reallocate the frame buffer, so whatever size
you start with is the maximum the screen can ever become, and that this
amount of physical memory is tied down for the whole X server run.

Primary output for Laptop + external screen

>the desired behavior of the video
> drivers in typical laptop situations with an internal display and an
> external screen attached (extending the desktop).
>
> Currently for example the intel driver uses the external screen as the
> primary output. It is listed first with xrandr. I'm not sure if this is
> intentional or just coincidence.
It's coincidence -- the laptop hardware has two crtcs, and the LVDS can
only be driven by the second.
Note that RandR doesn't really want the order to be significant; it
would be better if the desktop environment knew about outputs and could
refer to a specific output as 'primary' or 'holds toolbar' or whatever.

Uncovered a workaround for black and white TV-out "known limitation" listed above on a intel 945GM chipset running i810-2.1.1 driver and xrandr-1.2.2. Get TV running in black and white. Then run command.

xrandr --output TV --set TV_FORMAT PAL; xrandr --output TV --mode 1024x768

substitute TV_FORMAT and mode as required. Note that the command "xrandr --output TV --set TV_FORMAT PAL" gives an error but appears to work as the subsequent mode change converts screen to colour.
Notes for X31, X32, T30 / Radeon 7000, Radeon 7500 users

X31 and X32 have an ATI Mobility Radeon 7000 with only 16MB RAM. This is not enough for big screens and DRI. Neither with radeon-default virtual size of 2048x1200, nor with a customized virtual of 2304x1024 (for one 1024x768 and one 1280x1024 screen). But this only applies for 24-bit color depth. Using only 16-bit and DRI works fine with the big virtual screen.

If you really want 24-bit depth, and do not need a bigger screen as your LCD, try setting Virtual to "1024 768", this will enable DRI in 24-bit too, but you won't be able to extend your screen anymore (well, clone will still work though).
Further Note
My T30 (Radeon 7500) with the Xorg radeonhd driver version 1.2.1-1 (from Debian unstable) reports the following:

(II) RADEON(0): Detected total video RAM=16384K, accessible=65536K (PCI BAR=131072K)
(--) RADEON(0): Mapped VideoRAM: 16384 kByte (64 bit DDR SDRAM)
(II) RADEON(0): Color tiling enabled by default
(WW) RADEON(0): Requested desktop size exceeds surface limts for tiling, ColorTiling disabled
(II) RADEON(0): Max desktop size set to 2304x1024

I don't understand exactly what this means, but it does support the entire large desktop at 24 bit depth, even though the card reports only 16M "total video RAM".


reference
http://www.thinkwiki.org/wiki/Xorg_RandR_1.2
http://intellinuxgraphics.org/dualhead.html

Monday, May 11, 2009

Login Graphically to A Computer in a Remote Location using freeNX

The ability to login graphically into any computer from a remote location has a number of uses. In my case it allows me to create a setup were students in my school can easily login graphically into the universities computer lab and use many of the applications which are installed there (like Matlab which is only licensed to run on our lab computers) It also allows me to log into my work computer from home. To create this setup we would need a tool called Freenx.

FreeNX
FreeNX is a system that allows you to access your desktop from another machine over the Internet. You can use this to login graphically to your desktop from a remote location.

Advantages of FreeNX
One advantage of FreeNX is that it is based on the SSH Protocol so your packets are transferred over an encrypted channel which in human language means nasty people can’t see what you are doing and potentially compromise your computer

Installation

Installation FreeNX is in Two Phrase the server and the client

Server Installation

and we install with:
sudo apt-get update ; sudo apt-get install freenx

That is all that is needed for the installation of freenx server on our remote machine.

Client Installation

The client is installed on the machine you want to login from.

There are Two type of FreeNX clients available the non free and open source version (and freedom hating version :) ) and the free and open source version

The Non-free version
This is the official NX version and can not be installed from the Ubuntu repository but can be deb version for ubuntu can be downloaded from here
Double click to install.
Once installed you find it at Application-Internet-NX Client for Linux

The Free and Open Source version can be downloaded from the Ubuntu repository by running:
sudo apt-get install qtnx
Once installed you find it at Application-Internet-QTNX

Usage
What i really love about FreeNX is its usage, its very easy to use and all your do is launch the client which once installed can be found under /Application/Internet/Nx Client for LInux

Wizard

Once you start the Program it displays a wizard which would guide you through the configuration process

session

=Session: First Thing you do is create a session which is like a profile of the remote machine you want to connect to. You can have many sessions of different remote machines which allows you to easily choose a session and login to the machine configure to the session.
Host: The IP address of the remote machine you want to login to
Select you Internet Type: Here is were you also get to indicate what type of internet connection you are running, NX compresses your data over the network so the slower your internet connection the higher the compression rate of your data (or so it seems) then you also put in the . Leave the port as 22 since that is the default that ssh uses (unless you have ssh using another port on the remote machine)

Friday, May 8, 2009

c program for unicode in linux

/*Program to check unicode support for gujurati language */


#include < stdio.h >
#include < locale.h >

int main()
{
char *locale;

printf("without using unicode for gujrati language\n");
printf("%ls\n", L"નમસતે રામ ,મેરા દેસ મહાન");
printf("\n");
printf("using unicode for gujrati language\n");

locale=setlocale(LC_ALL, "gu_IN.utf8");
if (!locale) {
fprintf(stderr, "Can't set the specified locale! "
"Check LANG, LC_CTYPE, LC_ALL.\n");
return 1;
}

printf("\n");
printf("%ls\n", L"નમસતે રામ ,મેરા દેસ મહાન");
printf("\n");
return 0;
}


#gcc -o unicode unicode.c
#./unicode
without using unicode for gujrati language

using unicode for gujrati language

નમસતે રામ ,મેરા દેસ મહાન

Unicode and Unicode Transformation Format

Unicode is not just a programming tool, but also a political and economic tool. Applications that do not incorporate world language support can often be used only by individuals who read and write a language supported by ASCII. This puts computer technology based on ASCII out of reach of most of the world's people. Unicode allows programs to utilize any of the world's character sets and therefore support any language.

Unicode allows programmers to provide software that ordinary people can use in their native language. The prerequisite of learning a foreign language is removed and the social and monetary benefits of computer technology are more easily realized. It is easy to imagine how little computer use would be seen in America if the user had to learn Urdu to use an Internet browser. The Web would never have happened.

Linux has a large degree of commitment to Unicode. Support for Unicode is embedded into both the kernel and the code development libraries. It is, for the most part, automatically incorporated into the code using a few simple commands from the program.

The basis of all modern character sets is the American Standard Code for Information Interchange (ASCII), published in 1968 as ANSIX3.4. The notable exception to this is IBM's EBCDIC (Extended Binary Coded Decimal Information Code) that was defined before ASCII. ASCII is a coded character set (CCS), in other words, a mapping from integer numbers to character representations. The ASCII CCS allows the representation of 256 characters with an eight-bit (a base of 2, 0, or 1 value) field or byte (2^8 =256). This is a highly limited CCS that does not allow the representation of the all of the characters of the many different languages (like Chinese and Japanese), scientific symbols, or even ancient scripts (runes and hieroglyphics) and music. It would be useful, but entirely impractical to change the size of a byte to allow a larger set of characters to be coded. All computers are based on the eight-bit byte. The solution is a character encoding scheme (CES) that can represent numbers larger than 256 using a multi-byte sequence of either fixed or variable length. These values are then mapped through the CCS to the characters they represent.

Unicode definition

Unicode is usually used as a generic term referring to a two-byte character-encoding scheme. The Unicode CCS 3.1 is officially known as the ISO 10646-1 Universal Multiple Octet Coded Character Set (UCS). Unicode 3.1 adds 44,946 new encoded characters. With the 49,194 already existing characters in Unicode 3.0, the total is now 94,140.

The Unicode CCS utilizes a four-dimensional coding space of 128 three-dimensional groups. Each group has 256 two-dimensional planes. Each plane consists of 256 one-dimensional rows and each row has 256 cells. A cell codes a character at this coding space or the cell is declared unused. This coding concept is called UCS-4; four octets of bits are used to represent each character specifying the group, plane, row and cell.

The first plane (plane 00 of the group 00) is the Basic Multilingual Plane (BMP). The BMP defines characters in general use in alphabetic, syllabic and ideographic scripts as well as various symbols and digits. Subsequent planes are used for additional characters or other coded entities not yet invented. This full range is needed to cope with all of the world's languages; specifically, some East Asian languages that have almost 64,000 characters.

The BMP is used as a two-octet coded character set identified as the UCS-2 form of ISO 10646. ISO 10646 USC-2 is commonly referred to as (and is identical to) Unicode. This BMP, like all UCS planes, contains 256 rows each of 256 cells, and a character is coded at a cell by just the row and cell octets in the BMP. This allows 16-bit coding characters to be used for writing most commercially important languages. USC-2 requires no code page switching, code extensions or code states. USC-2 is a simple method to incorporate Unicode into software, but it is limited in only supporting the Unicode BMP.

To represent a character coding system (CCS) of more than 2^8 = 256 characters with eight-bit bytes, a character-encoding scheme (CES) is required.


Unicode transformations

In UNIX the most-used CES is UTF-8. It allows for full support of the entire Unicode, all pages and planes, and will still read standard ASCII correctly. The alternatives to UTF-8 are: UCS-4, UTF-16, UTF-7,5, UTF-7, SCSU, HTML, and JAVA.

Unicode Transformation Formats (UTFs) are CESs that support the use of Unicode by mapping a value in a multi-byte code. This article will examine the UTF-8 CCS, the most popular format.

UTF-8

The UTF-8 transformation format is becoming a dominant method for exchanging international text information because it can support all of the world's languages and is compatible ASCII. UTF-8 uses variable-width encoding. The characters numbered 0 to 0x7f (127) encode to themselves as a single byte, and larger character values are encoded into 2 to 6 bytes.

Table 1. UTF-8 coding
0x00000000 - 0x0000007F: 0xxxxxxx
0x00000080 - 0x000007FF: 110xxxxx 10xxxxxx
0x00000800 - 0x0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx
0x00010000 - 0x001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
0x00200000 - 0x03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
0x04000000 - 0x7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx

The 10xxxxxx byte is a continuation byte with the xxxxxx bit positions filled with the bits of the character code number in binary representation. The shortest possible multi-byte sequence that can represent the code is used.

UTF-8 coding examples

The Unicode character copyright sign character 0xA9 = 1010 1001 is encoded in UTF-8 as:

11000010 10101001 = 0xC2 0xA9


and the "not equal" symbol character 0x2260 = 0010 0010 0110 0000 is encoded as:

11100010 10001001 10100000 = 0xE2 0x89 0xA0


The original values can be seen by taking out the continuation byte values:

[1110]0010 [10]001001 [10]100000
0010 001001 100000
0010 0010 0110 0000 = 0x2260


The first byte defines the number of octets to follow, or if it is 7F or less, it is the value of an ASCII equivalent. Starting each octet with 10xxxxxx makes certain that a byte is not mistaken for an ASCII value.


UTF support

Before you start using UTF-8 under Linux make sure the distribution has glibc 2.2 and XFree86 4.0 or newer versions. Earlier versions lack UTF-8 locale support and ISO10646-1 X11 fonts.

Before UTF-8, Linux users used various different language-specific extensions of ASCII like ISO 8859-1 or ISO 8859-2 in Europe, ISO 8859-7 in Greece and KOI-8 / ISO 8859-5/CP1251 in Russia (Cyrillic). This made data exchange problematic and required application software to be programmed for differences between these encodings. Support was incomplete and exchanges untested. Major Linux distributors and application developers are working to have Unicode, primarily in the UTF-8 form, made standard in Linux.

In order to identify a file as Unicode, Microsoft suggested all Unicode files should start with the character ZERO WIDTH NOBREAK SPACE (U+FEFF). This acts as a "signature" or "byte-order mark (BOM)" to identify the encoding and byte-order used in a file. However, Linux/UNIX does not use BOMs because this would break existing ASCII-file syntax conventions. On POSIX systems, the selected locale identifies the encoding expected in all input and output files of a process.

There are two approaches for adding UTF-8 support to a Linux application. First, data is stored in UTF-8 form everywhere, which results in only a very few software changes (passive). Alternatively, UTF-8 data that has been read is converted into wide-character arrays using standard C library functions (converted). Strings are converted back to UTF-8 when output as with the function wcsrtombs():

Listing 1. wcsrtombs()

#include
size_t wcsrtombs (char *dest, const wchar_t **src, size_t len, mbstate_t *ps);


The method chosen depends upon the nature of the application. Most applications can operate passively. This is why the use of UTF-8 in UNIX is popular. Programs such as cat and echo need no modification. A byte stream is simply a byte stream and no processing is done on it. ASCII characters and control codes do not change under UTF-8.

Small changes are needed for programs that count characters by counting the bytes. In UTF-8 applications do not count any continuation bytes. The C library strlen(s) function needs to be replaced with the mbstowcs() function if a UTF-8 locale has been selected:

Listing 2. mbstowcs() function

#include
size_t mbstowcs(wchar_t *pwcs, const char *s, size_t n);


A common use of strlen is to estimate display-width. Chinese and other ideographic characters will occupy two column positions. The wcwidth() function is used to test the display-width of each character:

Listing 3. wcwidth() function

#include
int wcwidth(wchar_t wc);



C support for Unicode

Officially, starting with GNU glibc 2.2, the type wchar_t is intended to be used only for 32-bit ISO 10646 values, independent of the currently used locale. This is signaled to applications by the definition of the __STDC_ISO_10646__ macro as required by ISO C99. The __STDC_ISO_10646__ is defined to indicate that wchar_t is Unicode. The exact value is a decimal constant of the form yyyymmL. For example, use:

Listing 4. Indicating that wchar_t is Unicode

#define __STDC_ISO_10646__ 200104L


to indicate that values of type wchar_t are the coded representations of the characters defined by ISO/IEC 10646 and all amendments and technical corrigenda as of the specified year and month.

It would be utilized as shown in this example, which uses the macro to determine the method of writing double quotes in ISO C99 portable code:

Listing 5. Determining the method of writing double quotes

#if __STDC_ISO_10646__
printf("%lc", 0x201c);
#else
putchar('"');
#fi


The locale

The proper way to activate UTF-8 is the POSIX locale mechanism. A locale is a configuration setting that contains information about culture-specific conventions of software behavior. This includes character encoding, date/time notation, sorting rules and measurement systems. The names of locales usually consist of ISO 639-1 language, ISO 3166-1 country codes and optional encoding names and other qualifiers. You can get a list of all locales installed on your system (usually in /usr/lib/locale/) with the command locale -a.

If a UTF-8 locale is not preinstalled, you can generate it using the localedef command. To generate and activate a German UTF-8 locale for a specific user, use the following statements:

Listing 6. Generating a locale for a specific user

localedef -v -c -i de_DE -f UTF-8 $HOME/local/locale/de_DE.UTF-8
export LOCPATH=$HOME/local/locale
export LANG=de_DE.UTF-8


It is sometimes useful to add a UTF-8 locale for all users. This can be by root using the following instruction:

Listing 7. Generating a locale for all users

localedef -v -c -i de_DE -f UTF-8 /usr/share/locale/de_DE.UTF-8


To make it the default locale for every user add into the /etc/profile file the following line:

Listing 8. Setting the default locale for all users

export LANG=de_DE.UTF-8


The behavior of functions that deal with multi-byte character code sequences depend on the LC_CTYPE category of the current locale; it determines locale-dependent multi-byte encoding. The value LANG=de_DE (German) will cause output to be formatted in ISO 8859-1. The value LANG=de_DE.UTF-8 will format the output to UTF-8. The locale setting will cause the %ls format specifier in printf to call the wcsrtombs() function in order to convert the wide character argument string into the locale-dependent multi-byte encoding. Country identifiers in the locales such as: LC_CTYPE= en_GB (English in Great Britain) and LC_CTYPE= en_AU (English in Australia) differ only in the LC_MONETARY category for the name of currency and the rules for printing monetary amounts.

Set the environment variable LANG to the name of your preferred locale. When a C program executes the setlocale() function:

Listing 9. setlocale() function

#include
#include
//char *setlocale(int category, const char *locale);
int main()
{
if (!setlocale(LC_CTYPE, ""))
{
fprintf(stderr, "Locale not specified. Check LANG, LC_CTYPE, LC_ALL.
");
return 1;
}


The library will test the environment variables LC_ALL, LC_CTYPE, and LANG in that order. The first one of these that has a value will determine which locale data is loaded for the LC_CTYPE category. The locale data is split up into separate categories. The LC_CTYPE value defines character encoding and LC_COLLATE defines the sorting order. The LANG environment variable is used to set the default locale for all categories, but LC_* variables can be used to override individual categories.

You can query the name of the character encoding in your current locale with the command locale charmap. This should say UTF-8 if you successfully picked a UTF-8 locale in the LC_CTYPE category. The command locale -m provides a list with the names of all installed character encodings.

If you use exclusively C library multi-byte functions to do all the conversion between the external character encoding and the wchar_t encoding that you use internally, then the C library will take care of using the right encoding according to LC_CTYPE. The program does not even have to be explicitly coded to the current multi-byte encoding.

If the application is required to be specifically aware of the UTF-8 (or other) conversion method and not use the libc multi-byte functions, the application has to find out whether to activate the UTF-8 mode. X/Open-compliant systems with a library header can use the code:

Listing 10. Detecting whether the current locale uses the UTF-8 encoding

BOOL utf8_mode = FALSE;

if( ! strcmp(nl_langinfo(CODESET), "UTF-8")
utf8_mode = TRUE;


to detect if the current locale uses the UTF-8 encoding. The setlocale(LC_CTYPE, "") function must be called to set the locale according to the environment variables first. The nl_langinfo(CODESET) function is also what the locale charmap command calls to find the name of the encoding specified by the current locale.

Another method that could be used is to query the locale environment variables:

Listing 11. Querying the locale environment variables

char *s;
BOOL utf8_mode = FALSE;

if ((s = getenv("LC_ALL")) || (s = getenv("LC_CTYPE")) || (s = getenv ("LANG")))

{
if (strstr(s, "UTF-8"))
utf8_mode = TRUE;
}


This test assumes the UTF-8 locales have the value "UTF-8" in their name, which is not always true, so the nl_langinfo() method should be used.