Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Display Notification Center Alerts from command line and AppleScripts System 10.8
Using the Automator action from this recent hint, it is easy to post notifications from AppleScripts or the command line.

To set this up, simply do the following:
  1. Download and install the action.
  2. Create a new workflow in Automator containing only the Display Notification Center Alert action.
  3. In the variables section at the bottom of the workflow construction area in Automator's window, create three variables named title, subtitle, and message.
  4. Give message a default value like "Notification sent." You can leave the default values other two blank.
  5. Drag each variable to its corresponding field in the Display Notification Center Alert action.
  6. Save the workflow as Display Notification.wflow. A good place to save it is in ~/Library/Workflows (create the folder if necessary).

Now you can display a notification from the command line using the following command:
automator -D title='Title text' -D subtitle='Subtitle text' -D message='Message text' ~/Library/Workflows/'Display Notification.wflow'

To display notifications from AppleScripts, paste the following handler into your script, and call it using the form notify("Notification title", "Notification subtitle", "Notification message")

on notify(title, subtitle, message)
	if title as text is not "" then set title to " -D title=" & quoted form of (title as text)
	if subtitle as text is not "" then set subtitle to " -D subtitle=" & quoted form of (subtitle as text)
	if message as text is not "" then set message to " -D message=" & quoted form of (message as text)
	
	do shell script "automator" & title & subtitle & message & " ~/Library/Workflows/Display Notification.wflow"
end notify
  Post a comment  •  Comments (7)  
  • Currently 2.95 / 5
  You rated: 5 / 5 (22 votes cast)
 
[14,254 views] Email Article To a Friend View Printable Version
Display Notification Center Alerts with Automator System 10.8
It would be great if you could be alerted in Notification Center when your Automator workflow is done. Here is an Automator action I created for displaying notification center alerts. It can be set to display a title, subtitle, and message. See the website linked above for screenshots.
  Post a comment  •  Comments (6)  
  • Currently 3.20 / 5
  You rated: 1 / 5 (20 votes cast)
 
[9,805 views] Email Article To a Friend View Printable Version
Dismiss banner notifications with a swipe on OS X System 10.8
If you are using Mountain Lion, you've probably seen the banner style notifications and wondered how to get them away quickly. Yet there is no close button.

The solution is simple: If you use a trackpad, use two fingers to swipe them away to the right; on the Magic Mouse, it's one finger swipe to the right. Of course, hover over it with the cursor and then swipe.

[kirkmc adds: Well, I wasn't sure whether to post this. The banners go away on their own after five seconds, so you'd need to be mighty impatient to want to go to the trouble of manually removing them. But there may be cases where you do want to do this. I'll let you discuss this in the comments below.]
  Post a comment  •  Comments (10)  
  • Currently 3.15 / 5
  You rated: 4 / 5 (20 votes cast)
 
[9,564 views] Email Article To a Friend View Printable Version
Edit Share menu System 10.8
Mountain Lion's new Share menu is handy, but not smart enough not to propose you services you haven’t signed for in the “Mail, Contacts & Calendar” Preferences pane. Here’s a way to remove from it the items you don’t use.

Copy the file /System/Library/PrivateFrameworks/ShareKit.framework/Versions/A/Resources/SHKServicesOrder.plist to a folder where you have write permissions. Duplicate it and keep a copy of the original in case you want to revert to the standard Share menu, as we’ll have to overwrite the system version.

Open the file with any text editor and erase the lines corresponding to services you don’t use. I’ve erased Twitter, Facebook, and all the video services. Save the file and copy it back to the folder mentioned above. When asked if you want to overwrite the file, click on Yes and enter an admin password. You may have to log out and back in for the changes to take effect.

[kirkmc adds: Note that this change may not survive a system update. I agree that this should be user-configurable, and basing it on accounts defined in the Mail, Contacts & Calendar preference pane - whose more appropriate name would be Accounts - would make sense. It would also be great if there were a way to add accounts that aren't hard-coded into the system. Could this be a challenge to hinters to try and figure out how to do that?]
  Post a comment  •  Comments (0)  
  • Currently 3.65 / 5
  You rated: 5 / 5 (20 votes cast)
 
[5,717 views] Email Article To a Friend View Printable Version
Toggle Web Sharing with an AppleScript System 10.8

As mentioned in this hint, Mountain Lion removed the setting in the Sharing preference pane to turn Web Sharing on and off, even though Apache Web Server is still installed by default. That hint also mentions a third-party preference pane that you can install to toggle Web Sharing in Mountain Lion.

Here's another solution in the form of an AppleScript. If you copy the script to a .scpt file in ~/Library/Scripts, you can conveniently toggle Web Sharing by selecting the script in the Scripts menu.

Here's the AppleScript:

display dialog "Enter your password:" with title "AppleScript" ¬
	default answer "" with hidden answer
set pw to text returned of result

set resultMsg to do shell script "
	listResult=`launchctl list | grep org.apache.httpd`; 
	if [[ $listResult ]]; then 
		apachectl stop; 
		echo 'Apache Web Server stopped.'; 
	else 
		apachectl start; 
		echo 'Apache Web Server started.'; 
	fi" password pw with administrator privileges

tell application "Finder"
	set notifier to POSIX file "/Applications/Terminal-Notifier.app"
	if exists notifier then
		do shell script POSIX path of notifier ¬
			& "/Contents/MacOS/terminal-notifier -message '" ¬
			& resultMsg & "'"
	else
		display alert resultMsg
	end if
end tell

The script uses the free Terminal-Notifier app by Eloy Durán, if installed, to notify you that Apache Web Server has been started or stopped. If you have the app installed somewhere other than /Applications, be sure to edit the app's path in the script.

Note that the state of Web Sharing is persistent across reboots, whether you use this method to control it or the aforementioned preference pane.

  Post a comment  •  Comments (1)  
  • Currently 3.00 / 5
  You rated: 2 / 5 (20 votes cast)
 
[3,403 views] Email Article To a Friend View Printable Version
Send Growl notifications to Notification Center System 10.8
If you use Growl, you might find it a bit overkill to have some notifications come through Growl and others to Notification Center. Mountain Growl pipes notifications from Growl to Notification Center, but there is one caveat: all these notifications will have the Growl icon, and not the icon of the application that sent the notification.

This is just a stop-gap, as Growl 2, to be released soon, will support Notification Center directly, but in the meantime, you might find this a useful solution to group all notifications in one place.
  Post a comment  •  Comments (8)  
  • Currently 3.32 / 5
  You rated: 4 / 5 (19 votes cast)
 
[3,771 views] Email Article To a Friend View Printable Version
Get notifications for iTunes track changes System 10.8
If you like getting those little Notification Center alerts when things happen, here's a way to get even more. iTunification gets information from iTunes when tracks change, and funnels this into Notification Center, so you can get a banner to see what the next track is.

This certainly isn't new, as GrowlTunes has been able to do this for a while (if you use Growl), and I get notifications from CoverSutra, an iTunes controller. On top of that, I'd be willing to bet pretty much anything that the next major update to iTunes has Notification Center support. But in the meantime, if you want simple banners to tell you what's playing, this is a good solution, and it's free.
  Post a comment  •  Comments (7)  
  • Currently 3.40 / 5
  You rated: 1 / 5 (20 votes cast)
 
[4,516 views] Email Article To a Friend View Printable Version
Set Software Update check frequency in Mountain Lion System 10.8
Mountain Lion removed the ability to set the frequency of checks for software updates. The default frequency was always a week and it remains so.

To change the frequency, open com.apple.SoftwareUpdate.plist, found in /Library/Preferences, and change the ScheduleFrequency key from 7 to the number of days you prefer.

I prefer to be notified of updates daily, if available, so I changed the frequency to 1.

[kirkmc adds: Note that you'll need admin privileges to edit this file. You can do so with a text editor, or with Xcode, which presents a graphical interface for .plist files. ]
  Post a comment  •  Comments (20)  
  • Currently 4.30 / 5
  You rated: 5 / 5 (10 votes cast)
 
[10,378 views] Email Article To a Friend View Printable Version
Fix iChat AppleScripts in Mountain Lion System 10.8
I noticed that my iChat-related AppleScripts had stopped working after the 10.8 upgrade. Apparently, Messages no longer answers to the name iChat; you have to edit your scripts to call "Messages" instead, like this:
tell application "Messages" to set status message to "On Mountain Lion"
I'm pretty sure the beta didn't break backwards compatibility like that, and I really can't think of a good reason for it.

[kirkmc adds: It's true that the name of an application like this changes it should probably still respond to the old name. So scripters beware. It's worth noting that both Contacts and Messages do respond to their old names if you search for them in Spotlight, though Calendar does not.]
  Post a comment  •  Comments (4)  
  • Currently 3.75 / 5
  You rated: 5 / 5 (4 votes cast)
 
[3,363 views] Email Article To a Friend View Printable Version
AppleScript to tweet via Notification Center System 10.8
The Click to Tweet button in Notification Center is just crying out for a way to activate it without taking your hands off your keyboard. Over at StackExchange, user Ewwis posted the following AppleScript. Save this and launch it with, say, LaunchBar or another launcher. It displays a dialog where you can post your tweet, then, when you click on OK, displays Notification Center and sends your tweet.
display dialog "Tweet?" default answer "" buttons {"OK"} default button 1
set mytweet to text returned of result

tell application "System Events"
    tell process "Notification Center"
        click menu bar item 1 of menu bar 1
        click button 1 of UI element 1 of row 2 of table 1 of scroll area 1 of window "window"
        keystroke mytweet
        keystroke "D" using {command down, shift down}
        keystroke space
    end tell
end tell
  Post a comment  •  Comments (1)  
  • Currently 2.80 / 5
  You rated: 1 / 5 (5 votes cast)
 
[4,066 views] Email Article To a Friend View Printable Version