Add Keyboard Shortcuts To Ubuntu

This article will show you how to add keyboard shortcuts to your Ubuntu desktop. A keyboard shortcut can improve your total desktop experience by assigning a keyboard shortcut to applications that you run frequently. This will cut down on navigation time and will launch a program with just a keystroke or two.

In my case, I decided to add the screen rotation app called Xrandr to the list of keyboard shortcuts that’s already available in Ubuntu. Previously, I talked how to add icons to the Gnome panel. I’m taking this one step further, by adding several custom keystrokes.

To customize a keystroke, we need to open System > Preferences > Keyboard Shortcuts. Click Add. Type the name of the application. In my case, I called it Rotate Left. The command is xrandr -o left. Click Apply. You can then assign a keyboard shortcut by highlighting the entry and typing in the keyboard shortcut.

If you’re not familiar with the actual command, you can take a look at System > Preferences > Main Menu. Find the application that you want and right-click to Properties. Copy and paste the command line entry, and paste it to your keyboard shortcut.

The only thing you want to make sure is, that there are no conflicts with the existing keyboard shortcuts. There are already several Functions keys that are already assigned by default. For example, F1 is normally Help, F3 is Search, F5 is Refresh and F11 is Full Screen mode. So, just keep that in mind.

Create Xrandr Shortcuts

If you have a monitor that swivels to portrait or landscape mode, you can easily create shortcuts in Ubuntu that makes rotating screens via the Xrandr utility that more easier.

With a couple of application shortcuts on the Gnome Panel (see above), changing monitor orientation is literally just a mouse click away. The application icons: the left and right arrows indicate the direction of the rotation. You can find these icons under the directory below in Ubuntu.


My Ubuntu desktop is a bit unusual since I’m still using Gnome 2 and Ubuntu 10.04. You can add application launchers on other windows managers as well, whether it’s Unity, Cinnamon, Gnome or KDE, it doesn’t really matter which one do you use. Just use the following Xrandr commands below.

To default: xrandr -o normal
To rotate left: xrandr -o left
To rotate right: xrandr -o right
To rotate upside down: xrandr -o inverted

The application launchers I created just happen to be on my Gnome Panel. It makes changing my monitor orientation that much easier. I wished I did this a long time ago.

XRANDR Comes to the Rescue

What could be more frustrating than trying to install Ubuntu or Mint on a new CPU, motherboard, with a built-in graphics card and your display goes south. Here’s the scenario, after the initial flash screens, the screen goes blank. It seems that Xorg is using a screen resolution your monitor does not support.

Why is that? So frustrating. So, my older 19 inch Samsung monitor comes to the rescue. It seems to cope better than my 22 inch HPw220h monitor. The initial screen seems to be twice as big as the monitor supports, hence it doesn’t display properly on certain monitors.

There is one trick, well, a fix to make things all right again. XRANDR comes to the rescue. You will need to perform the following to get your Xorg displaying properly.

  • Hit Ctrl-Alt-F1. This will take you to the terminal screen.
  • Type in XRANDR -s 1024×768. This resets the screen a certain size.
  • Hit Ctrl-Alt-F7. This will take you back to XORG.

You can then make the Xorg changes and make it stick. Once I regained my screen, I was able to reconfigure Xorg to the resolution I wanted, 1680×1050 on my HP monitor.

To make my changes stick, I selected Preferences>Display. Say NO when prompted. Logout and Login.

The new Xorg configuration is now set.

Ubuntu 1050×1680 Portrait Mode

About a month ago, I had a little computer glitch. I ended up reinstalling Windows XP, but I ran into some more problems when Windows updates began to trickle in. I just couldn’t get past Windows Authentication since I didn’t have a valid license.

I was literally stuck with Windows XP SP1. There were some programs that refuse to install unless I had SP2. So much for that idea.

Then, Solaris came out a few weeks ago, I tried to install it by overwriting my Ubuntu partition. The Solaris installation was smooth. There were no issues. However, running it is another story.

There were two major problems:

  1. Xorg wasn’t working quite well. I was only seeing 3/4 of the screen. I tried rebooting. I also  reconfigured Xorg. It worked for the lower resolutions, but not the 1680×1050 widescreen my monitor supported. So, I gave up Solaris and went back to Ubuntu.
  2. I learned after the install of Ubuntu that the MBR (Master Boot Record) aka PBR was destroyed. I could no longer boot to Windows or Ubuntu. Nice job, Solaris.

I wiped out the entire disk and removed the two partitions. I installed Ubuntu as the only OS on my computer. C’est la vie, Windows.

The only thing I missed in Windows is viewing in portrait mode which is great for browsing websites and documents, while landscape mode is perfect for viewing spreadsheets.

So, did I get portrait mode working in Ubuntu?

I had an old ATI graphics card which I learned later that it had issues with rotating views. I ended up buying an older Nvidia FX-5200 from Ebay for a fairly good price.

So, here’s my setup.

  • Monitor: HP w2207h 1680×1050 60 Hz
  • Video Card: Nvidia GeForce FX-5200
  • Ubuntu Hardy Heron 8.04.

I set the device section of my Xorg.conf to:

Section "Screen"
 Identifier "Default Screen"
 DefaultDepth 24
Section "Module"
 Load	"glx"
Section "Device"
 Identifier "Default Device"
 Driver	"nvidia"
 Option	"NoLogo" "True"
 Option "RandRRotation"


To view in portrait mode, just go to Systems – Preferences – Screen Resolution – Monitor Resolution Settings and choose either Normal or Left rotation.

Landscape Mode (Normal) Setting: 1680×1050 pixels.

Portrait Mode (Rotated Left) Setting: 1050×1680 pixels.

So, this is how I setup my Ubuntu in Portrait mode with my HP w2207h monitor and my Nvidia FX-5200 video card. I will note however, that are currently issues with running Xrandr with Compiz at the same. Unfortunately, you can’t have both. Other than, I’m a happy camper.