2008-02-15

BASH scripts on Mac OS X

I learned today how to use a BASH script on Mac OS X.

Just create a text file and put #!/bin/bash on the first line, and then write the rest of your BASH script and save.

Then make the file executable by opening Terminal and running
chmod +x scriptname.sh

Then you should be able to run it from the Terminal command line.

To make it so you can run the script by just double clicking on it in Finder, just change the extension of the script file to be .command

See Introduction to Open Source Scripting on Mac OS X

2008-02-05

Proper Mapping of Modifer Keys for Synergy with Windows Server and Mac Client

Synergy is a great program that allows you to use one keyboard and mouse to drive a number of computers whose monitors are next to each other. See http://synergy2.sourceforge.net/. I have it set up so that my keyboard and mouse connected to my Windows box can be used on my Mac mini whose monitor is to the right of my Windows box monitors. When I move the mouse off the right edge of my Windows monitor it magically shows up on my Mac mini monitor, and if I then use the keyboard it magically sends to the Mac mini instead of the Windows box its physically connected to. I can also block and copy text between the two systems. At free its a heck of a lot cheaper than a KVM switch, and since switching between computers is as easy as moving the cursor from one monitor to the other, its a lot more convenient than hitting a switch to move.

In any event, the real purpose of this post is to show how to correctly map the modifier keys (Ctrl, Alt, Windows etc) when your Synergy Server is on a Windows box and your client is a Mac. By default, for me, the Alt key on my keyboard was acting like Command on my Mac. Here is how to get the Windows key on a keyboard connected to a Windows box to map to the Command key on a Mac.

Start up Synergy on the Windows box.
Click on the Configure button next to Screens & Links.
In the Screens box click on the name of your Mac, and then click the Edit button below the screens box.
In the Modifiers area assign Alt to Super and Super to Alt.
Click OK, exit Synergy, restart your Synergy server and it should work.

2008-02-04

Using Mac OS X Leopard Preview to Manipulate PDF Files

Update 2011-01-09: I finally got around to installing Snow Leopard on my main Macbook and discovered that Preview handles this stuff a little differently.  The instructions have been updated for Snow Leopard 

I do all my filing paperless, so I am in the habit of scanning batches of snail mail as a single PDF and then breaking out and saving pages as separate PDFs for filing, and sometimes combining multiple PDFs into a single PDF. In Windows I had always used Adobe Acrobat Professional to do this, but my personal Mac mini challenge was to replicate all the functionality I have in Windows in Max OS X Leopard.

I didn't see an obvious tool for this built-in to Leopard, so I spent a lot of time downloading and trying out various freeware applications (mostly Java based) for breaking apart and merging PDFs, but they are were all pretty awkward to work with. Then I decided to take a hard look at Preview to see if I could get it to do what I wanted. Here is what I found:

To extract a single pages of a PDF in Snow Leopard Preview:
1. Highlight the page(s) you want in the Sidebar and hit Command-C to copy to the clipboard (For some reason you can't seem to do this with multiple pages).
2. Then go File -> New from Clipboard (or just Command-N). A new Preview window opens up with just the single pages you copied.
3. Then do File -> Save As or Shift-Command-S to save the new PDF.
4. You can also drag the selected pages to the Desktop and it will create a new PDF of those pages.

To extract multiple pages of a PDF in Preview:
1. Extract a single page as outlined above.
2. Open your new single page PDF in Preview next to your already open source PDF.
3. Select all of the pages you want to extract in the Sidebar of your source PDF, and then drag and drop and drop them where you want them to go in the Sidebar of your target PDF. They show up in your target PDF where you dropped them.
4. Save your target PDF using File -> Save As or Shift-Command-S.

To combine multiple PDFs in Preview:
1. Open one PDF in Preview.
2. Drag the PDF file you want to add from Finder onto the Sidebar of the PDF you have open in Preview and drop it directly on top of the existing page (if it is a single page) or directly on top of the page with the binder showing (if the existing PDF is multiple pages).  In Snow Leopard, if you just drop the file on the sidebar it doesn't combine the PDFs by default; you have to drop directly onto a page.