Archive for March, 2009

3
18
Mar

Quicksilver + Twitter + IM + Growl?

After re-evaluating my use of Quicksilver, I decided to see if anyone had integrated it with Twitter. A couple of people have been doing some integration, one did the ground work, another made some enhancements. I looked over the code, and decided that it needed a little more improvement. Not everyone is using Growl, for example (yes, there really are some that do not use it). So I edited the script to allow for IF Growl is present, then we will use it (though I really don’t know why, at the point of the other scripts all it did was say that it did what you just told it to do, not very helpful).

They integrated with 1 or 2 IM clients, so I went ahead and integrated with a couple more. I have support for MSN Messenger 6.0.3, Adium 1.3.3, iChat 4.0.7, and Skype 2.7.0. One of the problems with the previous scripts is the fact that if you were not already running the IM client in question, it was launched for you (how convenient?). I check to see if it is running first, and if it is running I adjust the status. This allows you to have multiple IM clients running, and they will all get the status update.

Next, and probably the biggest improvement that I made was the inclusion of Usable Keychain Scripting. I think the other guys may have added Growl support because the Keychain Scripting that is built in to the Mac is so dog slow that they wanted to know 2 minutes later when it finally finished processing and located their user name and password in the keychain. Enter Usable Keychain Scripting. Daniel decided to see if he cold improve on Apple’s work, and he succeeded. You get instant access to any keychain information you need, rather than parsing through the whole list looking for it. I just wish he would release the source code for it since he isn’t going to be maintaining it anymore. One thing to note is that you need to install this before you open script editor so that it will be aware of the scripting addition.

So, on to the script. Download Growl and install it if you want the notifications, and install Usable Keychain Scripting (mandatory). Copy the code from below into Script Editor. Save it as Tweet.scpt in your ~/Library/Application Support/Quicksilver/Actions (create it if it doesn’t already exist).

?View Code APPLESCRIPT
using terms from application "Quicksilver"
--get text from quicksilver
on process text tweet
--this section requires the use of Usable Keychain Scripting (http://www.red-sweater.com/blog/170/usable-keychain-scripting)
--Why?  The keychain scripting access was KILLING me, Usable Keychain Scripting is very fast.  This grabs user/pass from keychain.
tell application "Usable Keychain Scripting" to tell current keychain
	set twitter_user to account of first internet password whose name is "twitter.com"
	set twitter_password to password of first internet password whose name is "twitter.com"
	set twitter_login to quoted form of (twitter_user & ":" & twitter_password)
end tell
--here we create the status="something" that we get from quicksilver
set twitter_status to quoted form of ("source=qucs&status=" & tweet)
--now we send it to twitter for update
set results to do shell script "curl --basic --user " & twitter_login & " --data " & twitter_status & " http://twitter.com/statuses/update.xml"
--check if Growl exists, if it doesn't, we do nothing, if it does, we send alerts to it.  This is to let the script run
-- even if Growl is not installed, otherwise it would just exit the script.
tell application "System Events" to set GrowlRunning to ((application processes whose (name is equal to "GrowlHelperApp")) count)
if GrowlRunning >= 1 then
	if results contains "Could not authenticate you" then
		growlNotify("Tweet not sent, authentication problem")
	end if
	--register this script with Growl
	my growlRegister()
	--send alert info to growl, including what we tweeted
	growlNotify("Tweet Sent", tweet)
end if
 
--Here I check to see if the different IM applications are running.  If they are running, update their status.
--this allows for status updates of multiple IM clients without running them if they are currently off.
--support for MSN Messenger 6.0.3, Adium 1.3.3 iChat, and Skype currently
tell application "System Events" to set iChatIsRunning to (name of processes) contains "iChat"
tell application "System Events" to set adiumIsRunning to (name of processes) contains "Adium"
tell application "System Events" to set skypeIsRunning to (name of processes) contains "Skype"
tell application "System Events" to set msnIsRunning to (name of processes) contains "Microsoft Messenger"
 
--check if Adium is running, if it is update the status
if adiumIsRunning then
	tell application "Adium"
 
		go available with message tweet
 
	end tell
end if
 
--check if iChat is running, if it is update the status
if iChatIsRunning then
	tell application "iChat"
		set the status message to tweet
	end tell
end if
 
--check if Skype is running, if it is update the status
if skypeIsRunning then
	tell application "Skype" to send command "SET PROFILE MOOD_TEXT" & tweet script name "Quicksilver Tweet"
end if
 
--check if Msn Messenger is running, if it is update the status via the System Events as it does not support applescript
if msnIsRunning then
	set oldclip to the clipboard
	set the clipboard to tweet
	try
		tell application "Microsoft Messenger" to activate
		tell application "System Events"
			tell process "Microsoft Messenger"
				if not (exists window "Personal Contacts") then
					keystroke "l" using command down
				end if
				click menu item 2 of menu 1 of menu bar item "Messenger" of menu bar 1
				delay 0.1
				click button "Appearance" of tool bar 1 of window 1
				delay 0.1
				key code 48
				delay 0.1
				keystroke "v" using command down
				delay 0.1
				key code 36
			end tell
		end tell
	end try
	set the clipboard to oldclip
end if
end process text
end using terms from
 
--this section is a wrapper for growl notifications, I don't want a separate notification for each app I update, so I just say tweet sent
using terms from application "GrowlHelperApp"
	-- Register Growl
	on growlRegister()
		tell application "GrowlHelperApp"
			register as application "Tweet" all notifications {"Alert"} default notifications {"Alert"} icon of application "Script Editor.app"
		end tell
	end growlRegister
 
	-- Notify using Growl
	-- Example: growlNotify("This is an Alert","This is a test of the Growl Alert System")
	on growlNotify(grrTitle, grrDescription)
		tell application "GrowlHelperApp"
			notify with name "Alert" title grrTitle description grrDescription application name "Tweet"
		end tell
	end growlNotify
end using terms from

Next you will need to restart Quicksilver. You also need to make sure you have a twitter entry in your keychain access named twitter.com. Happy tweeting. Let me know if you like it, or if you want some changes to it. One user has noted that he does not have skype and therefore had to comment out the skype section.

0
18
Mar

Quicksilver annoyance finally fixed

For some time I have been experiencing an issue with Quicksilver clipboard plugin. Every time I quit an application, the clipboard pane opens. I have finally happened upon a solution which I happened upon before, but it didn’t make any sense at the time. I found this solution.

Basically, if you drag the clipboard window to either side of the screen, up against the edge, and then click out of it. It will disappear. When you move the mouse over to that portion of the side of the screen, it will slide back out. It will still respond to the hotkeys, but only if you go to the Spaces preference panel and tell it that quicksilver should be running in ALL screens. This is important so that the panel will work in every space, and not just in the one you were in when you put it there. This work around is called “docking” the panel. So it is always present, you just cant see it. This way it can’t pop up in my face every time I quit an application.

Finally. I was on the verge of switching back to the original launcher called Launchbar. They are coming out with a new version. You should check it out as a viable alternative to quicksilver.