Skip to content

Instantly share code, notes, and snippets.

@wakinchan
Created January 25, 2014 14:24
Show Gist options
  • Save wakinchan/8617153 to your computer and use it in GitHub Desktop.
Save wakinchan/8617153 to your computer and use it in GitHub Desktop.
Transparent Icon Selection
#define PreferencesFilePath [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Preferences/com.kindadev.transparenticonselection.plist"]
@interface SBApplicationIcon
- (id)applicationBundleID;
@end
@interface SBUserInstalledApplicationIcon : SBApplicationIcon
@end
%hook SBIconImageView
- (void)setIcon:(id)icon animated:(BOOL)animated
{
NSString *bundleIdentifier = [(SBApplicationIcon *)icon applicationBundleID];
BOOL isDisableApplication = NO;
if (bundleIdentifier
&& ([NSStringFromClass([icon class]) isEqualToString:@"SBUserInstalledApplicationIcon"]
|| [NSStringFromClass([icon class]) isEqualToString:@"SBApplicationIcon"])) {
NSDictionary *udDict = [NSDictionary dictionaryWithContentsOfFile:PreferencesFilePath];
NSString *key = [@"TISDisable-" stringByAppendingString:bundleIdentifier];
id disablePref = [udDict objectForKey:key];
isDisableApplication = disablePref ? [disablePref boolValue] : NO;
}
if (isDisableApplication) %orig(nil, animated);
else %orig;
}
- (id)darkeningOverlayImage
{
BOOL isDarkeningOverlayImage;
NSDictionary *udDict = [NSDictionary dictionaryWithContentsOfFile:PreferencesFilePath];
id darkeningPref = [udDict objectForKey:@"isDarkeningOverlayImage"];
isDarkeningOverlayImage = darkeningPref ? [darkeningPref boolValue] : NO;
if (isDarkeningOverlayImage) return nil;
else return %orig;
}
%end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment