-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTweak.x
55 lines (42 loc) · 1.38 KB
/
Tweak.x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* Copyright (c) 2024 Nightwind
*/
#import <UIKit/UIKit.h>
#import <GcUniversal/GcColorPickerUtils.h>
#import <rootless.h>
#import "Notifications.h"
static UIColor *prefs_musicPlayerColor = nil;
static UIColor *const UIColorFromHex(NSString *const hexString) {
if (!hexString) return nil;
unsigned rgbValue = 0;
NSScanner *const scanner = [NSScanner scannerWithString:hexString];
if ([hexString hasPrefix:@"#"]) {
scanner.scanLocation = 1;
}
[scanner scanHexInt:&rgbValue];
return [UIColor
colorWithRed:((rgbValue >> 24) & 0xFF) / 255.0
green:((rgbValue >> 16) & 0xFF) / 255.0
blue:((rgbValue >> 8) & 0xFF) / 255.0
alpha:(rgbValue & 0xFF) / 255.0
];
}
static void updatePrefs(void) {
NSDictionary *const prefs = [NSDictionary dictionaryWithContentsOfFile:@"/var/mobile/Library/Preferences/com.nightwind.musicplayercolorsettings.plist"];
if (prefs) {
prefs_musicPlayerColor = UIColorFromHex([prefs objectForKey:@"MusicPlayerColor"]);
}
}
@interface MRUNowPlayingView : UIView
@end
%hook MRUNowPlayingView
- (void)didMoveToWindow {
%orig;
updatePrefs();
self.backgroundColor = prefs_musicPlayerColor;
[[NSDistributedNotificationCenter defaultCenter] addObserverForName:kMusicPlayerColorChangedNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
updatePrefs();
self.backgroundColor = prefs_musicPlayerColor;
}];
}
%end