Quality profiles

This commit is contained in:
Arkadiusz Fal
2022-08-14 19:06:22 +02:00
parent 57d8698f86
commit ac9abaec5a
19 changed files with 1372 additions and 234 deletions

View File

@@ -1,4 +1,5 @@
#import <CoreFoundation/CoreFoundation.h>
#import <IOKit/ps/IOPowerSources.h>
#import "../Vendor/mpv/include/client.h"
#import "../Vendor/mpv/include/render.h"
#import "../Vendor/mpv/include/render_gl.h"

38
macOS/Power.swift Normal file
View File

@@ -0,0 +1,38 @@
import Foundation
struct Power {
static var hasInternalBattery: Bool {
let psInfo = IOPSCopyPowerSourcesInfo().takeRetainedValue()
let psList = IOPSCopyPowerSourcesList(psInfo).takeRetainedValue() as [CFTypeRef]
for ps in psList {
if let psDesc = IOPSGetPowerSourceDescription(psInfo, ps).takeUnretainedValue() as? [String: Any] {
if let type = psDesc[kIOPSTypeKey] as? String {
if type == "InternalBattery" {
return true
}
}
}
}
return false
}
static var isConnectedToPower: Bool {
let psInfo = IOPSCopyPowerSourcesInfo().takeRetainedValue()
let psList = IOPSCopyPowerSourcesList(psInfo).takeRetainedValue() as [CFTypeRef]
for ps in psList {
if let psDesc = IOPSGetPowerSourceDescription(psInfo, ps).takeUnretainedValue() as? [String: Any] {
if let type = psDesc[kIOPSTypeKey] as? String,
type == "InternalBattery",
let powerSourceState = (psDesc[kIOPSPowerSourceStateKey] as? String)
{
return powerSourceState == kIOPSACPowerValue
}
}
}
return false
}
}