defaults
This subchapter looks at defaults, a Mac OS X command.
defaults is used to read, write, or delete defaults from a command line shell.
defaults options
Mac OS X programs use the defaults system to record user preferences and other information. Most of the information is more easily accessed through the applications Preferencess panel, but some information is normally inaccessible to the end user.
Note: Since applications do access the defaults system while theyre running, you shouldnt modify the defaults of a running application.
All programs share the defaults in NSGlobalDomain. If the program doesnt have its own default, it uses the value from the NSGlobalDomain.
screencapture defaults
The following methods use Terminal to change the default file format and location where the screenshot is saved from the graphic user interface.
In Mac S X 10.4 (Tiger) or more recent, the default screencapture format can be changed in Terminal by using the defaults command. In Mac S X 10.4 (Tiger), the new default does not take effect until you logout and log back in(from the entire computer, not just from Terminal a full restart will also work) unless you also use the killall command.
$ defaults write com.apple.screencapture type ImageFormat; killall SystemUIServer
The FileFormat can be png (Portable Network Graphic), pdf (Portable Document Format), tiff (Tagged Image File Format), jpg or jpeg (Joint Photographic Experts Group), pict (Macintosh QuickDraw Picture), bmp (Microsoft Windows Bitmap), gif (Graphics Interchange Format), psd (Adobe Photoshop Document), sgi (Silicon Graphics File Format), or tga (Truevision Targe File Format).
JPGs are saved at quality 60%.
To change the default location where the screenshot file is saved (the default is Desktop), use the following Terminal command (where pathname is the full path to a directory.:
$ defaults write com.apple.screencapture location PathName; killall SystemUIServer
The normal default location would be reset with the following command (where USername is the current accounts user name.
$ defaults write com.apple.screencapture location /Users/UserName/Desktop; killall SystemUIServer
dock defaults
Use the following commands to change the 3D Dock of Mac OS X Lion back to the 2D look. The killall restarts the Dock so that the change takes effect right away.
$ defaults write com.apple.dock no-glass -boolean YES; killall Dock
Return to the 3D look with the following commands:
$ defaults write com.apple.dock no-glass -boolean NO; killall Dock
Use the following commands to add a gradient behind an icon in a Dock Stack in Mac OS X:
$ defaults write com.apple.dock mouse-over-hilte-stack -boolean YES; killall Dock
Use the following commands to add a small Exposé button to the upper right of your Mac OS X screen. Clicking on the Exposé button will show all of the windows from the current application (same as the normal F10 default) and option clicking the Exposé button will show all windows from all programs (same as the normal F9 default). This will work even if you reconfigure the F9 and F10 keys to do something else.
$ defaults write com.apple.dock wvous-floater -bool YES; killall Dock
Use the following commands to remove the small Exposé button.
$ defaults write com.apple.dock wvous-floater -bool NO; killall Dock
login defaults
Use the following command to add a message to your Login window. Replace message with a short message. Keep the message short. As always with the sudo command, type very carefully.
$ sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "message"
To remove the login message, type the following:
$ sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText ""
showing dot files
The Mac OS X Finder hides all files that start with the period or dot character. This matches the standard behavior of ls in UNIX, where a leading dot is used as an indicator of a hidden file.
To have Finder always show all files, including hidden files, type:
$ defaults write com.apple.Finder AppleShowAllFiles YES; killall Finder
To restore Finder to its default behavior, type:
$ defaults write com.apple.Finder AppleShowAllFiles NO; killall Finder
.DS_Store files
To prevent Mac OS X from creating .DS_Store files on network shares (and everywhere else), type:
$ defaults write com.apple.desktopservices DSDontWriteNetworkStores true
To restore Mac OS X from creating .DS_Store files on network shares (and everywhere else), type:
$ defaults write com.apple.desktopservices DSDontWriteNetworkStores false
Mac Flashback Trojan
You can use defaults to determine if your Macintosh has been infected by the Mac Flashback Trojan (which enters your computer through a Java flaw).
Type the following command (copy and paste into Terminal):
$ defaults read /Applications/Safari.app/Contents/Info LSEnvironment
A clean system will report The domain/default pair of (/Applications/Safari.app/Contents/Info, LSEnvironment) does not exist. Any other result indicates your computer is infected.
If your computer passes the first test, type the following command (copy and paste into Terminal):
$ defaults read ~/.MacOSX/environment DYLD_INSERT_LIBRARIES
A clean system will report The domain/default pair of (/Users/user-name/.MacOSX/environment, DYLD_INSERT_LIBRARIES) does not exist. Any other result indicates your computer is infected.
If your computer is infected, immediately go to F-Secure.
Downloading the latest security patches from Apple will help prevent infection.
comments, suggestions, corrections, criticisms
free music player coding example
Coding example: I am making heavily documented and explained open source code for a method to play music for free almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).
View music player in action: www.musicinpublic.com/.
Create your own copy from the original source code/ (presented for learning programming).
Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.
Names and logos of various OSs are trademarks of their respective owners.