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

10.8: AppleScript to close iCal Alerts System 10.8
I'd just installed OS X 10.8, and booted to find the right side of my screen covered in Birthday and Calendar notifications! Since installing I've clicked 'Close' on way too many iCal notification alerts.

Here's a script to close them all for you in one fell swoop. Since I still want iCal to popup a Notification alert for event alarms I've set, I don't want to simply disable all the iCal notifications (or set them to temporary banner alerts).

However, it still occurs that sometimes a small pile of alerts have accrued while I was away from the computer, and I really hate hitting 'Close' a bunch of times.

So, followng is a script to simply close all the piled-up Notification Alerts. The script was put together using these two webpages for inspiration: http://macosxautomation.com/mavericks/notifications/01A.html (most of the nice code comes from here) and http://apple.stackexchange.com/questions/52848/how-do-i-click-a-button-using-applescript (just how to click a button with AppleScript).

on run
 closeNotifications()
end run

on closeNotifications()
 try
  -- This function closes all currently displaying notification alerts. It used to also return the titles of each notification, which I have commented out to disable.
  tell application "System Events"
   tell process "Notification Center"
    set theseWindows to every window whose subrole is "AXNotificationCenterAlert" or subrole is "AXNotificationCenterBanner"
    --set theseTitles to {}
    repeat with thisWindow in theseWindows
     try
      -- Save the title of each alert window:
      --set thisTitle to the value of static text 1 of scroll area 1 of thisWindow
      --set the end of theseTitles to thisTitle
      
      -- Close each alert:
      click button "Close" of thisWindow
     end try
    end repeat --"theseWindows"
    --return theseTitles
   end tell -- "NotCenter"
  end tell -- "SysEvents"
  
 on error errorMessage number errorNumber
  if errorNumber is errorNumber then
   my addAppletToAccessibilityList()
   error number -128
  end if
 end try
end closeNotifications

on addAppletToAccessibilityList()
 -- This function gets the user to enable Accessibility, for scripting the UI interface (hitting buttons etc.)
 set thisAppletFile to (path to me)
 tell application "Finder" to reveal thisAppletFile
 tell application "System Preferences"
  launch
  activate
  
  reveal anchor "Privacy_Assistive" of pane id "com.apple.preference.security"
  
  activate
  
  display alert ¬
   "Add Applet to Accessibility" message "In order to respond to user clicks on Notification panels and alerts, this applet must be added to the lost of apps approved to use accessibility controls of the OS." & return & return & ¬
   "To add this app:" & return & return & ¬
   "1) Click the lock icon (if it is locked) and enter your password." & return & return & ¬
   "2) If 'SystemUIServer.app' is in the list, check the box next to it's name." & return & return & ¬
   "Otherwise, if the applet's name is in the list, check the box next to it's name. If it's not in the list, drag the applet (currently shown in the Finder) into the list area." & return & return & ¬
   "3) Click the lock to re-lock the preference pane, close System Preferences."
 end tell
end addAppletToAccessibilityList


[crarko adds: I haven't tested this one, as I don't run Mountain Lion any more. I remember the problem very well, though. I did compile the script successfully.]
  Post a comment  •  Comments (2)  
  • Currently 1.09 / 5
  You rated: 4 / 5 (55 votes cast)
 
[10,429 views] Email Article To a Friend View Printable Version
Displaying film-related metadata columns in non-"Movies" folders in the Finder System 10.8
You are probably already aware that extra columns of meta data can be added to the Movies folder in the Finder by right-clicking (ctrl-click) on the folder's header row. The following extra columns can be added: Duration; Dimensions; Title; Codecs. These extra columns do not feature in the View>Show View Options menu selection.

This hint describes how to obtain the same columns in folders not named "Movies".

This is a little pedantic, but in the UK we do not tend to use the term "movie" so much. We don't "Go to the movies" we "Go to watch a film". In fact the UK version of iTunes recognises this and in the sidebar or pop-up menu we have "Films" instead of "Movies" (and "TV Programmes" rather than "TV Shows" as well).

The Finder does not do this and the "Movies" folder is there in your home folder as expected.

In the "Movies" folder and any folder created inside it the above extra meta data columns can be added, and this applies to any other "Movies" folder created anywhere else - on another drive for example. But if you have another folder elsewhere that is labeled "Films", for example, the extra columns cannot be added.

However it is easy to add these columns - simply (re)name the folder "Movies". Open it and add the columns that you want. Then return and rename the folder back to "Films" or whatever. The extra columns remain and are still there after a log-out or restart.

And as long as at least one of these extra columns remain others can continue to be added or removed at will.

Now all my films on my external 3TB Raid drive show the extra meta data for convenient reference or sorting.
  Post a comment  •  Comments (7)  
  • Currently 4.13 / 5
  You rated: 4 / 5 (8 votes cast)
 
[17,130 views] Email Article To a Friend View Printable Version
Send iMessages from the Finder System 10.8

Just as you can send iMessages from the Contacts app, you can do so from the Finder too.

Right-click on any file or folder, and choose Share from the contextual menu that comes up. You can share files via AirDrop, email, and various social media services, depending upon the filetype. But nearly any file can be shared via iMessage.

Select the Messages option, and a popover appears for you to compose your message. If you really want to send the file, of course, you can go right ahead and do so. But if you're just looking to fire off a quick iMessage without first launching the Messages app, you can delete the file attachment from the message body, compose your message, and send it on its way.

  Post a comment  •  Comments (1)  
  • Currently 2.40 / 5
  You rated: 2 / 5 (10 votes cast)
 
[17,678 views] Email Article To a Friend View Printable Version
Quick Look with a three-finger tap System 10.8
Keyboard junkies know that they can rely on the spacebar to trigger a Quick Look preview of a file, folder, or drive in the Finder. But what about trackpad junkies?

The good news is, there's an option for the multitouch mavens, too. Perform a three-finger tap on any Quick Look-able item in the Finder, and a Quick Look preview you shall receive.

Repeat the gesture to send the Quick Look preview back into the abyss.
  Post a comment  •  Comments (15)  
  • Currently 1.91 / 5
  You rated: 2 / 5 (23 votes cast)
 
[19,324 views] Email Article To a Friend View Printable Version
Create Smart Collections in Font Book System 10.8
You remember Font Book, right? That's the built-in app that OS X offers for organizing and previewing fonts. In Mountain Lion, it gained a feature to make organization a little simpler: Smart Collections.

They work just like Smart Playlists, Smart Folders, and Smart Mailboxes. Option-click the Plus icon at the lower left, or choose File -> New Smart Collection.

Filters in your Smart Collection can include Family Name, Style Name, PostScript name, Languages, and Design Style. That way, you could make a collection that consists of, say, only English, italic, sans-serif fonts.
  Post a comment  •  Comments (3)  
  • Currently 4.29 / 5
  You rated: 5 / 5 (7 votes cast)
 
[16,298 views] Email Article To a Friend View Printable Version
Share contacts from your Mac via iMessage or AirDrop System 10.8
OS X's built-in Contacts app has long offered an option to share a contact's details via email. But OS X Mountain Lion added two additional options.

With a contact selected, click on the Send To arrow icon at the bottom of the window, and you can choose to send the card not just via email, but also via iMessage and AirDrop.

If you select the iMessage option, when the iMessage composition screen pops up, you can also use it as a quick shortcut to iMessaging the email address or phone number of your choosing: Just delete the card attachment inserted in the message body, and write whatever you'd like instead.
  Post a comment  •  Comments (0)  
  • Currently 3.50 / 5
  You rated: 2 / 5 (8 votes cast)
 
[15,850 views] Email Article To a Friend View Printable Version
Rearrange the Finder's sidebar sections via drag and drop System 10.8
Rearranging the sections in the sidebar of Finder windows used to be a beast. That hasn't been the case since the introduction of Mountain Lion.

You can drag and drop sections like Favorites, Devices, and Shared to reorder them however you'd like. And when you do so, the change is immediately effective in all Finder windows already open.

Even better, of course: The change is reflected in any new Finder windows you open, too.
  Post a comment  •  Comments (3)  
  • Currently 2.78 / 5
  You rated: 5 / 5 (9 votes cast)
 
[12,346 views] Email Article To a Friend View Printable Version
Set up a Minecraft server System 10.8

Here’s a recipe for setting up Minecraft server on OS X. Since I don’t fully trust the server not to have some security hole, I want it to run as user nobody so it doesn’t have a lot of permissions. And I also want it to restart automatically when I reboot the computer. Finally I show how to backup the worlds you create.

There’s three parts to this hint.

1) creating the launchDaemon that starts the minecraft server.
2) how to turn it on and off
3) maintaining backups

The first step is to download the minecraft server jar file from the Mojang website. Currently that site is https://minecraft.net/download but that might change in the future. And currently the jar filename is: minecraft_server.1.6.2.jar, but that will change too.

1) Creating a place for it. When you run the jar the first time it’s going to create a lot of files and subdirectories the in the current working directory (CWD) so we want to create a nice place to do this. It doesn’t matter where this it, but the permissions on the folder do matter. I put mine in /opt

sudo -s -
mkdir -p /opt/minecraft_server/state

Now if your user name is bob then move the minecraft jar into place:

mv /User/bob/Downloads/minecraft_server.1.6.2.jar /opt/minecraft

and make sure the top level folder and executable are owned by root. This will assure that no one can change the jar file without root access. Since the system is going to invoke this file automatically you don’t want it changing with simple user level permissions.

chown -R root:wheel /opt/minecraft<em>server
chmod -R a+xr  /opt/minecraft</em>server

Minecraft is going to run as user nobody, and it will need permission to modify the state folder contents.

chown nobody /opt/state
chmod 755 /opt/state

2) Creating the launch daemon:

As root, create the file

/Library/LaunchDaemons/net.minecraft.plist

The file name is not important, but it’s tradition to name the Daemon for website that it came from. You need to create this as root or otherwise assure it’s owned by root:wheel and can be read. It’s not an executable.


<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
           <string>net.minecraft</string>
        <key>RunAtLoad</key>
           <true/>
        <key>WorkingDirectory</key>
           <string>/opt/minecraft_server/state</string></p>

<pre><code>     &lt;key&gt;UserName&lt;/key&gt;
        &lt;string&gt;nobody&lt;/string&gt;

    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
            &lt;string&gt;/usr/bin/java&lt;/string&gt;
            &lt;string&gt;-Xmx1024M&lt;/string&gt;
    &lt;string&gt;-Xms1024M&lt;/string&gt;
    &lt;string&gt;-jar&lt;/string&gt;
    &lt;string&gt;/opt/minecraft_server/minecraft_server.1.6.2.jar&lt;/string&gt;
    &lt;string&gt;nogui&lt;/string&gt;
    &lt;/array&gt;
</code></pre>

<p></dict>
</plist>
The above is plist speak to tell it that it should change into the working directory where we want it to store its data, then launch the java jar with a memory size of 1G. You can adjust the values for your system if that turns out to be too much. It also tells it to run the job as the username nobody. And it will start the server when the Daemon is loaded, which happens either at boot time or if you explicitly tell the daemon to load.

The key thing here is that the paths to the “state” folder and the executable are hardcoded. You must change these paths if you set this up in a different place.

2) testing it. first make sure you have java installed. /usr/bin/java -version if java is installed then this will reply with the java version at that path. If it’s not installed OSX will usually ask you if you want to install java and then automagically do this for you.

as root, (sudo -s -) run the following: launchctl load /Library/LaunchDaemons/net.minecraft.plist

test to see if it worked:

ps auxww | grep java | grep jar

does the output include something like this:


nobody          1405   0.5 10.8  3814720 681608   ??  Rs   Mon06PM  25:58.23 /usr/bin/java…

If so then the server jar is running and is running as nobody.

If not then you made a mistake. To help diagnose this try running the command right from the command line.


cd /opt/minecraft<em>server/state
/usr/bin/java -Xmx1024M -Xms1024M -jar /opt/minecraft</em>server/minecraft_server.1.6.2.jar 
note, at this point you are running the server as root. This is reasonably safe, assuming you trust mojang, to do for a moment just to eliminate the permission issues. If you are nervous, disconnect your ethernet cable for a moment.

You may see some java exceptions printed in the process, but if the program stays running then it’s working. Once it stops printing stuff out, type ctrl-c to kill it. List the current directory (state) and you will see a whole bunch of files and folders have been created. So now you know the program and the paths are right. You’ll need to find the error you made. Most likely a permissions issue.

2) controlling it. to load the server by hand:

sudo launchctl load /Library/LaunchDaemons/net.minecraft.plist

it will start when you load it the first time.

to stop the server temporarily

sudo launchctl stop net.minecraft

Here I used the name not the path. The name is one given in the plist file not the actual file name. Normally you want to make these the same for sanity sake. This command stops the server but it doesn’t remove the autostart Daemon—next boot it will start again.

to restart it after stopping:

sudo launchctl start net.minecraft

to unload the daemon (so it won’t autostart at boot)

sudo launchctl unload  /Library/LaunchDaemons/net.minecraft.plist

If you edit the plist file, you need to stop the server and unload the daemon then (re)load the daemon. Otherwise it will ignore your edits till next reboot.

3) backing up the state. from time to time you may want to back up the state of your minecraft world and the server configuration (banned-IP, whitelist, config…)

To do that:


sudo -s -
cd /opt/minecraft_server
find ./state | sudo cpio -dpl <code>date "+%y%m%d-%H%M-minecraft"</code>

this command will create a snapshot backup of the state of your system. This will look like a copy off the state directory tree and files. But it’s not a copy. It’s a hardlinked image. It doesn’t actually occupy any (significant) disk space unless your world is changed. The command names the new snapshot for the date and time down to the hour.

You can restore an older image to being the current state by deleting the current state folder and moving the state folder from the image folder to the minecraft working directory.

Lex adds: I haven’t tested this one.

  Post a comment  •  Comments (4)  
  • Currently 2.27 / 5
  You rated: 1 / 5 (11 votes cast)
 
[15,276 views] Email Article To a Friend View Printable Version
Add full screen mode support to apps lacking it System 10.8
Some applications will never get full screen support. Here's a workaround.

1. Install SIMBL, http://www.culater.net/software/SIMBL/SIMBL.php.

2. Install Maximizer, http://chpwn.com/apps/maximizer.html.

3. Optional, but recommended step. Maximizer breaks full screen in some applications that already support it. To add it on a per application-basis edit SIMBLTargetApplications key from '/Library/Application Support/SIMBL/Plugins/Maximizer.bundle/Contents/Info.plist' by appending entries like explained at http://code.google.com/p/simbl/wiki/Tutorial, no. 3.

Example for TextEdit.

<key>SIMBLTargetApplications</key>
	<array>
		<dict>
			<key>BundleIdentifier</key>
			<string>com.apple.TextEdit</string>
			<key>MaxBundleVersion</key>
			<string>*</string>
			<key>MinBundleVersion</key>
			<string>*</string>
		</dict>
	</array>
Use the following applescript as a trigger with shortcut ⌃⌘F and scope per application(s) in Quicksilver (http://qsapp.com) or use a hotkey application, to enable/disable full screen mode.

tell application "System Events" to tell (first process whose frontmost is true)
	delay 0.05 -- tweak it as necessary
	if front window exists then
		tell front window
			if value of attribute "AXFullScreen" then
				set value of attribute "AXFullScreen" to false
			else
				set value of attribute "AXFullScreen" to true
			end if
		end tell
	end if
end tell
Lex adds: I haven't tested this one.
  Post a comment  •  Comments (10)  
  • Currently 1.23 / 5
  You rated: 1 / 5 (13 votes cast)
 
[7,978 views] Email Article To a Friend View Printable Version
Fix OS X wrongly reporting an application is corrupted (OSStatus error 99999) System 10.8
OS X stopped letting me install any software not coming from Apple. I wanted to update some software, and instead of seeing the "Quarantine Dialog" box telling that the software was just downloaded from Internet, I got a dialog box telling me that the software was corrupted.

In fact, it was not corrupted—I could use it on another Mac. The issue wasn't affecting Apple software, only third-party apps. Only by setting the "Anywhere" setting in System Preferences -> Security for installing apps could I install software again. But I didn't want to use that setting.

Looking in the Console, I saw error 99999 from CoreServiceUIagent when I tried to install software.

CoreServicesUIAgent[2105]: Error SecAssessmentCreate: L’opération n’a pas pu s’achever. (OSStatus erreur 99999).


After some research and help from Apple I found that a specific file's corruption was the source of my woes.

A way to confirm that you are this weird situation is to use the SecAssessment system policy security command line utility on a system file e.g. the ls command

$spctl --assess --verbose --raw /bin/ls

the result of this command is normally
$spctl --assess --verbose --raw /bin/ls
/bin/ls: accepted

and a dump of xml properties

in my case the output was
$spctl --assess --verbose --raw /bin/ls
/bin/ls: unknown error 99999=1869f

showing the 99999 error

The SystemPolicy got corrupted somehow. Fortunately there is a default database that you can restore.

Use this command (you need to be admin)
$ sudo cp /var/db/.SystemPolicy-default /var/db/SystemPolicy
and reboot; that will restore the ability to install software, and is likely to restore things back to normal.

You may then see an occasional security dialog box coming back again asking confirmation to run a software that you previously authorized, but this is the only drawback to resetting that database.
  Post a comment  •  Comments (1)  
  • Currently 1.80 / 5
  You rated: 1 / 5 (15 votes cast)
 
[8,010 views] Email Article To a Friend View Printable Version