How to add or remove launchers from your gnome classic/fallback desktop panel

This is a nice little hack that comes handy when you want to add or remove launchers (shortcuts to your favorite programs such as firefox or gedit) to an existing panel, or add an entirely new panel to your gnome-classic or fallback desktop. On my Linux Mint workstation, I prefer the gnome-classic version instead of the default cinnammon desktop for reasons of speed and simplicity. I soon found out, however, that process of adding/removing launchers or adding a new panel requires a special key combination that is not easily found without going through some extensive documentation!! Here is how you do it:

To add a new launcher:

1. Press the WIN (Super) and ALT keys together.
2. While keeping them pressed, right-click the panel.
3. You will then get a popup menu saying “New Panel”, or “Add to Panel”.
4. Click on the second option and select your program.

To edit/remove an existing launcher:

1. Follow steps 1 & 2 from above.
2. You will get a popup menu saying “Move” and “Remove from Panel”.
3. Click on your choice.

Advertisements

How to make brightness changes permanent in your Linux Desktop?

Quite recently, I’ve faced this nagging little issue on all the distros I tried. These included Ubuntu 12.04 LTS, Linux Mint 11.1 and Fedora 18. Whenever I changed my computer’s brightness setting either through the gnome-settings applet or by using hotkeys, the changes were only temporary. On next reboot, they would vanish!! Now what is the easiest way to make your chosen setting permanent? After much googling and head-scratching, I finally arrived at the answer.

First of all, NEVER place anything like this in a startup script:

echo 4 > /sys/class/backlight/acpi_video0/brightness

(See this update if you found this folder empty or missing)

Although this command might change your brightness, again the effects are only temporary and will be lost on your next reboot. If you attempt to place this in /etc/rc.local, it may not always work due to permission issues. Instead of ending up chmod-ing the permissions to the brightness file and cause any other issues in turn, the recommended approach is to use xbacklight, the tool fit for this purpose.

Here is the easy way:

1. Install xbacklight from your package repository. On Linux Mint, I did this:

sudo apt-get install xbacklight

2. Place xbacklight command with your chosen settings in your “startup-applications” applet. In my case I had the command: xbacklight -set 50

On Mint Linux, it looked something like this:

Image for xbacklight-startup
Configure xbacklight in startup-applications applet

Thats all. This effectively sets brightness to 50% by default upon your each login. Enjoy!!

UPDATE on 04-mar-2013: I came to know today that the 3.4 kernel has broken some things related to acpi-support for setting brightness. As a result of that the /sys/class/backlight folder is empty and the xbacklight program also won't work!! Solution? Either upgrade/downgrade your kernel or add "acpi_backlight=vendor" to your menu.lst. See this link for more information:

http://superuser.com/questions/548459/how-to-change-screen-brightness-on-toshiba-satellite-l850-djs-in-linux/556745#comment683067_556745

Some free tools to help you develop better .NET Solutions!

1. DebugView: DebugView is a free tool that lets you view the debug output written by applications on the windows operating system. You might be aware that many Try/Catch blocks in .NET applications use the Debug.WriteLine statement to make note that an error or exception occurred. DebugView displays an output log of all such diagnostics written by your application thus making the task of tracking errors much easier. In fact, on live or production systems, it is not always possible to run your application in debug mode. In such cases, DebugView comes very handy as it lets you see the exceptions written by your .NET application without disrupting any user activity.

http://www.sysinternals.com/Utilities/DebugView.html

2. FxCop: For those who wish to follow the industry best-practices while coding .NET applications, this free tool from Microsoft is a great boon. FxCop helps you with code-review by analyzing your .NET assembly and highlighting several programming and design issues such as:

  • Not following proper naming-conventions for constants and variables.
  • Improper commenting of code.
  • Inappropriate use of public variables.
  • Using obsolete or irregular keywords like goto.
  • Performance issues (use of excessive locals, declaring unused parameters, etc.)
  • Security issues (not specifying marshalling for pinvoke string arguments, etc.)
  • Design issues (Not strong-naming an assembly, hiding base-class methods, etc.)

To see a complete list of FxCop rules with an in-depth discussion and example, see msdn:

http://msdn.microsoft.com/en-us/library/bb429379(v=vs.80).aspx

3. StyleCop: StyleCop is another opensource tool for static code analysis. It analyzes the C# source-code unlike FxCop which analyzes the assembly. It thus applies a different set of rules from FxCop. These rules fall in seven basic categories:

  • Documentation
  • Layout
  • Maintainability
  • Naming
  • Ordering
  • Readability
  • Spacing

4. CLR Profiler:CLR Profiler is an excellent tool to help you identify performance issues in your .NET application. Many a times it so happens that you notice your application is performing poorly or consuming a lot of memory, but could not put your finger on the exact function or class in code that is causing this. This tool does exactly that! It creates a call graph analysis when your .NET application is run, along with the behaviour of the Grabage-Collector. CLR Profiler is a free download from Microsoft:

Download CLR-Profiler from Microsoft

5. NANT: NANT is a free and opensource tool for automating the software build process.  NANT is specifically targetted at building .NET solutions. It automatically fetches the dependency tree and builds them in order for your .NET solution. NANT is free software:

http://nant.sourceforge.net/

6. Subversion/TortoiseSVN: Subversion is an excellent opensource collaboration software used by several large firms to manage inhouse development in large teams. Subversion is the server component that provides a central repository to store your .NET code, while there are several Subversion clients (TortoiseSVN being the most popular) that integrate with your windows-shell and provide SCM features and tools to:

  • Check-out, browsing and check-in of code in the SVN repository.
  • View change log and changes made by other users to the repository.
  • Compare or merge your local code with the base version in repository.
  • Resolve conflicts (if any) with the base version by gradually accepting/rejecting the changes.

Both Subversion and TortoiseSVN are 100% free and opensource:

http://subversion.tigris.org/
http://tortoisesvn.net/downloads.html

7. Redgate Reflector: Not many people know that the EXE or DLL compiled from your Visual-Studio IDE is prone to reverse-engineering if you ship them as it is. That is because, a .NET assembly (EXE/DLL) is not directly compiled to the low-level machine code, but rather, into CIL (Common Intermediary Language) to achieve architecture independence and reduce compile time. One such industry-standard tool to reverse engineer a .NET assembly is the Redgate Reflector. Reflector takes the .NET assembly as input and regenerates the entire source-code and solution in the language of your choice (VB/C#/F#/etc). Though Reflector is a commercial product, you can use the free demo version to decompile .NET assemblies (but with some limitations):

http://www.reflector.net/

8. AnkhSVN/SharpSVN: AnkhSVN is yet another opensource tool which is managed by Collabnet, the creators of  SVN Server itself. It seamlessly fits into the Visual Studio IDE and allows you to check-out and commit code to your SVN repositories. Also, the api used by SVN called SharpSVN is also an opensource .NET 2.0 library. You can add its reference to your .NET project if you need to automate code check-outs and commits from your application itself:

http://sharpsvn.open.collab.net/

9. Windows SDK Tools: You can find a bunch of usefull stuff already installed in your Windows SDK directory itself! These are typically installed in the below folder:

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\

sn.exe is the strong-name utility that you can use to strong-name your .NET assemblies.

gacutil.exe is used to install/uninstall an assembly from the .NET GAC (Global Assembly Cache).

wsdl.exe automatically generates .NET code for xml web-service clients to connect to a web-service.

svcutil.exe pregenerates C# serialization code that is required for types that can be serialized using XML Serializer.

ildasm.exe is a disassembler that generates CIL code from .NET assemblies.

References:

http://en.wikipedia.org/wiki/.NET_Reflector
http://en.wikipedia.org/wiki/StyleCop
http://en.wikipedia.org/wiki/CLR_Profiler
http://en.wikipedia.org/wiki/NAnt
http://en.wikipedia.org/wiki/AnkhSVN

How to setup a Virtual LAN on your machine using Oracle VirtualBox

After running many errands on google, wikipedia and suchthings in search of a good  Virtualization solution for my Windows-7 HP machine, I’ve discovered a sleek new solution for many virtualization tasks like trying out new Linux distros, testing my C# applications on a fresh Operating System, creating a virtual “Network of computers” on my machine, etc. This solution came in the form of Oracle VirtualBox. I had short-listed three virtualization candidates for this – VirtualBox, VMWare Player and Microsoft VirtualPC in that order. However, VirtualBox paid off so well that I had no need to look anywhere else. If you haven’t set up VirtualBox already, here is how you do it:

Step1: Download VirtualBox and a guest OS image

Download and install the latest package for your host OS from https://www.virtualbox.org/wiki/Downloads. In order to achieve virtualization, you will obviously need a guest OS either in the form of an installable CD/DVD or an .ISO image. Luckily, VirtualBox doesn’t insist on an actual CD/DVD disk. You may choose to install either from a disk, or directly from the .ISO image of the guest OS itself! Here are some places to get the latest versions of some of the popular OS images:

Debian: http://www.debian.org/mirror/list

Ubuntu: http://www.ubuntu.com/download

openSUSE: http://software.opensuse.org/

Fedora: http://fedoraproject.org/en/get-fedora-options

Linux Mint: http://www.linuxmint.com/download.php

Step2: Configure

VirtualBox provides many out of the box features including a versatile GUI to make the job of creating a virtual machine as easy as possible. Once you have installed VirtualBox, the next step is to create a virtual-machine for your new OS. This is like a shell that provides all basic features such as BIOS settings to control how the new OS starts, its hardware and graphics profile, and also its network setup. To create a new VM, start the VirtualBox program and click the new icon on the top:

VirtualBox will now ask you several questions such as the type of operating-system and how much disk-space to allocate to your virtual hard-drive.

How to allocate space to your virtual hard-drive?

The default setting of a dynamically growing disk suffices most purposes. The advantage of this is that you can play with several VMs with each getting a good hard-disk allocation like 100 or 200 Gigabytes. Mind you, this space is not actually allocated on your host-OS in case of dynamic memory, but the space will grow as and when used.

However, if you have plenty of space on your host-drive with memory running in several gigs or terabytes, or you want to allocate a fixed size on your host in advance, then you should go for fixed-size drive which performs better compared to dynamically allocated one.

The entire VM creation process is quite intuitive with a wizard-like interface. If you don’t understand anything, just go with the default settings. You can change later anything you want. Once you create your new VM, you can start it using the start icon on top, then proceed with the installation of your particular OS.

VirtualBox provides several ways to control and interact with the new machine. For instance, by default, the right control key (or right command-key in Mac Osx) is used to leave control to the host-OS. You can toggle between full-screen and normal mode by pressing Right-Ctrl+F key.

Once your installation is complete, you may have to install some guest addition packages on your guest OS. These are software that enable VirtualBox to better the user experience for that OS by providing features like 3D-graphics, USB support, native resolution/modes, etc.

Step 3: Establish a network between the guest and host machines

Here comes an important reason why most people (myself included) want to implement virtualization in the first place. To create and experiment with all kinds of networks without the risk (or taking the trouble) of creating an actual one. And here is where VirtualBox excels by providing several options for networking out of the box. VirtualBox installs an additional NIC (Network Interface Card) on your host computer to identify itself while communicating with the guest. By default the host gets an IP address of 192.168.56.1. You can change the network modes, IP and other network settings by right-clicking your virtual machine on the left and clicking Settings. These are the networking modes that work with VirtualBox guest computers:

  1. NAT (Default)
  2. Host-only Network (Most secure)
  3. Bridged Network (Least secure)
  4. Internal-Network (Betweeen guests only)
  5. Not Attached (No connectivity, guest isolated)

NAT: By default, the networking mode for your virtual machine is NAT (Network Address Translation) mode. This works something like this:

Assume that on your laptop, you are accessing internet through a router (typical in most home or wifi network scenarios). NAT works in the same way. This is a very secure way to access a network. In this case, your Guest computer sits behind the VirtualBox router. It can even access internet from through the host computer’s modem or LAN. However it is completely hidden from the rest of your network and the host computer thanks to the VirtualBox router-cum-firewall. Any traffic coming

from the guest computer will be seen as originating from your host computer.

Host-only Network: This is the second mode allowed by VirtualBox. Obviously, this is the most secure method among the three as there the “virtual-cable” is just laid between the guest and host computers, no other computer on the network will be visible to the guest. Think of this as a peer-to-peer computers between any two computers on a LAN:

In this case, the guest is actually (or rather “virtually”) cut off from the rest of the world, except the host computer. In this case, if you want to provide internet connectivity to the guest, you will have to turn your host into a proxy server. Then the guest can indirectly access the internet through your guest’s proxy server. This scenario is very useful when say, you are developing a proxy server and you want to test it. Other scenario is when you don’t need network in the guest at all. Of course, VirtualBox also provides an additional “Not Attached” mode if you want to totally isolate your guest from even the host computer too.

Bridged-Network: This is the preferred mode to establish full-fledged networking on your guest. In this case, your guest actually becomes a peer on your network. All other computers can “see” the guest as a different peer from the host. In other words, it is as good as setting up another peer with network and cabling on your LAN. VirtualBox achieves this by “sniffing” the incoming network packets on all your NICs directed at the guest, and in-turn “injecting” packets that are send by the guest to other peers:

Be warned however, that this mode is the least secure way to connect the guest, and use it only when you know what you are doing, and you really need to. Use the NAT mode as far as possible. I’ve myself never yet found a use for this mode. Especially, when you are connecting to the Internet without a proxy, remember that you are connecting directly without a router in between. In this case, you need a firewall which is quite strong. The Windows built-in firewall is preferred for windows guests which is on by default. On RHEL-like system such as Fedora or CentOS, there is a built-in firewall that you have to initially configure. Similarly on debian based systems like Ubuntu and MintOS, there is the ufw package which stands for “Uncomplicated firewall”.

Internal-Network: If, for some reason, you want all or some guests to internally communicate, while still keeping them isolated from host and the rest of your network, VirtualBox provides this mode out of the box:

Just set this mode for those guests you want to keep internally connected. By default all guests are assigned a dynamic IP address in the range of 10.0.2.0 (in all modes) by the built-in DNS servers in the VirtualBox. You will not want to change this to a static IP-address unless you have a specific reason to do so. Also, remember to keep all guests that you want internally connected in the same domain (for linux or Win-Server hosts), or the same workgroup (Windows hosts).

Not Attached: Finally, there is the mode for complete isolation, wherein the “virtual-cable” is as good as non-existent between the guest and host. In this mode, there is zero connectivity between your guest and host:

However, do remember that the guest can still access your CD-drive or an ISO depending on your setup. There is also a feature for “Shared Folders” which you can set in the virtual machine’s “Shared Folders” settings. When you map a folder on your guest, you have the option to “auto-mount” it when your gust starts. For example, you have shared your host machine’s C:\library folder as and mapped as library folder in guest. When your linux guest starts, it will be automatically mounted as “/media/sf_library” by default.

Hopefully, the above instructions should suffice. However, with the complexity involved in Virtualization, there is a big chance that anything has gone wrong or some components did not work as expected. In that case these are the holy sites to visit:

  1. VirtualBox User Manual: http://www.virtualbox.org/manual/UserManual.html
  2. VirtualBox Forums: https://www.virtualbox.org/wiki/Community
  3. SuperUser: http://www.superuser.com

How to create an FTP client in C#

Creating an FTP client in a CLR compliant languge such as C# is truly a breeze compared to native languages like C or C++. The .NET Framework class library hands you the useful classes of System.Net on a platter which you can use to write your FTP functionality without worrying about things like memory allocation, protocol handling, etc. The .NET API does that on your behalf!

Before writing the code, it is useful to sit down and give a thought to your program design. Do you want to create a library to reuse in a larger project, or just a Windows app that acts as an FTP client? If you are a student doing some test project, I bet its the latter you will prefer! However, object-oriented programming and the concept of object-reuse dictate that you create a library first and then proceed with building your GUI, though it takes a little bit of extra effort.

In this tutorial I’ll briefly explain the functionality of libftp, an FTP library I have created in C# which I can seamlessly integrate into any application I develop or distribute it as a class-library/DLL. I also built a proof-of-concept Windows Forms application along with, to ensure the new functionality is working well. The library and application are available as open-source project on codeplex. You can browse through the code, understand it and straight away plug-it in your .NET application 100% free of cost.

The workings of this library is simplicity itself. There are just two classes – ftper class that acts as an interface to this library. It exposes public methods like connect(), disconnect(), browse(), addFilesToDownloadQueue(), etc. Here are some implementation details:

public bool isProcessing()
{
    return _threadRunning; //check if a thread is running for up/download
}

public List<ftpinfo> connect(string host, string username, string password)
{
    return ftpobject.connect(host,username,password);
}

public void disconnect()
{
    if (_threadRunning)
    {
        _threadRunning=false;
    }

    int timeout=60; //seconds
    DateTime start=DateTime.Now;
    while(queue.Count==0) //wait till running up/download threads complete.
    {
        if (DateTime.Now.Subtract(start).Seconds>timeout)
            break;
    }
}

public List<ftpinfo> browse(string path)
{
    return ftpobject.browse(path);
}

The second class, ftp is the core class which does the actual ftp stuff by connecting to the remote-host and transferring files. It is the underlying class for ftpobject in the above code.  It also exposes some events like uploadComplete and downloadComplete that our client can subscribe to, so that he/she can get notified of these events.


internal ftp() //hide constructor from the outside world.
{
context = SynchronizationContext.Current;
}

//tests connection and browse to home-directory
 public List<ftpinfo> connect(string host,string username,string password)
 {
 this._username=username;
 this._password=password;

//FtpWebRequest.Create(host); //test connect;
 context = SynchronizationContext.Current;

return browse(host);
 }

//public bool exists(string remotefilename)
 //{
 //    return true;
 //}

/// <summary>
 /// Fetch all files/folders in this directory and return the ftpinfo array.
 /// </summary>
 public List<ftpinfo> browse(string path) //eg: "ftp.xyz.org", "ftp.xyz.org/ftproot/etc"
 {
 FtpWebRequest request=(FtpWebRequest)FtpWebRequest.Create(path);
 request.Method=WebRequestMethods.Ftp.ListDirectoryDetails;
 List<ftpinfo> files=new List<ftpinfo>();

//request.Proxy = System.Net.WebProxy.GetDefaultProxy();
 //request.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
 request.Credentials = new NetworkCredential(_username, _password);
 Stream rs=(Stream)request.GetResponse().GetResponseStream();

OnStatusChange("CONNECTED: " + path, 0, 0);

StreamReader sr = new StreamReader(rs);
 string strList = sr.ReadToEnd();
 string[] lines=null;

if (strList.Contains("\r\n"))
 {
 lines=strList.Split(new string[] {"\r\n"},StringSplitOptions.None);
 }
 else if (strList.Contains("\n"))
 {
 lines=strList.Split(new string[] {"\n"},StringSplitOptions.None);
 }

//now decode this string array

if (lines==null || lines.Length == 0)
 return null;

foreach(string line in lines)
 {
 if (line.Length==0)
 continue;
 //parse line
 Match m= GetMatchingRegex(line);
 if (m==null) {
 //failed
 throw new ApplicationException("Unable to parse line: " + line);
 }

ftpinfo item=new ftpinfo();
 item.filename = m.Groups["name"].Value.Trim('\r');
 item.path = path;
 item.size = Convert.ToInt64(m.Groups["size"].Value);
 item.permission = m.Groups["permission"].Value;
 string _dir = m.Groups["dir"].Value;
 if(_dir.Length>0  && _dir != "-")
 {
 item.fileType = directoryEntryTypes.directory;
 }
 else
 {
 item.fileType = directoryEntryTypes.file;
 }

try
 {
 item.fileDateTime = DateTime.Parse(m.Groups["timestamp"].Value);
 }
 catch
 {
 item.fileDateTime = DateTime.MinValue; //null;
 }

files.Add(item);
 }

return files;
 }

The reason I’ve kept the constructor method ftp() internal is that we don’t want our client creating these objects as they form the core ftp functionality that only our library is supposed to use. By using the keyword “internal”, C# compiler understands that we don’t want this consturctor to be visible outside our assembly.

List of development tools for Linux platform – IDEs, Compilers, etc.

One of my most recent endeavours was to set up my old linux machine for development. I chose the Debian Squeeze(6.1.5) distro because of its reputation for stability and also its minimalistic approach towards installing packages, and both these features were quite welcome. Having said that, the tools listed here can be downloaded and installed on any distro, in case they are not already included in the installation CD/DVD. Based on my development experience with these tools, this list is frequently updated with new information:

1. GCC (GNU Compiler Collection): The GCC toolchain is considered a sin-qua-non of any linux developer’s toolbox. In fact, the linux kernel itself relies on several libraries provided as part of GCC. The debian squeeze 6.1.5 includes GCC 4.4 which is pretty stable. I’ve compiled several programs in C/C++ without any issues. You can choose to install specific packages such as gcc4.4 for C, or g++4.4 for the C++ language.

Only issue is that you should not install the OpenJDK package (gcj) of the GNU collection. The reason being that it will clash with the Sun/Oracle Java version which is very much preferred if you are into Android development or use other Java features such as Swing or AWT.

GCC is one of your core tools. Whether you use Eclipse or Netbeans to code your C/C++ programs, whether you use the QTcreator or Glade for designing interfaces, GCC is one good toolchain that most IDEs rely on to build your application.

2. Java/Netbeans: You can download all the java editions for linux including Java ME/EE, documentation & samples and also the Netbeans package from here. I specifically chose the combined Netbeans+JDK7.5 to avoid getting Netbeans separately.

3. MonoDevelop: One of the most important tools that allows me to leverage my Microsoft VB.NET/C# skills on linux is the MonoDevelop IDE. Except for Microsoft proprietary classes such as System.Windows.Forms, all your .NET code is 100% portable to linux through the Mono platform. The only support that MonoDevelop lacks as of now is the ability to design ASP.NET web pages. I believe this limitation is going to be overcome pretty soon.

4. Eclipse: Eclipse was essential for me as I wanted to develop Android apps too which is easier using the Eclipse IDE. The debian squeeze CD comes with version 3.5.2 of eclipse package, whereas I wanted to try the latest Juno version, so I got it from the eclipse site. However, the eclipse SDK for linux is a tar package and not an installer package. This means you have to extract this tar separately in a folder and use eclipse from there. If you do so, ensure that the ..JDK/bin is set in your $PATH variable, so that you can invoke java from the command line. If not, then add it by editing the .profile file in your home directory (/home/xyz, etc..).

5. Android Suite: The android developer site contains complete information about how to download and install the android sdk, along with the system images for the particular android platforms for which you wish to develop. Just keep in mind that android needs the Sun/Oracle java sdk and not the OpenJDK provided by GNU to write android programs.

6. Glade: Glade is an excellent RAD tool to rapidly develop professional-looking user interfaces for your applications. Glade is based on the Gtk+ toolkit that forms the core of the GNOME desktop. Glade basically generates an xml file (similar to the XAML generated in visual-studio) that can be used in many languages such as  C, C++ and Java. However, since the Gtk+ framework is built in C, it is advisable to build your GNOME applications in C for performance benefits. Glade can also be integrated with Anjuta, a full fledged IDE to develop GNOME applications that includes full toolchain integration and debugging support.

7. QTcreator: Based on the extensive QT framework, QTcreator is to KDE desktop what Glade is to GNOME. However, don’t feel crippled because of this as everything is “mix-and-match-able” in the linux world. QT apps can run on GNOME, as do Gtk+ apps run on KDE desktop. Since QT framework is written in C++, the language is well suited to write QT apps. Qtcreator can also be integrated with KDevelop, the equivalent of Anjuta IDE on KDE.

Solution for issues with Intel 845g graphic cards on Linux

Recently, I installed Debian Squeeze (6.0.5) on my old Zenith machine with a bit modest specs (384 MB RAM & 40GB HDD). It also had an Intel Extreme graphics 82845g for a video card.

While using the system I faced one major annoyance that in retrospect, was traced to my video card. My machine used to suddenly hang at random intervals.  When I switched to tty1 by pressing ctrl+alt+F1, I saw something like this:

X.Org X Server 1.7.7
Release Date: 2010-05-04
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.32-5-amd64 i686 Debian
Current Operating System: Linux workstation1 2.6.32-5-686 #1 SMP Sun May 6 04:01:19........
Kernel Command Line....
...
...
..
FATAL: Module fbcon not found.
SELinux: Disabled on system, not enabling in X server
(EE) Intel(0): Detected a hung GPU, disabling acceleration.

After a bit of googling, I found out that this behaviour was quite usual for most Intel cards in the i8xx series that included my card too. Turns out that Intel has not released the complete specs for this card that are needed to develop an open-source driver. As a result of this, all Windows machines will run in full acceleration with Intel’s proprietary drivers, whereas the Linux folk have to find an alternative or suffer these hangs/crashes. You can find the notes from the developer of Xorg’s driver here.

If you are facing this same problem, there are two workarounds available. I’ve tested these on debian squeeze and they both worked for me. Hopefully one of them should work for you.

Workaround [1]: Use the generic vesa driver instead of the intel driver. You may not get the cutting-edge graphics on your screen, but you will get a more robust machine. If you choose to do this step, you will also have to disable kms (kernel mode setting) as vesa does not support it. If you decide to go for this step, here is how you go about doing it:

1. First locate your /etc/X11/xorg.conf file and open in your text editor. You can find your driver configuration in the device section somewhere like:

….

Driver      “intel”
VendorName  “Intel Corporation”
BoardName   “82845G/GL[Brookdale-G]/GE Chipset Integrated Graphics Device”
BusID       “PCI:0:2:0”

…..

If there is no xorg.conf file in /etc/X11 folder, then you will have to generate one. To do this, log-in as root on command prompt and perform these steps (make sure that no x-session is running on a terminal when you do this):

I.) Xorg -configure               (this will generate the xorg.conf file)

II.) mv /root/xorg.new.conf /etc/X11/xorg.conf

2. Now that you have located the driver section, you can change it by simply replacing “intel” with “vesa”. To do this change, again you have to login as root on the command prompt. You can use your default console editor such as vi or nano for this.

3. The last step is to disable kms (kernel mode setting) for the vesa driver. To do this edit the file /etc/modprobe.d/i915-kms.conf and replace modeset=1 with modeset=0.

4. Reboot your machine and test the new display.

Workaround [2]: This alternative workaround is also available if you are intent on using the intel driver instead of the vesa one. However, the stability is not as much guaranteed as the vesa solution, and you might have to do some experimenting. To do this, just edit the /etc/X11/xorg.conf while logging as a root on the command prompt (If the xorg.conf file does not exist, see how to generate it in Workaround-1). Uncomment some driver options in your device section and set those values as follows:

Section “Device”
### Available Driver options are:-
### Values: <i>: integer, <f>: float, <bool>: “True”/”False”,
### <string>: “String”, <freq>: “<f> Hz/kHz/MHz”
### [arg]: arg optional
        Option     “AccelMethod” “uxa”           # [<str>]
        Option     “DRI”        “false”            # [<bool>]
#Option     “ColorKey”               # <i>
#Option     “VideoKey”               # <i>
#Option     “FallbackDebug”          # [<bool>]
        Option     “Tiling” “false”                 # [<bool>]
        Option     “Shadow”     “true”                # [<bool>]
#Option     “SwapbuffersWait”        # [<bool>]
#Option     “XvMC”                   # [<bool>]
#Option     “XvPreferOverlay”        # [<bool>]
#Option     “DebugFlushBatches”      # [<bool>]
#Option     “DebugFlushCaches”       # [<bool>]
#Option     “DebugWait”              # [<bool>]
    Option    “MigrationHeuristic” “greedy”
Identifier  “Card0”
Driver      “intel”
VendorName  “Intel Corporation”
BoardName   “82845G/GL[Brookdale-G]/GE Chipset Integrated Graphics Device”
BusID       “PCI:0:2:0”
EndSection

Reboot your machine after saving xorg.conf. The bold options above are those that worked for me. Just remember that setting Shadow to true and DRI to false will work in most cases, so just try setting those two options first.

EDIT: As of today (18-07-2012), it seems that the issue is permanently resolved in the next debian release (testing/wheezy).  I installed the backports packages for xorg and the newer kernel version (3.2) and the issue resolved even with the default xorg.conf configuration.