mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: move to the new mechanism of setting up fan speed (separate SMC app) (#454)
This commit is contained in:
@@ -198,23 +198,12 @@ internal class FanView: NSStackView {
|
||||
buttons.callback = { [weak self] (mode: FanMode) in
|
||||
self?.fan.mode = mode
|
||||
if let fan = self?.fan {
|
||||
SMC.shared.setFanMode(fan.id, mode: mode)
|
||||
SMCHelper.shared.setFanMode(fan.id, mode: mode.rawValue)
|
||||
}
|
||||
self?.toggleMode()
|
||||
}
|
||||
|
||||
let rootBtn: NSButton = NSButton(frame: NSRect(x: 0, y: 4, width: view.frame.width, height: view.frame.height - 8))
|
||||
rootBtn.title = "Control fan (root required)"
|
||||
rootBtn.setButtonType(.momentaryLight)
|
||||
rootBtn.isBordered = false
|
||||
rootBtn.target = self
|
||||
rootBtn.action = #selector(self.askForRoot)
|
||||
rootBtn.wantsLayer = true
|
||||
rootBtn.layer?.cornerRadius = 3
|
||||
rootBtn.layer?.borderWidth = 1
|
||||
rootBtn.layer?.borderColor = NSColor.lightGray.cgColor
|
||||
|
||||
view.addSubview(isRoot() ? buttons : rootBtn)
|
||||
view.addSubview(buttons)
|
||||
|
||||
return view
|
||||
}
|
||||
@@ -230,8 +219,8 @@ internal class FanView: NSStackView {
|
||||
|
||||
let slider: NSSlider = NSSlider(frame: NSRect(x: 0, y: 0, width: view.frame.width, height: 26))
|
||||
slider.minValue = self.fan.minSpeed
|
||||
slider.doubleValue = self.fan.value
|
||||
slider.maxValue = self.fan.maxSpeed
|
||||
slider.doubleValue = self.fan.value
|
||||
slider.isContinuous = true
|
||||
slider.action = #selector(self.speedChange)
|
||||
slider.target = self
|
||||
@@ -269,12 +258,6 @@ internal class FanView: NSStackView {
|
||||
return view
|
||||
}
|
||||
|
||||
@objc private func askForRoot(_ sender: NSButton) {
|
||||
DispatchQueue.main.async {
|
||||
ensureRoot()
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func speedChange(_ sender: NSSlider) {
|
||||
guard let field = self.sliderValueField else {
|
||||
return
|
||||
@@ -289,7 +272,7 @@ internal class FanView: NSStackView {
|
||||
let task = DispatchWorkItem { [weak self] in
|
||||
DispatchQueue.global(qos: .userInteractive).async { [weak self] in
|
||||
if let id = self?.fan.id {
|
||||
SMC.shared.setFanSpeed(id, speed: Int(value))
|
||||
SMCHelper.shared.setFanSpeed(id, speed: Int(value))
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
field.textColor = .systemBlue
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
9ABFF914248C30A800C9041A /* popup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ABFF913248C30A800C9041A /* popup.swift */; };
|
||||
9AD33AC624BCD3EE007E8820 /* helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AD33AC524BCD3EE007E8820 /* helpers.swift */; };
|
||||
9AD64FA224BF86C100419D59 /* settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AD64FA124BF86C100419D59 /* settings.swift */; };
|
||||
9AD7F866266F759200E5F863 /* smc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ADE7038265D059000D2FBA8 /* smc.swift */; };
|
||||
9ADE6FDB265D032100D2FBA8 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ADE6FDA265D032100D2FBA8 /* main.swift */; };
|
||||
9ADE702B265D03D100D2FBA8 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9ADE7005265D039300D2FBA8 /* IOKit.framework */; };
|
||||
9ADE7039265D059000D2FBA8 /* smc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ADE7038265D059000D2FBA8 /* smc.swift */; };
|
||||
@@ -1156,7 +1157,7 @@
|
||||
New,
|
||||
);
|
||||
LastSwiftUpdateCheck = 1240;
|
||||
LastUpgradeCheck = 1240;
|
||||
LastUpgradeCheck = 1250;
|
||||
ORGANIZATIONNAME = "Serhiy Mytrovtsiy";
|
||||
TargetAttributes = {
|
||||
9A1410F4229E721100D29793 = {
|
||||
@@ -1401,6 +1402,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9AD7F866266F759200E5F863 /* smc.swift in Sources */,
|
||||
9A2847612666AA2700EC1F6D /* PieChart.swift in Sources */,
|
||||
9A2847672666AA2700EC1F6D /* BarChart.swift in Sources */,
|
||||
9A28477B2666AA5000EC1F6D /* popup.swift in Sources */,
|
||||
@@ -1858,7 +1860,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
@@ -1890,7 +1892,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1240"
|
||||
LastUpgradeVersion = "1250"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1240"
|
||||
LastUpgradeVersion = "1250"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
Reference in New Issue
Block a user