Mac OS X Tips and Tricks: Part 1

Apple’s Mac OS X is so versatile that you can do almost anything you want with it; Yes, even sexing it up if you want to. The point here is, there are many hidden features and settings that many users never bother to know, with the exception of enthusiasts. So I will be trying to compile these treasures as often as I can; Therefore I do not know how many parts this post will be in, but rest assure that it will come to an end… when Apple comes to an end.

I wrote about one Dock trick in an earlier post and have decided to expand my “Tips and Tricks” archive. Most of the tips and tricks I will be mentioning in this post will apply to Snow Leopard and they will be in the form of terminal commands, so for those of you who are not familiar with the terminal, have no fear. The terminal app is located at /Applications/Utilities and you can copy and paste or just highlight then drag and drop the commands into your terminal window. “I know, you can’t do that in Windows!”

After executing the commands, you will have to restart the targeted application for the changes to take effect. If it’s a Finder or Dock tweak, the easiest way is to execute the appropriate command in terminal as follow:

  • killall Finder
  • killall Dock

To revert the changes you’ve made, just change the keywords of the command you executed as listed below:

  • YES to NO and vice versa
  • TRUE to FALSE and vice versa
  • 0 to 1 and vice versa

Commands

1. Quick Look X-Ray Folders

Enables you to preview files that are in a folder through a translucent folder icon when using Quick Look. The files will cycle through every 3 seconds when there are more than 5 files in the folder.

defaults write com.apple.finder QLEnableXRayFolders 1; killall Finder

Quick Look

Quick Look

2. Mouse-Over Highlights In Stacks
Items in your stacks that are in grid view will be highlighted when you hover your mouse cursor over them.

defaults write com.apple.dock mouse-over-hilite-stack -boolean YES; killall Dock

Grid

Grid

Fan

Fan

3. Make List View Look Like Grid View
Change list view to closely mimic grid view in your stacks.

defaults write com.apple.dock use-new-list-stack -bool YES; killall Dock

List

List

4. One-Window Dictionary
I like using the contextual menu to look up words when browsing the internet as oppose to using Command+Control+D[1] because of the keys being too close together, but since Snow Leopard, every time I look up a new word Dictionary just keeps opening new windows and that annoys the hell out of me. For those of you who are like me, the following command will force Dictionary to use only 1 window.

defaults write com.apple.Dictionary ProhibitNewWindowForRequest -bool TRUE

5. QuickTime Remaining In Full Screen
Whenever watching a movie on my Mac I occasionally get IM messages and when I Command+Tab[2] to view the message, my QuickTime window will always exits full screen, which isn’t what I want it to do. To keep QuickTime always in full screen execute the following command.

defaults write com.apple.QuickTimePlayerX MGFullScreenExitOnAppSwitch 0

6. Auto Play QuickTime Videos
By default QuickTIme does not auto play a video file when you open it. To enable auto play upon opening a video file execute the following command.

defaults write com.apple.QuickTimePlayerX MGPlayMovieOnOpen 1

7. Automatically Turn On Closed Captioning and Subtitles
Sometimes when playing a movie, I like to turn on subtitles because let’s face it, not all actors and actresses have been taught to speak clearly in theater school. But always having to click the menu to check if there are subtitles is just troublesome. The following command will automatically turn on closed captioning and subtitles when playing a video if they are available.

defaults write com.apple.QuickTimePlayerX MGEnableCCAndSubtitlesOnOpen 1

8. Address Book Debug Menu
The debug menu in Address Book enables some extra options, with one of them being able to toggle contact picture reflections; But the menu is hidden. To show the debug menu, run the following command.

defaults write com.apple.AddressBook ABShowDebugMenu -bool TRUE

Address Book

Address Book

Reference

[1] Command+Control+D allows quick definition look-ups within Cocoa applications such as Safari, Mail, Adium, etc.

[2] Command+Tab allows you to switch between running applications, just like CTRL+Tab on a Windows machine.

Audio For Everybody!

When The Love Falls by Sean OoiDownload Audio: Audio Format "MP3" | Audio Format "OGG"

Prologue

A few posts back I used the new HTML 5 video tag to display a video. That chunk of code was written by Kroc Camen and is compatible across most major browsers, including IE and the iPhone. One of the reasons I like it is because there is no JavaScript involved, making it lightweight.

It was his Video for Everybody post that inspired me to write this post. I figured since there's a cross-browser compatible code for the video tag, it would only be right to have one for the audio tag as well; A simple Google search came up with one related site that was very poorly written, so I decided to write one myself, based heavily on Kroc's code.

I've tested my codes on the iPhone and on common web browsers which includes Firefox, Safari and Opera on both Windows and Mac OS X, and Google Chrome and IE on Windows.

Compatibility

The code is validated as HTML 5. It will first try the HTML 5 playback, and fallback to flash if needed. If neither works, it will display an image showing users that no streaming capability is available and will ask to download the file instead.

  • Firefox 3.5: HTML5-OGG
  • Safari 4 (Mac): HTML5-MP3
  • Safari 4 (PC): HTML5-MP3→Flash
  • iPhone OS 3.1.2: HTML5-MP3 (Small play area due to the lack of the width & height attribute)
  • Opera 10: QT→Flash
  • Chrome 3: HTML5-OGG
  • <= IE 6: Flash
  • >= IE 7: Windows Media Player
Firefox

Firefox

Chrome

Chrome

IE

IE

iPhone

iPhone

Opera

Opera

The Code

<!-- Try HTML 5 playback first. -->
	<audio controls="controls">
	<source src="__AUDIO__.OGG" type="audio/ogg" /> <!-- Firefox and Chrome -->
	<source src="__AUDIO__.MP3" type="audio/mpeg" /> <!-- Safari and iPhone -->

<!-- Windows Media Player class id to enable native streaming on IE 7 and above. IE 6 and below will go straight to flash player -->
	<!--[if gt IE 6]>
	<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="320" height="45"><!
	[endif]-->

	<!--[if !IE]><!-->
	<object type="audio/mpeg" data="__AUDIO__.MP3">
	<!--<![endif]-->

<!-- Windows Media Player controls -->
	<param name="url" value="__AUDIO__.MP3" />
	<param name="autostart" value="false" />
	<param name="uiMode" value="full" />

<!-- Flash fallback -->
	<object height="24" width="320" type="application/x-shockwave-flash" data="__FLASH__.SWF" id="audioplayer">
	<param name="movie" value="__FLASH__.SWF" />
	<param name="FlashVars" value="playerID=audioplayer&amp;soundFile=__AUDIO__.MP3" />

<!-- Fallback image when nothing works -->
	<img class src="__POSTER__.JPG" width="128" height="135" alt="Title" title="No audio playback capabilities, please download the audio below" />

	</object><!--[if gt IE 6]><!-->
	</object><!--<![endif]-->
</audio> 

<!-- Download links outside the audio tag -->
<p>Download Audio: <a href="__AUDIO__.MP3">Audio Format "MP3"</a> | <a href="__AUDIO__.OGG">Audio Format "OGG"</a></p>

The line break in line 8 is due to a bug in IE. I'm not sure if it applies to the audio tag as well, but no harm being safe. A more compact version of the source code follows.

<audio controls="controls">
	<source src="__AUDIO__.OGG" type="audio/ogg" />
	<source src="__AUDIO__.MP3" type="audio/mpeg" />
	<!--[if gt IE 6]>
	<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" width="320" height="45"><!
	[endif]--><!--[if !IE]><!-->
	<object type="audio/mpeg" data="__AUDIO__.MP3">
	<!--<![endif]-->
	<param name="url" value="__AUDIO__.MP3" />
	<param name="autostart" value="false" />
	<param name="uiMode" value="full" />
	<object height="24" width="320" type="application/x-shockwave-flash" data="__FLASH__.SWF" id="audioplayer">
	<param name="movie" value="__FLASH__.SWF" />
	<param name="FlashVars" value="playerID=audioplayer&amp;soundFile=__AUDIO__.MP3" />
	<img class src="__POSTER__.JPG" width="128" height="135" alt="Title" title="No audio playback capabilities, please download the audio below" />
	</object><!--[if gt IE 6]><!-->
	</object><!--<![endif]-->
</audio> 
<p>Download Audio: <a href="__AUDIO__.MP3">Audio Format "MP3"</a> | <a href="__AUDIO__.OGG">Audio Format "OGG"</a></p>
Usage notes:
  • Replace __AUDIO__.MP3 with the path to your MP3 encoded file
  • Replace __AUDIO__.OGG with the path to your OGG encoded file
  • Replace __FLASH__.SWF with the path to your flash player. I use the standalone version of WordPress Audio Player
  • Replace __POSTER__.JPG with your JPEG image file for fallback purposes

One reason to put the download links outside the audio tag as said by Kroc for his Video for Everybody code: Give people your audio files—you want them to hear the audio anyway and you are fooling yourself if you think that they shouldn’t be allowed to download the audio.

I am not very confident when it comes to writing codes and explaining. In fact I suck at it, so please contact me if you spot any mistakes in my post. Any kind of help to further improve the code is welcomed as well.

SSH Into iPhone Without Wireless Router

I have always wondered if it were possible to SSH into my iPhone without a wireless router and search results on Google always pointed to no… This was before I found out that it was possible to do so.

Steps that I will be explaining will only apply to jailbroken iPhones and Macs, because I do not want to waste my time tinkering with Windows’ complicated network settings, so if you’re a PC user, I’m sorry, you’re out of luck. But if you found a way to do so, please do let me know and I can post it up as reference.

Instructions will be based on Mac OS X Snow Leopard 10.6.2 Things you will need will be of course, an iPhone, and a Mac with wireless capabilities. Which covers almost all Macs.

  1. Go into System Preference
  2. Click on Network
  3. Click on AirPort
  4. Turn AirPort on if you haven’t already
  5. Click on the Network Name dropdown menu and choose Create Network…
  6. The Name field will be your wireless name, or SSID. Leave the Channel as it is, and tick Require Password if you wish to do so.
  7. You will be asked to key in your admin password to finalize your network creation

Now that you’ve created a network, it’s time to connect your iPhone and SSH into it.

  1. Connect your iPhone like you would with any WAP.
  2. After you’re connected, give it awhile to register an IP address.
  3. Tap on the blue arrow beside your connected network to reveal your IP address. This is the address you will be using to SSH into your iPhone
  4. I like to use Coda for FTP purposes. But if you don’t have an FTP app, you can try Cyberduck
  5. Fire up your FTP app and click Connect on Coda or New Connection on Cyberduck.
  6. Change the Protocol to SFTP
  7. In the Server text field, type in the IP address you found in step 3
  8. Your username is root
  9. Your password is alpine[1]
  10. Leave the Port as 22 and click Connect

You have just SSH’ed into your iPhone without a wireless router. This method is most probably noted already somewhere on the web, but I have never been able to search for it. So hopefully this post will be of help to cheap people like me who do not want to fork out $50 for a wireless router

Reference

[1] In a previous post, I wrote on the vulnerability of not changing your iPhone’s root password and steps on how to do it. It is highly recommended that you do so as to secure your iPhone.

Mac OS X Dock Spacers

I was reorganizing my desktop when I noticed how cluttered my dock was, so I set out on a quest to find ways on how to make it look more organized and found out that adding spacers to it can help divide my applications into different sections, thus making it look cleaner and neater.

To add spacers to your dock, just fire up Terminal (Applications > Utilities) and run the following command:

defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'

Don’t worry if you don’t see any changes yet, because you still need to reload the dock. To do so, just run the following command in Terminal as well.

killall Dock

Your dock will reload and you should be seeing an empty space (spacer) on your dock now. To add more, just run the first command for as many spacers as you want and reload the dock.

You can add spacers to the right side of the dock too, or also known as the “Stacks” side of the dock. To do so, just run the following command for as many spacers as you want as well, and remember reload the dock when you’re done.

defaults write com.apple.dock persistent-others -array-add '{tile-data={}; tile-type="spacer-tile";}'

To remove these spacers, just right click on them and select “Remove from Dock” or just drag them out of the dock and it’ll *poof* away.

Dock Spacers

Dock Spacers