Small guide on how to change scrollbar behavior on a per-app basis:
UPDATE: If you just want to toggle behavior for specific applications, you can now use my open-source LionScrollbars app (link to post), available on MacUpdate and BitBucket.
defaults write com.macromates.TextMate AppleShowScrollBars Always
defaults delete com.macromates.TextMate AppleShowScrollBars
defaults read com.macromates.TextMate AppleShowScrollBars
Or Globally:
defaults write -g AppleShowScrollBars Always
Possible values:
- Automatic (i.e. “Automatically based on input device”)
- WhenScrolling
- Always
OS X Lion (10.7)
Lion has sandboxing of certain apps, which we need to account for. To check if an app will be sandboxed, look for a Contents/_CodeSignature directory. This is not foolproof, but maybe good enough. If the app is sandboxed, then instead of writing to: ~/Library/Preferences/com.company.AppName.plist
(which would be where) [NSUerDefaults persistentDomainForName:]
would read from, you must look in: ~/Library/Containers/Data/Library/Preferences/com.company.AppName.plist
. This has to be done manually by reading in and writing out the file, using [NSDictionary readFile:]
.
The older way using CoreFoundation to read/write settings also does not work:
CFPreferencesSetAppValue((CFStringRef)kAppleShowScrollBarsKey, (CFStringRef)value, (CFStringRef)identifier);
CFPreferencesAppSynchronize((CFStringRef)identifier);
This also only looks in the first, default place, and not within sandboxes.
the terminal command defaults
seems to know about the sandboxed location for some apps, but not all. Preferences it find properly in the sandbox, but TextEdit it does not. The workaround to simply run /usr/bin/defaults
for reading/writing will also therefore not work in all cases.
Reading/Writing preferences via NSUserDefaults
Reading/Writing preferences via CoreFoundation
Reading/Writing via NSTask and /usr/bin/defaults
Reading/Writing plist files directly:
From: http://www.ifans.com/forums/showthread.php?t=64679