rdesktop running inside X11

I've been using the Remote Desktop Connection for Mac from Microsoft to connect to my Windows machines on my Mac. I've used the open source client rdesktop on Linux machines in the past, but I figured since Microsoft provided a free client I might as well take advantage of every free thing I can get from the company that loves to charge for everything. But then I heard about how the performance of the Microsoft Remote Desktop client on the newer Intel Rosetta Macs was not that great, and that rdesktop worked much better.

So I installed rdesktop using MacPorts (sudo port install rdesktop) which installed rdesktop in /opts/local/bin/. Then I had to start X11 (I already installed X11 from my Mac OS X CD) and using the X11 terminal run rdesktop from the command line to connect to my Windows PC (running open-x11 /opt/local/bin/rdesktop my-server-ip from iTerm did not work). Obviously this was a lot of work to simply open a connection to my Windows server, so I searched for a simple workaround. I found one here. For sake of maintaining a consistent source of information, and because I modified some of the steps, I'll recreate the steps here:

1) Create ~/my-windows-pc.sh (important difference in this step is the addition of the -K option):


#!/bin/sh
/opt/local/bin/rdesktop -K -f -a 16 my-windows-pc-ip

2) Make the file executable:

chmod +x ~/my-windows-pc.sh

3) Apparently the default xinitrc settings get in the way when running rdesktop full screen, so lets place a copy in our home directory and make some changes to it:

cp /etc/X11/xinit/xinitrc ~/.xinitrc

Edit the file and remove the line that says xterm &

4) Finally, we can do some cool stuff. Lets create a single .app (Mac's application file) that can do all the work of opening X11 and running our my-windows-pc.sh script. Start by opening the Script Editor (Finder -> Applications -> Apple Script -> Script Editor). You should be presented with an Untitled script editor window (if not, choose File -> New). Type the following into the editor window:

do shell script "open-x11 ~/my-windows-pc.sh &"

Choose File -> Save As. Then change File Format to Application. Type a name to save your application (such as My Windows PC), select a place to save the application (such as your home directory or Desktop), and click Save. Now you should be able to double click on the My Windows PC file to open your Remote Desktop connection.

Full screen issues

The first major difference between this method and using Microsoft's Remote Desktop client was that I could not press Apple+H to hide the Remote Desktop connection window, and then Apple+Tab to switch back to it, while running Remote Desktop in full screen mode (the -f option in the rdesktop command). Also, in full screen mode the Apple+H shortcut doesn't work by default. The -K option (keep window manager key bindings) we added to the rdesktop command allows us to still use the Apple key to do things while we're connected to the Windows PC (including Apple+H), however it doesn't work the way it's supposed to! Another huge annoyance is that when running Remote Desktop in full screen mode, its not truly full screen because we still see the Apple Dock and the X11 bar across the top.

The way to fix these problems is by enabling full screen in X11 (X11 -> Preferences -> Output -> Enable the Enter Full Screen menu). Keep in mind, Alt+Apple+A switches between full screen and windowed mode in X11 (in full screen X11 mode, you can't see the X11 menu bar to get back into the Preferences without changing back into windowed mode!). Also, I can't remember, but I might have also checked the "Enable keyboard shortcuts under X11" option. Now, if you start your full screen Remote Desktop connection, it should really look full screen (nothing visible except your Windows PC).

Finally, it would be really nice to be able to switch between the Remote Desktop connection and applications running on the Mac. I currently use Witch as my application switcher, instead of the default application switcher that comes with the Mac (so I can't tell you if this issue applies if you're not using Witch (and if you're not, you should be!)).

To make the X11 application show up in the Witch list, choose System Preferences -> Witch -> Behavior. Then enable the "Show an Activate Item for windowless/hidden applications". Now when you're inside a full screen Remote Desktop connection, you can press Apple+H to hide the full screen window, and you should see an "Activate X11" option in your Witch list, which you can use to switch back to the full screen session. This method also works if you're using a windowed rdesktop session.

Write a Comment

Comment

  1. Thanks for this post – I thought the slowness with MS’s RDP client was with my old G4, rdesktop is SO much faster.

  2. You’re welcome Jim! I have a G4 laptop also, and I too thought Microsoft’s RDP client was only slow because it was a G4. It’s really amazing how much faster the open source client is!

  3. Thanks for this post. I am using Mac os x 10.7.2.
    In My Mac rdesktop command is not working..
    In 3 step is not working for me.its says “cp: /etc/X11/xinit/xinitrc: No such file or directory”.

    So Please Help me.

    Thanks,
    Kumaresan.