Keep auto-timeout Transmit connections alive
I use a shared host which unfortunately, due to circumstances outside my control, terminates my Transmit FTP/SQL sessions after 15 minutes of idleness. Good for processor cycles, poor for my sanity, especially during intensive coding/research sessions. After gleaning the internet for a solution and finding none which worked, I decided to whip up my own. Copy and paste the following code into Script Editor, and save it as an application with the 'stay open' option checked:repeat tell application "Transmit" tell document 1 tell current session refresh list their stuff files end tell end tell end tell delay (60)end repeatIf anyone wants to follow up this with a touch of AppleScript that cycles through every connection, that would be great. This is my first AppleScript project, so woot for me!
published on Thursday, the 23. October 2008, macosxhints
Automatically reconnect iChat if connection drops
I've had the problem with my iChat Jabber connections (gtalk and yahoo.jabber.org.uk gateway) constantly crashing, causing an error dialog in iChat. Since the Chax add-on no longer seems to support automatically reconnecting to crashed connections in 10.5, I found this great idea for a crontab script to force a reconnection using AppleScript. However, the only problem is that this would start iChat even if it was not running. So I used this slightly extended script to make it check if iChat was running before executing the login command. I added this line to my crontab (via crontab -e or the Cronnix crontab editor) to make it re-run every minute using the command line: * * * * * osascript -e 'tell application "Sy...
published on Thursday, the 28. August 2008, macosxhints
Add an iPhone call log to iCal via AppleScript
If you're like me, it is often nice to know the time spent on a call (especially if you charge your services by the minute) and even though the cheapest cell phones out there can tell you the time you were just on the phone, that data is buried deep in iPhone's records and unaccessible from the touch GUI. I have been using a script created in ruby called calllog2ical, which you can download from this page at Google Code. The install process is a breeze and it can be called from Terminal. After using the script for about a week, I decided it would be nicer to use an AppleScript to access the shell script, and so I wrote one. Its all of one line and goes like this: do shell script "/usr/local/bin/calllog2ical.rb -v0 iPhone\\ Call\\ Log" In the above code, the calendar I am syncing to is iPhone Call Log. Notes: In order to get the AppleScript ...
published on Tuesday, the 26. August 2008, macosxhints
Use an AppleScript to force a desktop picture change
I have my desktop images set to change every 30 minutes in random order. Sometimes the desktop will display an image that displayed earlier in the day, and I wanted a way to 'advance' the image easily. The following AppleScript will cause the desktop image to change, in whatever order you have set, each time it is run:property theSwitch : 0if theSwitch = 0 then tell application "System Events" tell current desktop set change interval to 1801.0 end tell end tell set theSwitch to 1else tell application "System Events" tell current desktop set change interval to 1800.0 end tell end tell set theSwitch to 0end ifTo maintain your current change interval, modify the change interval lines to reflect your interval, measured in seconds. Thus, for my 30-minute setting, I used 1801 and 1800 seconds. One hour would be 3601 and 3600, etc. For this script to work, you must have both Change Picture and Random Order enabled on the Desktop ...
published on Wednesday, the 11. June 2008, macosxhints
Auto-Remount Disconnected Shares
Some server administrators set share drives to auto disconnect users after a set time of inactivity (ie fifteen minutes). As a user it’s super frustrating to connect to a server every time you need access. I’ve written an AppleScript that first checks to see if the share is mounted, if it is mounted [...]
published on Thursday, the 15. May 2008, apple-blog
One way to randomize order of an iPhoto slideshow
There are two ways to have a slideshow in iPhoto. From within an album, you can click the Play button and get a quick slideshow. With this method, you have the option to shuffle the order, and play music -- but you can't "fit" the duration of the slideshow to the music. The other way is to create a slideshow in the sidebar. Here you have the option of setting the duration of each slide to match that of the music (in my case, I had a 20 minute montage), but there is no way to randomize the order -- you have to drag by hand to set the manual order. My idea is to title the photos with a random number, then sort by title, thereby randomizing the images. Run this AppleScript in Script Editor to do just that: tell application "iPhoto" --tell album "photos" -- Note: change the album name above to reflect the album -- whose images you'd like to re-title, then remove the "--" -- at the beginning of the line. Note that if you leave it -- as "photos," th...
published on Wednesday, the 12. March 2008, macosxhints
iCalculate 1.0
For the freelancers out there who like light, fast apps that don't get in the way: This Applescript will use the events in an iCal calendar to calculate the total cost for a project based on the number of hours (and minutes) worked from any start date to today. The output is opened in a TextEdit document for copying or printing. The event summary (ie: the project's title) in the iCal calendar must use the same name consistently (ie: 'ABC Project') in order for the iCalculate script to accurately total the hours. This Applescript is editable and can be configured with your own variables (pay rate, calendar name, etc.).
published on Sunday, the 2. March 2008, scriptbuilders
10.5: Change the polling interval for folder actions
Folder actions in Leopard are triggered by the application Folder Action Dispatcher, which basically checks for modifications in a folder at a specified interval. Unfortunately, the default time interval in Leopard is 180 seconds, i.e. three minutes, which may be way too long sometimes. However, Folder Action Dispatcher is a scriptable app and it allows user to change the checking interval. Open Script Editor in /Applications/AppleScript, and type the following command on one line: tell application "Folder Action Dispatcher" to set polling interval to nnn Replace nnn with the desired polling interval, in seconds. Now click the Run button in the toolbar, and voila! [robg adds: On the queue site, a comment notes that Script Editor may ask where the app is -- it resides in /System/Library/CoreServices. You can avoid this by specifying the ...
published on Thursday, the 13. December 2007, macosxhints
Presentation Mode 1.0
The problem: Whenever I was giving presentations, the display or the machine would go to sleep on me, causing the projector to go blank. It was a pain to change the Energy Saver settings to prevent this. Even if I did remember, I often forgot to change them back to a more normal mode. The solution: An AppleScript to wrap the UNIX 'pmset' command and provide a convenient toggle between Presentation and Normal settings. If we're giving a presentation (on power or on battery), this script sets the display and the machine to never go to sleep, but allows the disk to shut down after 10 minutes of activity and run the internal screen at a lower brightness level when we're on battery. If we're in normal mode and running on battery, this script sets the display ot run at a lower brightness and to shut itself off after 1 minute of inactivity. The disk is shut off after 2 minutes of inactivity, and the whole machine goes to sleep after 5 minutes of inactivity. If we're in normal mode and running off of power, the script sets the display to itself off after 15 minutes of inactivity, and the disk to shut off after 10 minutes of inactivity. The system will never put itself to sleep. All of these settings/timings are adjustable fairly easily by modifying the script. This script is most useful if you place it in the /Library/Scripts folder and use the /Applications/AppleScript/AppleScript Utility application to turn on the Script Menu in the menu bar.
published on Sunday, the 11. November 2007, scriptbuilders
Get Traffic Map 1.0
The problem: My wife and I were looking at locations to move to in the San Francisco Bay Area, and we wanted to figure out how bad our commutes would tend to be. The solution: An AppleScript that opens a Google Map centered on the Bay Area with the traffic information layer turned on. It then takes a screenshot and saves it in the 'Traffic' folder on the desktop, with the date and time as part of the file name. Finally, it opens the screenshot in Graphic Converter and crops it so just the map is visible. We set this script to run every 15 minutes from 7-9am and 4-6pm on weekdays using the following cron command: 0,15,30,45 7,8,16,17 * * 1-5 /usr/bin/osascript /Users/ian/Desktop/Traffic/GetTrafficMap.scpt We left it to run for 4 weeks. After we had 20 days worth of data, we used Photoshop to take all the shots from each time of day (e.g. 7:45am), and combine them into a composite image (20 layers, each 5% transparency) to give an 'average' view of traffic at that time of day. See my website for a link to these composite images.
published on Sunday, the 11. November 2007, scriptbuilders