Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Fanny/Fanny.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
84E99404232EEB3D009000FC /* Global.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E99403232EEB3D009000FC /* Global.swift */; };
84E99405232EEB55009000FC /* Global.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E99403232EEB3D009000FC /* Global.swift */; };
84E99410232EF25A009000FC /* FNYRadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E9940F232EF25A009000FC /* FNYRadioButton.swift */; };
CF697FC62CB2DDAE000A4D5B /* Fan+FNYExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF697FC52CB2DDAE000A4D5B /* Fan+FNYExtensions.swift */; };
CF697FC72CB2DDAE000A4D5B /* Fan+FNYExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF697FC52CB2DDAE000A4D5B /* Fan+FNYExtensions.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -122,6 +124,7 @@
84E99408232EEC88009000FC /* FNYWidgetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FNYWidgetViewController.swift; sourceTree = "<group>"; };
84E9940A232EEF7F009000FC /* FNYTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FNYTextField.swift; sourceTree = "<group>"; };
84E9940F232EF25A009000FC /* FNYRadioButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FNYRadioButton.swift; sourceTree = "<group>"; };
CF697FC52CB2DDAE000A4D5B /* Fan+FNYExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Fan+FNYExtensions.swift"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -166,6 +169,7 @@
8410EFCA2336E4A00003F94C /* Temperature+FNYExtensions.swift */,
84620D852447C2F3003B7B91 /* String+FNYExtensions.swift */,
8410EFCD2336F1CE0003F94C /* Bundle+FNYExtensions.swift */,
CF697FC52CB2DDAE000A4D5B /* Fan+FNYExtensions.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -460,6 +464,7 @@
84C31D4E231D7C9A00B8A9D5 /* SMC+Extensions.swift in Sources */,
84E993F3232ECE5E009000FC /* FNYDelegateMulticast.swift in Sources */,
8410EFCB2336E4A00003F94C /* Temperature+FNYExtensions.swift in Sources */,
CF697FC62CB2DDAE000A4D5B /* Fan+FNYExtensions.swift in Sources */,
84C31D4C231D7C9A00B8A9D5 /* SMCStructure.swift in Sources */,
84C31D51231D7C9A00B8A9D5 /* SMC+GPU.swift in Sources */,
84C31D4F231D7C9A00B8A9D5 /* SMC+CPU.swift in Sources */,
Expand Down Expand Up @@ -501,6 +506,7 @@
84E99402232EE709009000FC /* FNYDelegateMulticast.swift in Sources */,
844F4E24245DDA96002D6DC4 /* Sensor.swift in Sources */,
84E99405232EEB55009000FC /* Global.swift in Sources */,
CF697FC72CB2DDAE000A4D5B /* Fan+FNYExtensions.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
23 changes: 23 additions & 0 deletions Fanny/fanny-shared/Extensions/Fan+FNYExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Fan+FNYExtensions.swift
// Fanny
//
// Created by Jorge Pastor on 06/10/2024.
// Copyright © 2024 Daniel Storm. All rights reserved.
//

import Foundation

extension Array where Element == Fan {

func fastest() -> Fan? {
return self.max(by: { (a, b) -> Bool in a.currentRPM ?? 0 < b.currentRPM ?? 0 })
}
}

extension Fan {

func formattedRPM() -> String {
return (currentRPM?.description ?? "?") + " RPM"
}
}
4 changes: 3 additions & 1 deletion Fanny/fanny-shared/Storage/FNYUserPreferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ typealias TemperatureUnitOption = (index: Int, title: String, suffix: String)
typealias MenuBarIconOption = (index: Int, title: String)
typealias CPUSensorOption = (index: Int, title: String, key: String?)
typealias GPUSensorOption = (index: Int, title: String, key: String?)
typealias FanSensorOption = (index: Int, title: String, key: String?)

class FNYUserPreferences {

Expand All @@ -34,7 +35,8 @@ class FNYUserPreferences {
static let menuBarIconOptions: [MenuBarIconOption] = {
return [defaultMenuBarIconOption,
(1, "CPU Temperature"),
(2, "GPU Temperature")]
(2, "GPU Temperature"),
(3, "Fastest Fan RPM")]
}()

static let cpuSensorOptions: [CPUSensorOption] = {
Expand Down
1 change: 1 addition & 0 deletions Fanny/fanny/Menu/FNYMenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class FNYMenuController {
switch FNYUserPreferences.menuBarIconOption().index {
case 1: title = FNYLocalStorage.cpuTemperature()?.formattedTemperature(rounded: true)
case 2: title = FNYLocalStorage.gpuTemperature()?.formattedTemperature(rounded: true)
case 3: title = FNYLocalStorage.fans().fastest()?.formattedRPM()
default: image = NSImage(named: "status-item-icon-default.png")
}

Expand Down