Monday, November 8, 2010

Not all colors are showing in gnome-terminal (and xterm)!?

This incidence happened to me on my office vnc session (on 64b CentOS, kernel Version 2.6.29.4). I was in a vnc session and I typed ls --colors=always. I was expecting the output to be colorized as per the values set by 'dircolors'. But to my surprise I saw that the output was not colorized! I googled on this issue and saw some suggestions in many of the linux forums. I kept on trying each one of these solutions below:
  • Setting TERM=xterm
  • Setting TERM=xterm-color
  • Setting force_use_color=yes
  • Changing (and playing with) the values for gnome color palette.
But, none of them gave back the colors! Frustrating!
However, to my surprise, on a ssh session on the same machine, I was able to get the colors displayed! So, this definitely seemed to be an issue with the vnc session. (Indeed it was :D). I then checked the command used to create this vnc session and it was created with '-depth 8' (8bpp, bits per pixel). Somehow, gnome-terminal (as well as xterm) do not display (multiple) colors when you are in an 8bpp vnc session. But you know, even in that situation (8bpp), 'konsole' was able to display the colors!

By now, you'd have figured out the solution ;).
Yes! the solution is to start a vnc session using the option '-depth 24' to the command 'vncserver'.

Happy coding!


PS: If you set the depth to be 24bpp, then the bandwidth consumption of vnc viewer would increase. A solution for that is to set your vnc viewer to work with lesser colors. EG: 'Low (64 colors)'.

No comments:

Post a Comment