2008-03-13

local copy/paste on the Touch with iCopy

First off, I'd like to excoriate Apple for their egregious omission of copy/paste functionality on the iPhone and iPod Touch. Yes, you heard that right - there is no way to copy and paste text on the Touch or iPhone, though we assume it's coming in OS update 2.0 in June. That say, there are some kludgey solutions available. Here's one:



Preston Monroe has released iCopy, a Safari bookmarklet that will copy text from a web page and paste it into another web page. (Actually, he uses an intervening step so the process is actually copy, paste, paste). That's a good start, but what if you want to copy text from a file on your Touch to a website, or vice-versa? Well, I've written a solution for that: localCopyPaste, available from my .Mac public folder as localCopyPaste.zip.

Here's how to install and use it. I'll assume you have some basic command-line skills, so please don't write me asking how to change directories or open a Terminal session. If that's beyond you, you'll probably find the installation and usage to be too inconvenient anyway. With that said, here goes.

Installation:
  1. Install Cydia, AFP, TextEdit from Installer.App
  2. Install Python, wget, OpenSSH, Terminal (Term-vt100) from Cydia.
  3. Optionally install 1.1.3/4 Safari patch to allow you to open files on your Touch using Safari.
  4. On your desktop, install Putty (for Windows). If using a Mac or Linux, you already have ssh. Connect to your Touch (or iPhone) after determining its IP address (check Setting > Wireless > name of network you're connected to). Let's assume it's 192.168.0.94. To connect, type "ssh -l root 192.168.0.94", then log in with the appropriate password (default is 'alpine').
  5. Switch to your Documents folder: "cd /User/Media/Documents" (or any other preferred location).
  6. Install the web.py web application framework: "easy_install web.py". This should fetch it from python.org and install it.
  7. Now unzip localCopyPaste.zip on your desktop and copy over to your Touch's /User/Media/Documents folder. On the Mac, you can use Finder to do this, after using 'Connect to Server' and specifying 'afp://192.168.0.94' as the desired location; or, you can use Fugu and its built-in SCP tool. On Windows, use the excellent WinSCP application for this.
  8. Go back to your SSH client and make the copypaste.sh and killcopypaste.sh files executable with "chmod 0755 *.sh"
  9. Now you will start a local webserver on port 8080 serving up a special page so that iCopy can copy from it or paste to it: in your SSH window, type "./copypaste.sh". If all goes well, after a second or two you should see "running with PID 21644" (or some other process number). Then you will see a second line "http://0.0.0.0:8080/" which indicates that the webserver is accepting local connections on port 8080. Press Enter to get your command prompt back. You can now close your SSH window and break the connection between the desktop and the Touch. If you get an error spew ending with "socket.error: socket already in use", this means that you have tried to start a second copy of the webserver, or another webserver is running on that port.
  10. If you want to stop the local webserver later, either open another SSH connection to the Touch, or open a local Terminal session on the Touch, and go back to the installation directory. Type "./killcopypaste.sh".

Usage:
  1. Put the text you want to copy into a local file in /User/Media/Documents. By default, the local copy websersver will look for a file called copy.txt in this folder. Similarly, the webserver will place pasted text into a file called paste.txt in this folder.
  2. Now use iCopy to copy text from a website to your Touch (by default, into paste.txt), or to copy text from copy.txt on your Touch and then paste it to some remote website. Remember that iCopy requires you to Copy - Paste - Paste.
Good luck! Comment, suggestions?

Update:

I did all my testing on my Touch while it was connected to my desktop PC or Mac via SSH. And I started my web application through that SSH connection. I've discovered that as soon as I break the SSH connection, the web application stops. That's no good! One solution is to start and stop the app through the BossPrefs utility, as it's used for a number of other server services. I'm still working on that and should have something in a few days.

2008-03-10

Using the iPod Touch as a PDA

Maybe this has been kicked around already, but I'm late to the party, or inattentive. Then too, I didn't actually own an iPod Touch until last week (it arrived the very day Apple released the SDK), so I'm only finding out some of this stuff now.

I'm all about handheld functionality, having been a PDA user since 1992 (Sharp PC-3100) and a Palm user since 1996 (I bought one instead of a Newton because it was way cheaper). In recent years I went through a collection of Palm devices ending in the TX, but gave up on Palm when it became clear the company and the platform are moribund. I have a Windows Mobile device at work, but the user interface is so awkward it hurts me to use it; and then there's ActiveStync, the most off-putting utility you could ever want to use.

So, I've been looking with interest (from afar) for the past year at the Apple iPhone, which has shown great promise since its introduction. Since I'm in Canada, I don't have access to it (except by buying one in the US and unlocking it, which leaves me at risk with each new update). Recently I learned that Rogers won't be selling them until at least the rumoured 3G iPhone is released later this year, so I broke down and bought a refurbished 8G Touch from Apple's store. I was surprised and pleased to learn that it had the latest software update (1.1.4) and new apps (e.g. Calendar) even though the store listing said "original software" instead of "new version software".

After a few days with the unit, I have some comments about it as a PDA.
  1. jailbreaking is easier than ever. Just go to ziphone.org and download an app, run it (after shutting down iTunes and iTunes Helper) and in about 3 minutes you'll have Installer.app on your Touch (or iPhone) and be able to load on 3rd-party apps. Or you could wait for Apple's 2.0 software to be released in June, I guess. Note: jailbreaking is the not the same as unlocking: the latter only applies to iPhones and is intended to allow you to use a cellular provider than AT&T, while the former merely allows you to add functionality to your device.

  2. First off, while I have 8GB for music, videos, podcasts, by default you only have 300 MB for applications. And of that, much is taken up already by the operating system. I found that after loading on only a few apps, I got a "low disk space warning" when I tried to install the Python programming language. The solution is to make your first install the handy BossUtil app, which allows you to move stuff from the apps partition to the media partition (while also creating a symbolic link so the operating system doesn't notice they've moved). I moved my fonts (the recommended first choice) and that immediately freed up 100 MB! I then immediately synced my Touch so there'd be a backup of those fonts on my Mac. More on this backing up in a bit.

  3. I won't talk much about Safari except to say that it is (just like the ads say) the best mobile browser I've ever used. I mean, I've heard that over and over, but it wasn't until I used it for an hour that it sank in just how much better it is than anything else. A big part of that is the multi-touch screen which allows instantaneous, seamless, painless zooming in and out. Oh and, multiple tabs. One hint: if you are using Safari on your desktop you can go into your preferences and turn on bookmark sharing; it's also a feature in .Mac. This greatly simplifies getting your favourite sites onto your Touch/iPhone.

  4. Syncing: in order to use this thing as a PDA I need (at a minimum) to be able to sync my contacts, calendar events, to-dos and notes with my desktop. iTunes does this for contacts and calendars, and allows for fine-grained control of what gets synced. But, a few gotchas....

    • The Touch's Calendar doesn't know anything about categories. If you choose to sync multiple calendars to your device (say, yours and your spouse's), they'll all look like one Calendar on your device. I've requested an enhancement from Apple, but don't your breath. A kludgey workaround would be to preface each event in your desktop calendar with a specific word or character so it's recognizable on your device (say, "[Him]", "[Her]")
    • Get all your calendar categories set up before you start syncing with the Touch. If you sync once, then change your desktop iCal categories, the Touch will still keep the old calendar names in its database (I went looking into the sqlite calendar database to discover and correct this - not for the faint-hearted) and will get very confused. Some people have resorted to a Reset to get out of this situation, but I didn't want to re-jailbreak and re-install all my apps.

  5. Screen orientation. Safari switches automatically between portrait and landscape mode, but many other apps don't (yet?). I would really like to see a landscape view for the calendar so I could see a week at a time. Same thing for Mail.

  6. Todos: there are no ToDos on the Touch, except for those provided as part of Mail.app on the desktop. My solution is RememberTheMilk (free on the desktop but a commercial app on the Touch), but of course I need an internet connection to make that work. Kludgey off-line workaround: I installed the TextEdit app which allows me to note things.

  7. There's a Notes app on the Touch now, from Apple, but it doesn't sync with anything on the desktop (though you can mail your notes to anyone). Which brings me to the next point...

  8. Backup to desktop: when you sync the Touch, the first thing is says it's doing is "backing up to the desktop", but I don't know what exactly that entails or includes. Anyone know? I'm not sure I trust that process, so, I've got a few other options:
    • SSH - I installed the OpenSSH server, and it's sent to run all the time. I can connect to my Touch from my wireless desktop from a Terminal window with "ssh -l " . Check the Settings > Wireless on the Touch to find your IP address when connected via WiFi. (Before I could get SSH going, I had to repair the /etc/termcap file on the Touch in order to have it accept a connection from 'root', password 'alpine'; look for forum posts on this topic).
    • SCP - once the SSH server was installed, I could copy files to/from the device, and thus make a complete backup of all apps and settings, using the SCP (secure copy) functionality in the excellent Fugu app for the Mac. I'm sure there's something similar on Windows. This allows me to treat the Touch effectively as an external drive. BTW, Mac users can also install an AFP server on their Touch and then simply user Finder to browse to the device by using Connect to Server and then specifying "afp://ip-address-of-device" as the connection name.
    • iSpit - I also installed the iSpit micro-webserver on the Touch, which is designed for one purpose only - to share files from your Touch. I just open a web browser and go to http://<ip-address-of-Touch> and then click on links to take me down to the desired folder and the right-click on the desired file and Save As.

  9. Maps: not strictly a PIM functionality, but I'm impressed (and maybe a little creeped-out) as to how accurate the aGPS is (geo-location using WiFi information rather than satellites). I don't know how they do it, but at both my office and my residence I've found that GoogleMaps has located me within a two-block radius. Pretty handy to then do a Google search on "pizza" and then find out where I can walk to for dinner!

  10. Writing: With the Touch (and iPhone) you're limited to the on-screen keyboard since even on the bluetooth-equipped iPhone the Bluetooth stack is crippled so you can't use a BT keyboard. Let's hope they fix that in version 2.0 of the software. So, how's the on-screen keyboard? After a couple of days my accuracy has already increased substantially (actually, even within the first hour), though pecking like a chicken is going to get old very quickly. There are couple of tips to work with the keyboard:

    • whenever possible, do input in landscape orientation, since each key will be wider. I've found that in Safari this makes a substantial difference to my speed and accuracy. Too bad Mail doesn't run in landscape mode (unless somehow jailbreaking took away that feature).
    • if you make a mistake, you can zoom in to the exact spot where the correction is needed (if it's not at the cursor location) by press-and-hold, which bring up a small magnifying glass; you can then slide your finger to move the cursor to the exact insertion point.
    • turn off auto-complete in the General settings. I found its usage to be confusing and it just kept doing the wrong completion for me. The tool is basically useless at this point. TextPlus on PalmOS or WinMo is way better.
    • and this isn't a keyboard tip exactly, but you should note that the Touch and iPhone have no Cut and Paste capability! WTF were they thinking? This is so basic a need that I'm surprised they haven't fixed it yet. I'm guessing that the 2.0 software will address that. If it doesn't, some resource developer will.

  11. Integration with Exchange: the other bombshell at last week's Apple event was the announcement of full Exchange support for the iPhone. That should address all PIM functionality requirements, but at the expense of using ActiveStync. Yes Martha, there will be AS on the iPhone. But not on my device. AS was the reason I left Windows Mobile, and it's easily the worst piece of #$%^& ever created by Microsoft. I can't begin to count the hours wasted on that sorry excuse for a sync tool. They should have licensed Hotsync from Palm, the most reliable PDA sync tool I have used. Oh and Apple developers, please check the discussion forums on your own website - lots of people are having problems syncing their Touches through iTunes.

With the release of the SDK beta version, the floodgates have been opened, and soon we'll be seeing a plethora of mobile versions of well-known desktop apps. By the time that Apple's App Store opens in June, there should be hundreds of apps for the device. This is truly a renaissance moment in the mobile world.

My only question now is whether Apple will build on the iPhone's and Touch'e success: will a 7" Apple MID be next on the horizon?

Bluetooth on your iPod Touch

What? Your iPod Touch doesn't have Bluetooth? Why, that's a shame. Didn't you hear about the new refresh of the model in early January? It was going to be a "Just One More Thing" item in Steve's presentation but it got chopped for lack of time. Anyway, I got mine soon after and was delighted to see it had this new feature. Now I'm using external bluetooth headphones, external keyboard for text input, getting internet by tethering to my Bluetooth-equipped phone, and the best part - external bluetooth GPS for navigation!

Well, those would be sure nice features for everyone to have, and we can sure hope that Apple introduces them in the next upgrade. In the meantime, we Touch users can install the Bluetooth app on our jailbroken units and experience a tiny little frisson of excitement every time we see that icon.

Put your owner info on your iPhone / Touch home screen

One of the useful features of my old Palm PDA was the Owner Info icon. The idea was that if someone picked up your mislaid PDA and turned it on, she might see and tap on the Owner icon and then know:
- who the owner was and how to reach him
- what reward, if any, was being offered
Sure, you can just paste a sticker on the back of your device with your info on it, but after a few weeks it'll be illegible. Having the information on the device itself, on the main screen, is a more reliable way of ensuring that it's there when it's needed.

Since moving to an iPod Touch as my new PDA, I've missed this simple feature, but found a workaround for it. Here's how to do it:


  1. First off, jailbreak your iPhone or Touch (or wait for software update 2.0 in June). If you want to jailbreak, just visit ziphone.org and download the handy utility. The Windows version crashed on me, but the Mac version succeeded in about 3 minutes. This process will put Installer.app on your device.
  2. Open Installer.app and look for the 1.1.4 Safari Patch. This will allow Safari to open files on your device using a file:// type of URL.
  3. While you're at it, install the OpenSSH server, which will allow you secure access to your device. Note that you may need to apply a fix (via the method below) to your /etc/termcap file in order to be able to log in via SSH (at least, this fix is required for opening a local Terminal window).
  4. Next, connect your device to your local wireless network, and note the IP address it is assigned (e.g. 192.168.0.77). On your Mac, you can then connect to your device using "afp://192.168.0.77" for direct Finder access, or use Fugu. On a Windows PC, grab a copy of WinSCP and connect to that same IP address.
  5. Now open a text editor on your PC and copy the file below, editing as required to meet your needs. I included a picture of me sized around 150x150 pixels: seeing the owner's picture may encourage the finder to return the device, I figure. Save this file as owner.html.
  6. Now copy the owner.html and the picture file, if any, to your device. I put them in /User/Media/Documents.
  7. Open Safari and browse to "file:///User/Media/Documents/owner.html". Adjust the page zoom until your message fills the screen. You may need to edit your source document several times to get it right, copying the latest version each time over to your device and then hitting Reload in Safari to see your changes.
  8. When it all looks nice, hit the + icon at the bottom of the screen and select "Add to Home Screen"; an icon of the owner.html page will be placed on the home screen with the caption "Owner Info" underneath it.

I'm leaving as an exercise for the reader to create a little application that will do all of this for you right on your device!

Contents of owner.html (edit to suit your taste):

<html>
<head><title>Owner Info</title>
</head>
<body><h1>Hello!</h1>
<p>
<table width="100%" border="0">
<tr><td width="150"><img src="./Avatar147x160.jpg" width="140" height="160"></td>
<td>Please return to:<br>
Owner name<br>
Owner email address<br>
Owner phone number<br>
City, Country</td></tr></table>
<p><span><font size="+1">
Thank you for finding my _device-model_.<br>
I've spent a lot of time setting it up<br>
to my liking, and will gladly offer a<br>
reward for its safe return.<br>
Thank you!</font></span></p>
</body>
</html>