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

10.5: Create an XKCD-influenced Mac 'doorbell' System 10.5
A friend of mine wrote recently on his blog:
Randall Munroe's XKCD has inspired interesting product features in the past. A recent one has sent a lot of Mac users scurrying to set up an audio doorbell on their Mac Minis.
Here's his solution to the problem; paste the following code into a text editor and save it as, for example, say.php in the top-level /Library » WebServer » Documents folder of the Mac you wish to turn into the doorbell:
<?php
if (isset($_GET['say'])) {
  $cmd = sprintf('say "%s"', preg_replace('/[^\w\d ]/', '', $_GET['say']));
  `$cmd`;

} else if (isset($_GET['up'])) {
  $cmd = 'set output_vol to output volume of (get volume settings)
  set volume output volume (output_vol + 10)';
  `osascript -e "$cmd"`;

} else  if (isset($_GET['down'])) {
  $cmd = 'set output_vol to output volume of (get volume settings)
  set volume output volume (output_vol - 10)';
  `osascript -e "$cmd"`;
}
?>
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="get">
  <p><input type="text" name="say">
  <input type="submit" value="Say"></p>
  <p>Volume:
  <input type="submit" name="up" value="Up">
  <input type="submit" name="down" value="Down"></p>
</form>
<p>Hey Randall, here's how you
  <a href="http://xkcd.com/530/">change the volume</a>.<br/>
  &ndash;<a href="http://manas.tungare.name/">Manas</a>.
</p>
To test from the Mac your created the file on, make sure Web Sharing is enabled in the Sharing System Preferences panel, then load http://localhost/say.php in your browser. To access the "doorbell" from another machine on the same network, use the Bonjour name (as shown in the Sharing System Preferences panel) instead: http://My_MacPro.local/say.php.

For a more detailed walk through, see the original post on my friend's blog.

[robg adds: We've had a lot of hints on using say in Terminal, but as far as I can tell, we've not run anything about changing the remote Mac's volume settings.]
  Post a comment  •  Comments (9)  
  • Currently 1.89 / 5
  You rated: 3 / 5 (9 votes cast)
 
[11,645 views] Email Article To a Friend View Printable Version
10.5: Put a file in the trash while the trash is emptying System 10.5
Sometimes when I am emptying the trash, I want to put another file into the trash, but OS X tells me I can't because "You cannot move any item to the Trash because it is being emptied." It happens more often than you might think, especially since I turn on "Empty Trash Securely," and often delete video files hundreds or thousands of megs in size.

However, if I move the want-to-be-deleted file into a Stack in the dock, I can then drag it from the Stack into the trash immediately, even while the trash is still emptying.
  Post a comment  •  Comments (13)  
  • Currently 2.43 / 5
  You rated: 5 / 5 (7 votes cast)
 
[8,042 views] Email Article To a Friend View Printable Version
10.5: Show more Recent Places in Open/Save dialogs System 10.5
Leopard limits the maximum number of Recent Places in the pop-up menu of the Open/Save dialog windows to a mere five items. Following this excellent tutorial that robg wrote on finding hidden preferences, I figured out that if there is a hidden preference somewhere, it must live in /System » Library » Frameworks » AppKit.framework » Versions » C » AppKit. Additionally, since nearly all apps in Leopard use the Cocoa Open/Save dialogs, it was obvious that the preference key likely follows the Cocoa naming scheme and begins with NSNav, just like the rest of the bunch.

And the winner is: NSNavRecentPlacesLimit. To apply, type the following in the Terminal, where 12 would be the number of recent places to display in the Open/Save dialogs:
defaults write .GlobalPreferences NSNavRecentPlacesLimit -int 12
Alternatively, you can also open ~/Library » Preferences » .GlobalPreferences.plist with your favorite plist editor, add a new key named NSNavRecentPlacesLimit and set an integer value of your choice. (Being not really the Terminal type of guy, this is the way I actually did it.) Once you have "collected" a larger list of places in the popup menu, you will also notice that they are sorted alphabetically, not chronologically, which would actually seem more logical given the term "recent".

In theory, this trick might also work on application basis, but I didn't tested it yet. Also in theory, there might be a way for an app to remember its own set of places instead of fetching the current global list. In a short test (which was an old carbon app running in Rosetta, though) it sort of worked in that sense, in that this particular app showed only the predefined places I've added manually to its plist, but it didn't add any new ones.

To list these items, I simply added a NSNavRecentPlaces array with items containing the POSIX path of the places to the app's plist. This is different than Tiger, where Carbon apps had their own array AppleRecentFolders with file://localhost/... type of URL.) This still needs some more investigation...
  Post a comment  •  Comments (5)  
  • Currently 2.15 / 5
  You rated: 1 / 5 (13 votes cast)
 
[20,609 views] Email Article To a Friend View Printable Version
10.5: How to abort a stuck Time Machine backup System 10.5
Sometimes you just need to stop that Time Machine backup, whether it's because it's slowing down your computer and you need it to be very fast right then and want to backup later, or because Time Machine is not working (as is happening to me right now).

Sometimes just clicking Stop Backup item in the menu bar or System Preferences panel doesn't work (as is happening to me right now). If that's the case, you can turn to Terminal to stop it immediately. (You can also do this from Activity Monitor, but it takes longer and is trickier).

Once you've opened up Terminal (in Applications » Utilities), you can use the killall command to kill the process backupd, which is the Time Machine process. However, the process backupd is owned by root, so you need to run killall with root permissions via sudo: sudo killall backupd Type in you password when prompted, and Time Machine will instantly stop. This is handy if Time Machine is broken and not working.

[robg adds: I wouldn't recommend using this hint unless Time Machine is really and truly stuck -- killing the process means that it won't get a chance to nicely finish whatever it was trying to do. In some cases, depending on what it's actually doing, you may endanger your backups. With that said, I have had TM get stuck (typically at the "Finishing backup" step) for literally hours, and have eventually resorted to killing the process to get it to stop.]
  Post a comment  •  Comments (9)  
  • Currently 2.82 / 5
  You rated: 5 / 5 (11 votes cast)
 
[49,563 views] Email Article To a Friend View Printable Version
10.5: Unmount ZFS filesystems on USB drives System 10.5
If you are lucky enough to be test driving ZFS on you Mac, you might find this useful. The latest ZFS build from Macosforge.com has a problem where ejecting a ZFS-formatted USB disk and unplugging it will crash Leopard.

However, I wrote an Automator action [286KB download] that will sudo and run a ZFS export on all mounted ZFS filesystems, so you can safely unplug your USB drive with ZFS on it.

[robg adds: I haven't tested this one.]
  Post a comment  •  Comments (8)  
  • Currently 2.17 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (6 votes cast)
 
[8,725 views] Email Article To a Friend View Printable Version
10.5: Fix a hang on admin password entry System 10.5
I Googled and looked everywhere when I tried fixing this issue, but couldn't find the fix (possible I didn't word it correctly). Eventually, I came up with the solution on my own, so I'm sharing here in case this affects others.

A coworker and I both had the same issue: While logging in, or just typing our password for admin rights to install or change settings, the authentication would hang up (sometimes for minutes). After almost giving up, I looked in the Accounts System Preferences panel, and noticed I was the only admin -- but I was listed as admin, managed.

Since I knew this wasn't correct, I created a test account with admin privileges and logged out and logged into the test account. I then opened Accounts System Preferences panel, and unchecked admin and then unchecked parental controls for my main account. After I changed the account back to admin, I logged out and back into the original account -- and the issue was resolved.

I have a feeling this was a bug that carried over from an earlier version of 10.5, as I was the admin from the initial install and never enabled parental controls. Hopefully this helps someone with the same issue.
  Post a comment  •  Comments (3)  
  • Currently 2.00 / 5
  You rated: 5 / 5 (6 votes cast)
 
[8,781 views] Email Article To a Friend View Printable Version
10.5: Delay Time Machine backup by one hour System 10.5
As an Apple consultant, it never fails that when I'm looking at a client's system, as soon as I do a System Update, the Time Machine backup system wants to kick in.

Since turning it off could have dire effects if I forget to turn it on again, I've learned a little trick to give me a one hour maintenance window to work on the machine and not get slowed down by Time Machine hogging the disk I/O.

If Time Machine starts up on you, quickly go to the Time Machine System Preferences panel. If you look to the right of the Options button, you will see a progress indicator. If you click on the small circled X at the right end of the progress bar, you just bought yourself an hour before Time Machins starts another backup.

I tell clients to do this over turning Time Machine off and on all the time. If it isn't always running, you're not really doing backups, and missing the key features it offers.

[robg adds: I don't know how this differs from clicking on the Time Machine icon in the menu bar and selecting Stop Backup, but it's always nice to have alternatives.]
  Post a comment  •  Comments (4)  
  • Currently 2.67 / 5
  You rated: 3 / 5 (6 votes cast)
 
[10,294 views] Email Article To a Friend View Printable Version
10.5: A script to fix Time Machine after hardware repairs System 10.5
Apparently I have bad luck with MacBooks, because I have found myself going through this Time Machine repair guide with shocking frequency. The process of migrating an old Time Machine backup to a new machine is pretty involved and prone to errors, so I wrote a shell script that gets the job done automatically:
#!/bin/bash
if [[ "$USER" != "root" ]]; then
  echo "You must run this script as root."
  exit 1
fi

VOLUME=`find /Volumes -mindepth 1 -maxdepth 2 -name 'Backups.backupdb' | head -n1 | sed 's/\/Backups.backupdb$//'`
if [[ -z "$VOLUME" ]]; then
  echo "Could not find a Time Machine drive. Please connect a drive and try again."
  exit 1
fi

BACKUP=`ls -d "$VOLUME/Backups.backupdb/"* | head -n1`
if [[ -z "$BACKUP" ]]; then
  echo "Could not find a Time Machine backup on the volume."
  exit 1
fi

OLDMAC=`xattr -p com.apple.backupd.BackupMachineAddress "$BACKUP"`
if [[ -z "$OLDMAC" ]]; then
  echo "Could not discover old MAC."
  exit 1
fi

NEWMAC=`ifconfig en0 | egrep -o 'ether ([0-9a-f]{2}:){5}[0-9a-f]{2}' | cut -c7-`
if [[ -z "$NEWMAC" ]]; then
  echo "Could not discover new MAC."
  exit 1
fi
if [[ "$NEWMAC" = "$OLDMAC" ]]; then
  echo "Found a Time Machine backup, but it's already bound to this machine."
  exit 1
fi

echo "Discovered a Time Machine backup at $BACKUP for MAC: $OLDMAC. Your new MAC is: $NEWMAC."
echo "Press enter to bind this backup to this machine, or Ctrl+C to cancel."
read

fsaclctl -p "$VOLUME" -d && \
mv "$VOLUME/.`echo "$OLDMAC" | sed s/://g`" "$VOLUME/.`echo "$NEWMAC" | sed s/://g`" && \
xattr -w com.apple.backupd.BackupMachineAddress "$NEWMAC" "$BACKUP" && \
OK=1
fsaclctl -p "$VOLUME" -e

if [[ -z "$OK" ]]; then
  echo "Something terrible happened while restoring the backup."
  echo "You're probably worse off now than you were before."
  echo "Sorry. :("
  exit 1
fi

echo "Time Machine backup successfully rebound to this machine. Please eject and reconnect the volume."
echo "Your first Time Machine backup after the restore process may take a really really long time."
echo "Like it might take a day or something, seriously."

It's simple to use:
  1. Copy and paste the entire script to a text file on your Desktop.
  2. Open a terminal, type sudo sh, then press the Space Bar, but do not press Enter/Return yet.
  3. Drag the text file where you saved the script into your Terminal, and then press Enter/Return.
This script will ask you for your password, and then if it discovers an old Time Machine backup, it will ask you if you want to automatically restore it.

[robg adds: I haven't tested this one.]
  Post a comment  •  Comments (24)  
  • Currently 2.54 / 5
  You rated: 3 / 5 (13 votes cast)
 
[41,857 views] Email Article To a Friend View Printable Version
10.5: Clear parental control log entries System 10.5
While recently setting up user accounts with parental controls, I decided to test how well various websites are blocked. I was using the Guest Account, which as far as I know, cannot be deleted. When checking the logs after my nasty little trip through the internet, I discovered that the logs cannot be deleted through the Parental Controls menu. I found a way to do this using Terminal, but also found a way to do this successfully using Finder. You will only be able to do this if you have administrator privileges.

The logs are stored in: /Library » Application Support » Apple » ParentalControls » Users » username. Normally, you will be allowed to see the /Users folder, but you will not have access to it. Accessing the file and deleting the log is straightforward:
  1. Highlight the Users folder.
  2. Select Get Info from the Action button.
  3. When the information window opens, click on the lock in the lower right corner to authenticate.
  4. Click the + and add yourself to the permissions list.
  5. Assign yourself read/write privileges.
  6. Return to Finder and select the desired user.
  7. Entries appear to be organized by date. Delete folders covering the dates you would like to erase.
  8. Restore correct permissions for the Users folder.
  9. Restart computer.
This should completely erase the user logs as seen in Parental Controls.
  Post a comment  •  Comments (3)  
  • Currently 3.07 / 5
  You rated: 4 / 5 (15 votes cast)
 
[37,944 views] Email Article To a Friend View Printable Version
A script to retain a copy of outgoing faxes System 10.5
For the few times I need to send a fax, I'm not going to mess with getting one of my broken third-party fax applications to run again. But the built-in OS X fax capability has some annoying limitations. One of the more annoying ones is that it doesn't save a copy of outgoing faxes. I wrote the following script as a kluge, to grab a copy of outgoing faxes and store them in /Users/Shared/Faxes/Outbox. The fax is saved (complete with the cover page) as a multi-page TIFF file.
!/bin/zsh

if [ $EUID -ne 0 ]; then
	echo YOU MUST SUDO TO ROOT TO RUN THIS
	exit
fi

dt=`date '+%Y%m%d-%H%M%S'`
t=''
echo Waiting for efax to run.
while [ x$t = x'' ]; do
	t=`ps -ef|grep efax|grep -v grep`
	sleep 1
done

ls -al /var/spool/cups/tmp
f=`echo $t|sed -e 's#.*\(/private.*\)#\1#'`
if [ -r $f ]; then
	echo COPYING $f to /Users/Shared/Faxes/Outbox/$dt.tiff
	cp $f /Users/Shared/Faxes/Outbox/$dt.tiff
	sudo chmod a+r /Users/Shared/Faxes/Outbox/$dt.tiff
	open /Users/Shared/Faxes/Outbox
else
	echo file $f doesn\'t exist
	exit
fi

echo If something goes wrong, try \"faxlog debug\"
tail -f /var/log/cups/error_log
I saved the script as watch_fax, in a spot where my admin user could get to it. You have to sudo to run this script, because it has to copy from /private/var. Don't forget to make it executable with chmod u+rx watch_fax.

To run it, I type sudo watch_fax. This script ends with a tail -f, which will show you the fax log as it's being written. When you're done watching the fax log, you'll have to kill the tail with Control-C. This script also references another of my scripts, called faxlog, that helps you set debug mode for the fax log. You can find that script in this hint.

[robg adds: I haven't tested this one.]
  Post a comment  •  Comments (4)  
  • Currently 1.86 / 5
  You rated: 1 / 5 (7 votes cast)
 
[7,927 views] Email Article To a Friend View Printable Version