feat: combine StatsKit and ModuleKit in the one framework: Kit

This commit is contained in:
Serhiy Mytrovtsiy
2021-06-04 19:37:29 +02:00
parent 69ba4190a6
commit 13707090eb
90 changed files with 490 additions and 872 deletions

View File

@@ -19,6 +19,6 @@
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020 Serhiy Mytrovtsiy. All rights reserved.</string>
<string>Copyright © 2021 Serhiy Mytrovtsiy. All rights reserved.</string>
</dict>
</plist>

View File

@@ -1,6 +1,6 @@
//
// BarChart.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 26/04/2020.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public class BarChart: WidgetWrapper {
private var labelState: Bool = false

View File

@@ -1,6 +1,6 @@
//
// Battery.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 06/06/2020.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public class BatterykWidget: WidgetWrapper {
private var additional: String = "none"

View File

@@ -1,6 +1,6 @@
//
// Label.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 30/03/2021.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public class Label: WidgetWrapper {
private var label: String

View File

@@ -1,6 +1,6 @@
//
// Chart.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 18/04/2020.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public class LineChart: WidgetWrapper {
private var labelState: Bool = false

View File

@@ -1,6 +1,6 @@
//
// Memory.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 30/06/2020.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public class MemoryWidget: WidgetWrapper {
private var orderReversedState: Bool = false

View File

@@ -1,6 +1,6 @@
//
// Mini.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 10/04/2020.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public class Mini: WidgetWrapper {
private var labelState: Bool = true

View File

@@ -1,6 +1,6 @@
//
// NetworkChart.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 19/01/2021.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public class NetworkChart: WidgetWrapper {
private var boxState: Bool = false

View File

@@ -1,6 +1,6 @@
//
// PieChart.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 30/11/2020.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public class PieChart: WidgetWrapper {
private var labelState: Bool = false

View File

@@ -1,6 +1,6 @@
//
// Sensors.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 17/06/2020.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public class SensorsWidget: WidgetWrapper {
private var modeState: String = "automatic"
@@ -186,20 +185,20 @@ public class SensorsWidget: WidgetWrapper {
public override func settings(width: CGFloat) -> NSView {
let view = SettingsContainerView(width: width)
view.addArrangedSubview(selectRow(
frame: NSRect(x: 0, y: 0, width: view.frame.width, height: Constants.Settings.row),
title: localizedString("Display mode"),
action: #selector(changeMode),
items: SensorsWidgetMode,
selected: self.modeState
))
view.addArrangedSubview(toggleTitleRow(
frame: NSRect(x: 0, y: 0, width: view.frame.width, height: Constants.Settings.row),
title: localizedString("Static width"),
action: #selector(toggleSize),
state: self.fixedSizeState
))
// view.addArrangedSubview(selectRow(
// frame: NSRect(x: 0, y: 0, width: view.frame.width, height: Constants.Settings.row),
// title: localizedString("Display mode"),
// action: #selector(changeMode),
// items: SensorsWidgetMode,
// selected: self.modeState
// ))
//
// view.addArrangedSubview(toggleTitleRow(
// frame: NSRect(x: 0, y: 0, width: view.frame.width, height: Constants.Settings.row),
// title: localizedString("Static width"),
// action: #selector(toggleSize),
// state: self.fixedSizeState
// ))
return view
}

View File

@@ -1,6 +1,6 @@
//
// Speed.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 24/05/2020.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public class SpeedWidget: WidgetWrapper {
private var icon: String = "dots"

View File

@@ -1,6 +1,6 @@
//
// constants.swift
// StatsKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 15/04/2020.
// Using Swift 5.0.

View File

@@ -1,6 +1,6 @@
//
// extensions.swift
// StatsKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 10/04/2020.
// Using Swift 5.0.

View File

@@ -1,6 +1,6 @@
//
// helpers.swift
// StatsKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 29/09/2020.
// Using Swift 5.0.
@@ -12,6 +12,26 @@
import Cocoa
import os.log
import ServiceManagement
public struct LaunchAtLogin {
private static let id = "\(Bundle.main.bundleIdentifier!).LaunchAtLogin"
public static var isEnabled: Bool {
get {
guard let jobs = (SMCopyAllJobDictionaries(kSMDomainUserLaunchd).takeRetainedValue() as? [[String: AnyObject]]) else {
return false
}
let job = jobs.first { $0["Label"] as! String == id }
return job?["OnDemand"] as? Bool ?? false
}
set {
SMLoginItemSetEnabled(id as CFString, newValue)
}
}
}
public protocol KeyValue_p {
var key: String { get }

View File

@@ -1,6 +1,6 @@
//
// module.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 09/04/2020.
// Copyright © 2020 Serhiy Mytrovtsiy. All rights reserved.
@@ -8,7 +8,6 @@
import Cocoa
import os.log
import StatsKit
public protocol Module_p {
var available: Bool { get }

View File

@@ -1,6 +1,6 @@
//
// popup.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 11/04/2020.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public protocol Popup_p: NSView {
var sizeCallback: ((NSSize) -> Void)? { get set }

View File

@@ -1,6 +1,6 @@
//
// reader.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 10/04/2020.
// Using Swift 5.0.
@@ -12,7 +12,6 @@
import Cocoa
import Repeat
import os.log
import StatsKit
public protocol value_t {
var widgetValue: Double { get }

View File

@@ -1,6 +1,6 @@
//
// settings.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 13/04/2020.
// Using Swift 5.0.
@@ -10,7 +10,6 @@
//
import Cocoa
import StatsKit
public protocol Settings_p: NSView {
var toggleCallback: () -> Void { get set }

View File

@@ -1,6 +1,6 @@
//
// widget.swift
// ModuleKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 10/04/2020.
// Using Swift 5.0.
@@ -11,7 +11,6 @@
import Cocoa
import os.log
import StatsKit
public enum widget_t: String {
case unknown = ""

View File

@@ -1,6 +1,6 @@
//
// Chart.swift
// StatsKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 17/04/2020.
// Using Swift 5.0.

View File

@@ -1,6 +1,6 @@
//
// SMC.swift
// StatsKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 05/04/2020.
// Using Swift 5.0.

View File

@@ -1,6 +1,6 @@
//
// store.swift
// StatsKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 10/04/2020.
// Using Swift 5.0.

View File

@@ -1,6 +1,6 @@
//
// SystemKit.swift
// Stats
// Kit
//
// Created by Serhiy Mytrovtsiy on 13/04/2020.
// Using Swift 5.0.

View File

@@ -1,6 +1,6 @@
//
// types.swift
// StatsKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 10/04/2021.
// Using Swift 5.0.

View File

@@ -1,6 +1,6 @@
//
// updater.swift
// StatsKit
// Kit
//
// Created by Serhiy Mytrovtsiy on 14/04/2020.
// Using Swift 5.0.

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
import IOKit.ps
struct Battery_Usage: value_t {

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
internal class Popup: NSView, Popup_p {
private var title: String

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
import os.log
internal class UsageReader: Reader<Battery_Usage> {

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
import SystemConfiguration
internal class Settings: NSView, Settings_v {

View File

@@ -7,8 +7,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
public struct CPU_Load: value_t {
var totalUsage: Double = 0

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
internal class Popup: NSView, Popup_p {
private var title: String

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
import os.log
internal class LoadReader: Reader<CPU_Load> {

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
internal class Settings: NSView, Settings_v {
private var usagePerCoreState: Bool = false

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
public struct stats {
var read: Int64 = 0

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
internal class Popup: NSView, Popup_p {
private let diskFullHeight: CGFloat = 62

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
import IOKit
import Darwin
import os.log

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
internal class Settings: NSView, Settings_v {
private var removableState: Bool = false

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
public struct Fan {
public let id: Int

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
internal class Popup: NSStackView, Popup_p {
public var sizeCallback: ((NSSize) -> Void)? = nil

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
import os.log
internal class FansReader: Reader<[Fan]> {

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
internal class Settings: NSStackView, Settings_v {
private var updateIntervalValue: Int = 1

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
public typealias GPU_type = String
public enum GPU_types: GPU_type {

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
internal class Popup: NSStackView, Popup_p {
public var sizeCallback: ((NSSize) -> Void)? = nil

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
import os.log
public struct device {

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
internal class Settings: NSView, Settings_v {
private var updateIntervalValue: Int = 1

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
import SystemConfiguration
public enum Network_t: String {

View File

@@ -11,8 +11,7 @@
// swiftlint:disable file_length
import Cocoa
import ModuleKit
import StatsKit
import Kit
// swiftlint:disable type_body_length
internal class Popup: NSStackView, Popup_p {

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
import SystemConfiguration
import Reachability
import os.log

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
import SystemConfiguration
internal class Settings: NSView, Settings_v {

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
public struct RAM_Usage: value_t {
var total: Double

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
internal class Popup: NSView, Popup_p {
private var title: String

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
import os.log
internal class UsageReader: Reader<RAM_Usage> {

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
internal class Settings: NSView, Settings_v {
private var updateIntervalValue: Int = 1

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
public class Sensors: Module {
private var sensorsReader: SensorsReader

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
internal class Popup: NSView, Popup_p {
private var list: [String: NSTextField] = [:]

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
import os.log
import IOKit.hid

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
internal class Settings: NSView, Settings_v {
private var updateIntervalValue: Int = 3

View File

@@ -9,7 +9,7 @@
// Copyright © 2020 Serhiy Mytrovtsiy. All rights reserved.
//
import StatsKit
import Kit
enum SensorGroup: String {
case CPU = "CPU"

File diff suppressed because it is too large Load Diff

View File

@@ -9,8 +9,7 @@
import Cocoa
import os.log
import StatsKit
import ModuleKit
import Kit
import CPU
import RAM

View File

@@ -10,7 +10,7 @@
//
import Cocoa
import StatsKit
import Kit
import os.log
class ApplicationSettings: NSScrollView {

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import StatsKit
import ModuleKit
import Kit
import os.log
class Dashboard: NSScrollView {

View File

@@ -10,8 +10,7 @@
//
import Cocoa
import ModuleKit
import StatsKit
import Kit
class SettingsWindow: NSWindow, NSWindowDelegate {
private let viewController: SettingsViewController = SettingsViewController()

View File

@@ -10,7 +10,7 @@
//
import Cocoa
import StatsKit
import Kit
import os.log
class UpdateWindow: NSWindow, NSWindowDelegate {

View File

@@ -10,8 +10,8 @@
//
import Cocoa
import Kit
import os.log
import StatsKit
extension AppDelegate {
internal func parseArguments() {

View File

@@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020 Serhiy Mytrovtsiy. All rights reserved.</string>
</dict>
</plist>

View File

@@ -1,15 +0,0 @@
//
// StatsKit.h
// StatsKit
//
// Created by Serhiy Mytrovtsiy on 14/04/2020.
// Using Swift 5.0.
// Running on macOS 10.15.
//
// Copyright © 2020 Serhiy Mytrovtsiy. All rights reserved.
//
#import <Foundation/Foundation.h>
FOUNDATION_EXPORT double StatsKitVersionNumber;
FOUNDATION_EXPORT const unsigned char StatsKitVersionString[];

View File

@@ -1,32 +0,0 @@
//
// launchAtLogin.swift
// StatsKit
//
// Created by Serhiy Mytrovtsiy on 14/04/2020.
// Using Swift 5.0.
// Running on macOS 10.15.
//
// Copyright © 2020 Serhiy Mytrovtsiy. All rights reserved.
//
import Cocoa
import ServiceManagement
public struct LaunchAtLogin {
private static let id = "\(Bundle.main.bundleIdentifier!).LaunchAtLogin"
public static var isEnabled: Bool {
get {
guard let jobs = (SMCopyAllJobDictionaries(kSMDomainUserLaunchd).takeRetainedValue() as? [[String: AnyObject]]) else {
return false
}
let job = jobs.first { $0["Label"] as! String == id }
return job?["OnDemand"] as? Bool ?? false
}
set {
SMLoginItemSetEnabled(id as CFString, newValue)
}
}
}