Created
May 27, 2026 10:44
-
-
Save d1y/23e3b6b3e6e48f6545dd4c3336a2fb17 to your computer and use it in GitHub Desktop.
Cyanide only show network speed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/Cyanide/SettingsViewController.m b/Cyanide/SettingsViewController.m | |
| index 2ceb556..ec3a87f 100644 | |
| --- a/Cyanide/SettingsViewController.m | |
| +++ b/Cyanide/SettingsViewController.m | |
| @@ -152,8 +152,10 @@ - (void)loadRespringPayload { | |
| NSString * const kSettingsStatBarEnabled = @"StatBarEnabled"; | |
| NSString * const kSettingsStatBarCelsius = @"StatBarCelsius"; | |
| -NSString * const kSettingsStatBarShowNet = @"StatBarShowNet"; | |
| +NSString * const kSettingsStatBarShowTemp = @"StatBarShowTemp"; | |
| NSString * const kSettingsStatBarShowCPU = @"StatBarShowCPU"; | |
| +NSString * const kSettingsStatBarShowRAM = @"StatBarShowRAM"; | |
| +NSString * const kSettingsStatBarShowNet = @"StatBarShowNet"; | |
| NSString * const kSettingsStatBarShowLabels = @"StatBarShowLabels"; | |
| NSString * const kSettingsRSSIDisplayEnabled = @"RSSIDisplayEnabled"; | |
| @@ -1912,8 +1914,10 @@ static void settings_start_statbar_live_loop(void) | |
| break; | |
| } | |
| ok = statbar_apply_in_session([d boolForKey:kSettingsStatBarCelsius], | |
| - [d boolForKey:kSettingsStatBarShowNet], | |
| + [d boolForKey:kSettingsStatBarShowTemp], | |
| [d boolForKey:kSettingsStatBarShowCPU], | |
| + [d boolForKey:kSettingsStatBarShowRAM], | |
| + [d boolForKey:kSettingsStatBarShowNet], | |
| [d boolForKey:kSettingsStatBarShowLabels]); | |
| } | |
| @@ -2011,8 +2015,10 @@ static void settings_apply_statbar_once_async(const char *reason) | |
| ![d boolForKey:kSettingsStatBarEnabled] || | |
| !g_springboard_rc_ready) return; | |
| ok = statbar_apply_in_session([d boolForKey:kSettingsStatBarCelsius], | |
| - [d boolForKey:kSettingsStatBarShowNet], | |
| + [d boolForKey:kSettingsStatBarShowTemp], | |
| [d boolForKey:kSettingsStatBarShowCPU], | |
| + [d boolForKey:kSettingsStatBarShowRAM], | |
| + [d boolForKey:kSettingsStatBarShowNet], | |
| [d boolForKey:kSettingsStatBarShowLabels]); | |
| } | |
| // Only log lifecycle applies that change result; a clean success on | |
| @@ -2794,8 +2800,10 @@ static BOOL settings_key_is_statbar(NSString *key) | |
| { | |
| return [key isEqualToString:kSettingsStatBarEnabled] || | |
| [key isEqualToString:kSettingsStatBarCelsius] || | |
| - [key isEqualToString:kSettingsStatBarShowNet] || | |
| + [key isEqualToString:kSettingsStatBarShowTemp] || | |
| [key isEqualToString:kSettingsStatBarShowCPU] || | |
| + [key isEqualToString:kSettingsStatBarShowRAM] || | |
| + [key isEqualToString:kSettingsStatBarShowNet] || | |
| [key isEqualToString:kSettingsStatBarShowLabels]; | |
| } | |
| @@ -2938,8 +2946,10 @@ static void settings_schedule_live_apply_for_key(NSString *key) | |
| @synchronized (settings_rc_lock()) { | |
| if (settings_cleanup_in_progress() || !g_springboard_rc_ready) return; | |
| bool ok = statbar_apply_in_session([d boolForKey:kSettingsStatBarCelsius], | |
| - [d boolForKey:kSettingsStatBarShowNet], | |
| + [d boolForKey:kSettingsStatBarShowTemp], | |
| [d boolForKey:kSettingsStatBarShowCPU], | |
| + [d boolForKey:kSettingsStatBarShowRAM], | |
| + [d boolForKey:kSettingsStatBarShowNet], | |
| [d boolForKey:kSettingsStatBarShowLabels]); | |
| settings_mark_tweak_applied(kSettingsStatBarEnabled, | |
| ok && [d boolForKey:kSettingsStatBarEnabled]); | |
| @@ -3085,8 +3095,10 @@ void settings_register_defaults(void) | |
| kSettingsStatBarEnabled: @NO, | |
| kSettingsStatBarCelsius: @NO, | |
| - kSettingsStatBarShowNet: @NO, | |
| + kSettingsStatBarShowTemp: @YES, | |
| kSettingsStatBarShowCPU: @YES, | |
| + kSettingsStatBarShowRAM: @YES, | |
| + kSettingsStatBarShowNet: @NO, | |
| kSettingsStatBarShowLabels: @YES, | |
| kSettingsRSSIDisplayEnabled: @NO, | |
| @@ -3210,9 +3222,10 @@ void settings_run_actions(void) | |
| (long)[d integerForKey:kSettingsLayoutDockScalePct]); | |
| } | |
| if (runStatBar) { | |
| - log_user("[PLAN] StatBar target: temp=%s cpu=%s network=%s refresh=1s\n", | |
| - [d boolForKey:kSettingsStatBarCelsius] ? "C" : "F", | |
| + log_user("[PLAN] StatBar target: temp=%s cpu=%s ram=%s network=%s refresh=1s\n", | |
| + [d boolForKey:kSettingsStatBarShowTemp] ? ([d boolForKey:kSettingsStatBarCelsius] ? "C" : "F") : "hidden", | |
| [d boolForKey:kSettingsStatBarShowCPU] ? "shown" : "hidden", | |
| + [d boolForKey:kSettingsStatBarShowRAM] ? "shown" : "hidden", | |
| [d boolForKey:kSettingsStatBarShowNet] ? "shown" : "hidden"); | |
| } | |
| if (runRSSI) { | |
| @@ -3245,7 +3258,7 @@ void settings_run_actions(void) | |
| log_user("[OK] Sandbox-extension patch stage finished.\n"); | |
| cyanide_upload_log_milestone(@"sandbox-ext-patched"); | |
| } | |
| - printf("[SETTINGS] actions escape=%d patch=%d sbc=%d dock=%ld hs=%ldx%ld hideLabels=%d dark=%d power=%d level=%s statbar=%d celsius=%d showNet=%d showCPU=%d rssi=%d rssiWifi=%d rssiCell=%d axon=%d rcReady=%d\n", | |
| + printf("[SETTINGS] actions escape=%d patch=%d sbc=%d dock=%ld hs=%ldx%ld hideLabels=%d dark=%d power=%d level=%s statbar=%d showTemp=%d celsius=%d showCPU=%d showRAM=%d showNet=%d rssi=%d rssiWifi=%d rssiCell=%d axon=%d rcReady=%d\n", | |
| runSandboxEscape, | |
| patchSandboxExt, | |
| runSBC, | |
| @@ -3257,9 +3270,11 @@ void settings_run_actions(void) | |
| runPowercuff, | |
| ([d stringForKey:kSettingsPowercuffLevel] ?: @"").UTF8String, | |
| runStatBar, | |
| + [d boolForKey:kSettingsStatBarShowTemp], | |
| [d boolForKey:kSettingsStatBarCelsius], | |
| - [d boolForKey:kSettingsStatBarShowNet], | |
| [d boolForKey:kSettingsStatBarShowCPU], | |
| + [d boolForKey:kSettingsStatBarShowRAM], | |
| + [d boolForKey:kSettingsStatBarShowNet], | |
| runRSSI, | |
| [d boolForKey:kSettingsRSSIDisplayWifi], | |
| [d boolForKey:kSettingsRSSIDisplayCell], | |
| @@ -3390,8 +3405,10 @@ void settings_run_actions(void) | |
| if (runStatBar) { | |
| settings_progress(&step, total, "Starting StatBar overlay and 1s feed"); | |
| bool ok = statbar_apply_in_session([d boolForKey:kSettingsStatBarCelsius], | |
| - [d boolForKey:kSettingsStatBarShowNet], | |
| + [d boolForKey:kSettingsStatBarShowTemp], | |
| [d boolForKey:kSettingsStatBarShowCPU], | |
| + [d boolForKey:kSettingsStatBarShowRAM], | |
| + [d boolForKey:kSettingsStatBarShowNet], | |
| [d boolForKey:kSettingsStatBarShowLabels]); | |
| settings_mark_tweak_applied(kSettingsStatBarEnabled, | |
| ok && [d boolForKey:kSettingsStatBarEnabled]); | |
| @@ -4202,8 +4219,10 @@ - (UITableViewCell *)buildWarningCell:(UITableViewCell *)cell | |
| - (NSArray<NSDictionary *> *)statbarRows | |
| { | |
| return @[ | |
| + @{ @"kind": @"toggle", @"key": kSettingsStatBarShowTemp, @"title": @"Show Temperature" }, | |
| @{ @"kind": @"toggle", @"key": kSettingsStatBarCelsius, @"title": @"Celsius" }, | |
| @{ @"kind": @"toggle", @"key": kSettingsStatBarShowCPU, @"title": @"Show CPU %" }, | |
| + @{ @"kind": @"toggle", @"key": kSettingsStatBarShowRAM, @"title": @"Show RAM" }, | |
| @{ @"kind": @"toggle", @"key": kSettingsStatBarShowLabels, @"title": @"Show CPU / RAM labels" }, | |
| @{ @"kind": @"toggle", @"key": kSettingsStatBarShowNet, @"title": @"Show network speed" }, | |
| ]; | |
| diff --git a/Cyanide/tweaks/statbar.h b/Cyanide/tweaks/statbar.h | |
| index 2bab484..e3c6a36 100644 | |
| --- a/Cyanide/tweaks/statbar.h | |
| +++ b/Cyanide/tweaks/statbar.h | |
| @@ -10,8 +10,8 @@ | |
| #import <stdbool.h> | |
| -bool statbar_apply(bool celsius, bool showNet, bool showCPU, bool showLabels); | |
| -bool statbar_apply_in_session(bool celsius, bool showNet, bool showCPU, bool showLabels); | |
| +bool statbar_apply(bool celsius, bool showTemp, bool showCPU, bool showRAM, bool showNet, bool showLabels); | |
| +bool statbar_apply_in_session(bool celsius, bool showTemp, bool showCPU, bool showRAM, bool showNet, bool showLabels); | |
| bool statbar_stop_in_session(void); | |
| void statbar_forget_remote_state(void); | |
| diff --git a/Cyanide/tweaks/statbar.m b/Cyanide/tweaks/statbar.m | |
| index ddb26c9..fc94ff3 100644 | |
| --- a/Cyanide/tweaks/statbar.m | |
| +++ b/Cyanide/tweaks/statbar.m | |
| @@ -289,22 +289,24 @@ static void read_net_speed_kbps(double *downKB, double *upKB) | |
| return pad_left_visual(token, 6); | |
| } | |
| -static NSString *build_text(bool celsius, bool showNet, bool showCPU, bool showLabels) | |
| +static NSString *build_text(bool celsius, bool showTemp, bool showCPU, bool showRAM, bool showNet, bool showLabels) | |
| { | |
| NSMutableArray<NSString *> *parts = [NSMutableArray array]; | |
| // Slot order: temp -> cpu -> ram -> net. `showNet` controls whether the | |
| // wider (260+) layout is used; in that mode, numbers are visually padded | |
| // to keep columns aligned as digits change. | |
| - double tempC = read_battery_temp_c(); | |
| - if (tempC > 0) { | |
| - double v = celsius ? tempC : (tempC * 9.0 / 5.0 + 32.0); | |
| - NSString *num = [NSString stringWithFormat:@"%.2f", v]; | |
| - NSString *displayNum = showNet ? pad_left_visual(num, 6) : num; | |
| - [parts addObject:[NSString stringWithFormat:@"%@\u00B0%c", | |
| - displayNum, celsius ? 'C' : 'F']]; | |
| - } else if (statbar_should_log_tick()) { | |
| - printf("[STATBAR] temp unavailable this tick\n"); | |
| + if (showTemp) { | |
| + double tempC = read_battery_temp_c(); | |
| + if (tempC > 0) { | |
| + double v = celsius ? tempC : (tempC * 9.0 / 5.0 + 32.0); | |
| + NSString *num = [NSString stringWithFormat:@"%.2f", v]; | |
| + NSString *displayNum = showNet ? pad_left_visual(num, 6) : num; | |
| + [parts addObject:[NSString stringWithFormat:@"%@\u00B0%c", | |
| + displayNum, celsius ? 'C' : 'F']]; | |
| + } else if (statbar_should_log_tick()) { | |
| + printf("[STATBAR] temp unavailable this tick\n"); | |
| + } | |
| } | |
| if (showCPU) { | |
| double pct = read_cpu_percent(); | |
| @@ -315,17 +317,19 @@ static void read_net_speed_kbps(double *downKB, double *upKB) | |
| [parts addObject:[NSString stringWithFormat:@"%@%%%@", displayNum, | |
| showLabels ? @" CPU" : @""]]; | |
| } | |
| - double freeGB = read_free_ram_gb(); | |
| - if (freeGB > 0) { | |
| - NSString *suffix = showLabels ? @" RAM" : @""; | |
| - if (freeGB < 1.0) { | |
| - NSString *num = [NSString stringWithFormat:@"%.2f", freeGB * 1024.0]; | |
| - NSString *displayNum = showNet ? pad_left_visual(num, 6) : num; | |
| - [parts addObject:[NSString stringWithFormat:@"%@MB%@", displayNum, suffix]]; | |
| - } else { | |
| - NSString *num = [NSString stringWithFormat:@"%.2f", freeGB]; | |
| - NSString *displayNum = showNet ? pad_left_visual(num, 6) : num; | |
| - [parts addObject:[NSString stringWithFormat:@"%@GB%@", displayNum, suffix]]; | |
| + if (showRAM) { | |
| + double freeGB = read_free_ram_gb(); | |
| + if (freeGB > 0) { | |
| + NSString *suffix = showLabels ? @" RAM" : @""; | |
| + if (freeGB < 1.0) { | |
| + NSString *num = [NSString stringWithFormat:@"%.2f", freeGB * 1024.0]; | |
| + NSString *displayNum = showNet ? pad_left_visual(num, 6) : num; | |
| + [parts addObject:[NSString stringWithFormat:@"%@MB%@", displayNum, suffix]]; | |
| + } else { | |
| + NSString *num = [NSString stringWithFormat:@"%.2f", freeGB]; | |
| + NSString *displayNum = showNet ? pad_left_visual(num, 6) : num; | |
| + [parts addObject:[NSString stringWithFormat:@"%@GB%@", displayNum, suffix]]; | |
| + } | |
| } | |
| } | |
| if (showNet) { | |
| @@ -430,15 +434,50 @@ void statbar_forget_remote_state(void) | |
| printf("[STATBAR] forgot remote overlay state\n"); | |
| } | |
| -static double statbar_overlay_width(bool showNet, bool showCPU, bool showLabels) | |
| +static double statbar_overlay_width(bool showTemp, bool showCPU, bool showRAM, bool showNet, bool showLabels) | |
| { | |
| - double base = showNet ? 260.0 : 140.0; | |
| - if (showCPU) base += 50.0; | |
| - if (showLabels) { | |
| - // Each appended " CPU" / " RAM" token adds visible width. | |
| - base += showCPU ? 70.0 : 35.0; | |
| + // 基础宽度:每个项目大约需要的空间 | |
| + // 温度: ~70px (例如 "25.50°C") | |
| + // CPU: ~50px (例如 "45%") 或 ~120px (带 " CPU" 标签) | |
| + // RAM: ~70px (例如 "2.50GB") 或 ~105px (带 " RAM" 标签) | |
| + // 网速: ~180px (例如 "↓ 1KB ↑ 7KB") | |
| + // 分隔符: 每个 " | " 约 15px | |
| + | |
| + double width = 0.0; | |
| + int itemCount = 0; | |
| + | |
| + if (showTemp) { | |
| + width += 70.0; | |
| + itemCount++; | |
| + } | |
| + | |
| + if (showCPU) { | |
| + width += showLabels ? 120.0 : 50.0; | |
| + itemCount++; | |
| + } | |
| + | |
| + if (showRAM) { | |
| + width += showLabels ? 105.0 : 70.0; | |
| + itemCount++; | |
| + } | |
| + | |
| + if (showNet) { | |
| + width += 180.0; | |
| + itemCount++; | |
| + } | |
| + | |
| + // 添加分隔符的宽度 (项目之间的 " | ") | |
| + if (itemCount > 1) { | |
| + width += (itemCount - 1) * 15.0; | |
| } | |
| - return base; | |
| + | |
| + // 添加左右内边距 | |
| + width += 20.0; | |
| + | |
| + // 如果没有任何项目,返回最小宽度 | |
| + if (width < 60.0) width = 60.0; | |
| + | |
| + return width; | |
| } | |
| static bool statbar_set_text_fast(uint64_t label, uint64_t textObj) | |
| @@ -637,7 +676,8 @@ static void statbar_apply_overlay_style(uint64_t label) | |
| } | |
| static bool statbar_apply_overlay_layout(uint64_t win, uint64_t label, | |
| - bool showNet, bool showCPU, bool showLabels) | |
| + bool showTemp, bool showCPU, bool showRAM, | |
| + bool showNet, bool showLabels) | |
| { | |
| if (!r_is_objc_ptr(win)) return false; | |
| @@ -645,7 +685,7 @@ static bool statbar_apply_overlay_layout(uint64_t win, uint64_t label, | |
| double screenWidth = statbar_valid_screen_length(metrics.screenWidth) ? | |
| metrics.screenWidth : kStatBarFallbackScreenWidth; | |
| double maxWidth = fmax(1.0, screenWidth - (kStatBarScreenSideMargin * 2.0)); | |
| - double width = fmin(statbar_overlay_width(showNet, showCPU, showLabels), maxWidth); | |
| + double width = fmin(statbar_overlay_width(showTemp, showCPU, showRAM, showNet, showLabels), maxWidth); | |
| double x = floor((screenWidth - width) / 2.0); | |
| if (x < 0.0) x = 0.0; | |
| double y = statbar_overlay_y_for_top_area(metrics.topAreaHeight); | |
| @@ -672,7 +712,8 @@ static bool statbar_apply_overlay_layout(uint64_t win, uint64_t label, | |
| return ok; | |
| } | |
| -static bool statbar_install_overlay(NSString *text, bool showNet, bool showCPU, bool showLabels) | |
| +static bool statbar_install_overlay(NSString *text, bool showTemp, bool showCPU, | |
| + bool showRAM, bool showNet, bool showLabels) | |
| { | |
| if (statbar_should_log_tick()) | |
| printf("[STATBAR] overlay: entry (dedicated UIWindow)\n"); | |
| @@ -686,7 +727,8 @@ static bool statbar_install_overlay(NSString *text, bool showNet, bool showCPU, | |
| bool ok = statbar_set_text_fast(gStatBarOverlayLabel, textObj); | |
| statbar_release_remote_obj(textObj); | |
| if (ok) { | |
| - statbar_apply_overlay_layout(gStatBarOverlayWindow, gStatBarOverlayLabel, showNet, showCPU, showLabels); | |
| + statbar_apply_overlay_layout(gStatBarOverlayWindow, gStatBarOverlayLabel, | |
| + showTemp, showCPU, showRAM, showNet, showLabels); | |
| if (statbar_should_log_tick()) | |
| printf("[STATBAR] overlay: fast cached text updated\n"); | |
| return true; | |
| @@ -728,7 +770,8 @@ static bool statbar_install_overlay(NSString *text, bool showNet, bool showCPU, | |
| gStatBarOverlayWindow = cachedWin; | |
| gStatBarOverlayLabel = cachedLabel; | |
| statbar_set_text_fast(cachedLabel, textObj); | |
| - statbar_apply_overlay_layout(cachedWin, cachedLabel, showNet, showCPU, showLabels); | |
| + statbar_apply_overlay_layout(cachedWin, cachedLabel, | |
| + showTemp, showCPU, showRAM, showNet, showLabels); | |
| r_msg2_main(cachedWin, "setHidden:", 0, 0, 0, 0); | |
| statbar_release_remote_obj(textObj); | |
| if (statbar_should_log_tick()) | |
| @@ -792,7 +835,7 @@ static bool statbar_install_overlay(NSString *text, bool showNet, bool showCPU, | |
| if (r_is_objc_ptr(white)) r_msg2_main(label, "setTextColor:", white, 0, 0, 0); | |
| } | |
| - statbar_apply_overlay_layout(win, label, showNet, showCPU, showLabels); | |
| + statbar_apply_overlay_layout(win, label, showTemp, showCPU, showRAM, showNet, showLabels); | |
| r_msg2_main(win, "addSubview:", label, 0, 0, 0); | |
| r_msg2_main(win, "setHidden:", 0, 0, 0, 0); | |
| r_dlsym_call(R_TIMEOUT, "objc_setAssociatedObject", app, assocKey, win, 1, 0, 0, 0, 0); | |
| @@ -866,26 +909,26 @@ static uint64_t __attribute__((unused)) walk_for_clock(uint64_t view, uint64_t c | |
| } | |
| } | |
| -bool statbar_apply_in_session(bool celsius, bool showNet, bool showCPU, bool showLabels) | |
| +bool statbar_apply_in_session(bool celsius, bool showTemp, bool showCPU, bool showRAM, bool showNet, bool showLabels) | |
| { | |
| gStatBarApplyTick++; | |
| - NSString *text = build_text(celsius, showNet, showCPU, showLabels); | |
| + NSString *text = build_text(celsius, showTemp, showCPU, showRAM, showNet, showLabels); | |
| if (statbar_should_log_tick()) { | |
| - printf("[STATBAR] === entry === text='%s' celsius=%d showNet=%d showCPU=%d showLabels=%d tick=%llu\n", | |
| - text.UTF8String, celsius, showNet, showCPU, showLabels, gStatBarApplyTick); | |
| + printf("[STATBAR] === entry === text='%s' celsius=%d showTemp=%d showCPU=%d showRAM=%d showNet=%d showLabels=%d tick=%llu\n", | |
| + text.UTF8String, celsius, showTemp, showCPU, showRAM, showNet, showLabels, gStatBarApplyTick); | |
| } | |
| - return statbar_install_overlay(text, showNet, showCPU, showLabels); | |
| + return statbar_install_overlay(text, showTemp, showCPU, showRAM, showNet, showLabels); | |
| } | |
| -bool statbar_apply(bool celsius, bool showNet, bool showCPU, bool showLabels) | |
| +bool statbar_apply(bool celsius, bool showTemp, bool showCPU, bool showRAM, bool showNet, bool showLabels) | |
| { | |
| if (init_remote_call("SpringBoard", false) != 0) { | |
| printf("[STATBAR] init_remote_call(SpringBoard) failed\n"); | |
| return false; | |
| } | |
| - bool ok = statbar_apply_in_session(celsius, showNet, showCPU, showLabels); | |
| + bool ok = statbar_apply_in_session(celsius, showTemp, showCPU, showRAM, showNet, showLabels); | |
| destroy_remote_call(); | |
| return ok; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment