Geektool script forces mail to stay open

Joined
Apr 27, 2008
Messages
92
Reaction score
5
Points
8
Your Mac's Specs
MBP 2.5 Intel Core 2 Duo, 2GB 667 MHz DDR2, 17" Hi-Res Display ; iPhone 3G 2.1
I am running a script in geektool to display my current number of unread mail messages on my desktop. I found this script on a website somewhere:

echo 'tell application "Mail" to return unread count of mailboxes of accounts' | osascript | perl -e "@a=split ',',<STDIN>; foreach (@a) {\$n += \$_}; print \"\$n\n\";"

The problem is that every time it updates it forces mail to open, which is causing problems when shutting down, and also sometimes i just dont want mail to be open.

Is there a way to modify this script so that it checks to see if mail is already open, and if it isnt end the script?
 
Joined
Sep 27, 2009
Messages
1
Reaction score
0
Points
1
well, i'm not sure about editing it, but here's a script I made:
Code:
tell application "System Events" to set iCalIsRunning to (name of processes) contains "Mail"
set finalText to ""
if iCalIsRunning then
	tell application "Mail"
		set unreadCount to unread count of inbox
		if (unreadCount is greater than or equal to 1) then
			return (unreadCount as string) & " new messages"
		else
			set finalText to "No new Mail"
		end if
	end tell
	
else
	set finalText to "Mail not open"
end if
Hope this helps!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top