mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
BugFix: remove the accidental stats in gitignore
This commit is contained in:
parent
742e34fbdc
commit
05ec90e840
13 changed files with 1628 additions and 1 deletions
61
DynamicIsland/components/Stats/ProcessStats.swift
Normal file
61
DynamicIsland/components/Stats/ProcessStats.swift
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
//
|
||||
// ProcessStats.swift
|
||||
// DynamicIsland
|
||||
//
|
||||
// Process information structure for stats monitoring
|
||||
// Adapted from boring.notch implementation
|
||||
|
||||
import Foundation
|
||||
import AppKit
|
||||
import SwiftUI
|
||||
|
||||
// Process information structure
|
||||
struct ProcessStats: Identifiable, Hashable {
|
||||
let id = UUID()
|
||||
let pid: Int32
|
||||
let name: String
|
||||
let cpuUsage: Double
|
||||
let memoryUsage: UInt64 // in bytes
|
||||
let icon: NSImage?
|
||||
|
||||
var memoryUsageString: String {
|
||||
let formatter = ByteCountFormatter()
|
||||
formatter.allowedUnits = [.useMB, .useGB]
|
||||
formatter.countStyle = .memory
|
||||
return formatter.string(fromByteCount: Int64(memoryUsage))
|
||||
}
|
||||
|
||||
var cpuUsageString: String {
|
||||
return String(format: "%.1f%%", cpuUsage)
|
||||
}
|
||||
}
|
||||
|
||||
enum ProcessRankingType {
|
||||
case cpu
|
||||
case memory
|
||||
case gpu
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
case .cpu: return "CPU Usage"
|
||||
case .memory: return "Memory Usage"
|
||||
case .gpu: return "GPU Usage"
|
||||
}
|
||||
}
|
||||
|
||||
var icon: String {
|
||||
switch self {
|
||||
case .cpu: return "cpu"
|
||||
case .memory: return "memorychip"
|
||||
case .gpu: return "display"
|
||||
}
|
||||
}
|
||||
|
||||
var color: Color {
|
||||
switch self {
|
||||
case .cpu: return .blue
|
||||
case .memory: return .green
|
||||
case .gpu: return .purple
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue