Fixing font smoothing on OSX

While I was experimenting with themes in GNU Emacs for OSX, the font smoothing somehow got messed up for the entire OS. A quick Google search didn’t exactly yield a helpful answer, as they just directed me to the System Preferences, in the “General” section, and told me to make sure that the “LCD font smoothing” box was checked. This didn’t help me because it was already checked, and toggling it didn’t actually make a difference.

What actually ended up fixing it for me was to set font smoothing at the command line. Open up a terminal, and type the following to see if the value is currently set:

defaults -currentHost read -globalDomain AppleFontSmoothing

This command will show the current value, or alert you if there is no value currently set. If you want to delete the value (thereby restoring the default), do the following:

defaults -currentHost delete -globalDomain AppleFontSmoothing

You can set the value with the following command, replacing with level of smoothing:

defaults -currentHost write -globalDomain AppleFontSmoothing -int <value>

0 – No smoothing
1 – Light smoothing
2 – Medium smoothing
3 – Strong smoothing

Deleting all partitions on a USB drive using fdisk

Due to my rampant experimentation with many different Linux distros, I often times have to wipe a USB drive completely after making it a bootable live USB for something like OpenSUSE. If you used the Imagewriter.exe program used to create the drive, you’ll have a hard time later on if you try to use uNetBootin to make a live USB for a different distro. You can use bootice.exe in Windows to restore the drive. Here’s how to do it with fdisk in Linux (courtesy of PenDriveLinux.com)Restoring your USB key to it’s original state using Linux:

First we need to delete the old partitions that remain on the USB key.

  1. Open a terminal and type sudo su
  2. Type fdisk -l and note your USB drive letter.
  3. Type fdisk /dev/sdx (replacing x with your drive letter)
  4. Type d to proceed to delete a partition
  5. Type 1 to select the 1st partition and press enter
  6. Type d to proceed to delete another partition (fdisk should automatically select the second partition)

Next we need to create the new partition.

  1. Type n to make a new partition
  2. Type p to make this partition primary and press enter
  3. Type 1 to make this the first partition and then press enter
  4. Press enter to accept the default first cylinder
  5. Press enter again to accept the default last cylinder
  6. Type w to write the new partition information to the USB key
  7. Type umount /dev/sdx (replacing x with your drive letter)

The last step is to create the fat filesystem.

  1. Type mkfs.vfat -F 32 /dev/sdx1 (replacing x with your USB key drive letter)

That’s it, you should now have a restored USB key with a single fat 32 partition that can be read from any computer.

Finally solved: Touchpad x/y sensitivity differs with screen aspect ratio!

For the longest time, one of my biggest gripes about Linux in general is that my Synaptics touchpad was more sensitive in the x direction than the y direction. I figured that this was due to having a 16:9 laptop screen, and assumed that the driver scaled to screen aspect ratio by default. This was confirmed when I plugged in an external monitor, and (when the monitors were arranged side-by-side), the cumulative x-dimension was used to calculate the touchpad aspect ratio. This resulted in a much higher sensitivity in the horizontal direction than the vertical direction.

After finding zero helpful information on almost every website, I finally stumbled across a solution here (note that the first answer idiotically suggests that you check the mouse panel under system settings):

Solution for Ubuntu 11.04:
Add the options

Option "VertResolution" "75"
Option "HorizResolution" "75"

To the file /usr/share/X11/xorg.conf.d/50-synaptics.conf

After doing that, mine looks like:

Section "InputClass"
     Identifier "touchpad catchall"
     Driver "synaptics"
     MatchIsTouchpad "on"
     MatchDevicePath "/dev/input/event*"
     Option "VertResolution" "75"
     Option "HorizResolution" "75"
EndSection

Now log off and log back in, and it should be fine! 🙂

I’m running Linux Mint 11, and it works just fine for me.

Gnome 3 via PPA with Ubuntu 11.04

If you have Ubuntu 11.04, you can install Gnome 3 using the following commands from the terminal (thanks to AskUbuntu.com for the info):

sudo add-apt-repository ppa:gnome3-team/gnome3
sudo apt-get update
sudo apt-get dist-upgrade

Now, every time I’ve tried this, Gnome 3 is already installed after these 3 lines. However, AskUbuntu.com’s post lists a 4th line, which you can try if the above 3 don’t do the trick:

sudo apt-get install gnome-shell

Some other tweaks
Here are some things I had to do to get it working right on my laptop (Compaq Presario CQ-56 115DX w/ ATi Radeon Mobility 4200). I was getting graphical corruption when using the fglrx drivers, so in order to revert back to the open source drivers, I did this:

sudo apt-get remove fglrx
sudo rm -f /etc/X11/xorg.conf

Also, when I installed via PPA, the theme didn’t look right… Looked like something straight out of Windows 95. To fix things, I did the following:

Install Half-Left’s Gnome 3 Shell theme, “Elementary”:
http://half-left.deviantart.com/art/GNOME-Shell-Elementary-3-0-193232931

Install Half-Left’s “Adwaita Improved” window theme:
http://half-left.deviantart.com/art/GNOME-3-Adwaita-Improved-206172213

I also made some tweaks to the gnome-shell.css file that comes with the Elementary theme. I did that by typing the following into the terminal:

sudo gedit /usr/share/gnome-shell/theme/gnome-shell.css

I’m not a big fan of large or bold fonts for a UI, so I just set all bold fonts to normal font-weight, and set the sizes to 8pt.

Installing Flash Player 64-bit for Chrome in Linux

Download the 64-bit Linux version of the plugin. The version I used was here, in tar.gz format.

Next, extract the file into your home directory. It should extract one file, libflashplayer.so.

Finally, open a terminal, and type the following:

sudo mkdir /opt/google/chrome/plugins

then

sudo mv ~/libflashplayer.so /opt/google/chrome/plugins/

Restart Chrome, and type

about:plugins

into the address bar. You should see the flash player plugin you just installed!

Compiling GLUT in Linux

This is just a quick supplement to my post on OpenGL on OSX.

To get the same code running under Linux, I simply changed the includes to the following:

#include <GL/glut.h>
#include <GL/gl.h>

…and compiled the code using the following line in the terminal:

gcc glutTest.c -lGL -lGLU -lglut

(Note that I’m using gcc because I’m now compiling a .c file. If it were a .cpp file, I would use g++ instead)

UPDATE:
If you’re getting errors such as ” has incomplete type” or “invalid use of GLvoid”, simply replace all instances of GLvoid with just void, and it should work.

OpenGL on OSX with GLUT and G++

There’s no doubt that programming with an IDE saves you loads of time with convenience, and ease-of-use. As programmers, we don’t always have the luxury of having a program do all the nasty bits for us, so it’s always good to learn how to program in a text editor (Emacs is a great choice) and how to compile from the command line.

Personally, I like programming in an environment that doesn’t require a lot of overhead, gives me a large amount of control, and lets me see all the little details. I’m going to give a startup tutorial for programming OpenGL with GLUT on OSX (Version 10.5.7), and I’ll be using nothing but GNU Emacs, and g++ (which is an optional install on your OSX Install DVD). More after the jump.

Continue reading