diff --git a/README.md b/README.md index c78e165f..ff68cdf4 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Stats -Application for macos that shows CPU, Memory and Disk usage on the menu bar +Simple macOS system monitor in your menu bar -[](https://github.com/exelban/stats/releases) +[](https://github.com/exelban/stats/releases) ## Why -Stats is a free application which allows you to monitor your system. +Stats is a application which allows you to monitor your macOS system. Also its: - free @@ -17,15 +17,14 @@ Also its: ## Installation You can download latest version [here](https://github.com/exelban/stats/releases). -## Widgets -Each widget can be disabled in menu. +## Modules -| Name | Type | Description | +| Name | Available widgets | Description | | --- | --- | --- | -| **CPU** | Percentage / Chart | Shows CPU usage | -| **Memory** | Percentage / Chart | Shows RAM usage | +| **CPU** | Percentage / Chart / Chart with value | Shows CPU usage | +| **Memory** | Percentage / Chart / Chart with value | Shows RAM usage | | **Disk** | Percentage | Shows disk filling | -| **Battery** | Graphic | Shows battery level | +| **Battery** | Graphic | Shows battery level and charging status | ## Compatibility | macOS | Compatible | @@ -34,6 +33,7 @@ Each widget can be disabled in menu. | 10.14.1 *(Mojave)* | **true** | ## Todo + - [ ] Battery percentage - [ ] Create new logo - [ ] Window with preferences - [ ] Save last modules values diff --git a/Stats/MenuBar.swift b/Stats/MenuBar.swift index 6677cfed..2dc09aad 100644 --- a/Stats/MenuBar.swift +++ b/Stats/MenuBar.swift @@ -111,32 +111,32 @@ class MenuBar { } self.menuBarButton.image = NSImage(named:NSImage.Name("tray_icon")) - var WIDTH = CGFloat(modules.value.count * 28) - - let view: NSView = NSView(frame: NSMakeRect(0, 0, WIDTH, MODULE_HEIGHT)) - - let stack: NSStackView = NSStackView(frame: NSMakeRect(0, 0, WIDTH, MODULE_HEIGHT)) - stack.orientation = NSUserInterfaceLayoutOrientation.horizontal - stack.distribution = NSStackView.Distribution.fillEqually - stack.spacing = 0 + self.menuBarItem.length = MODULE_WIDTH + var WIDTH = CGFloat(modules.value.count) * MODULE_WIDTH WIDTH = 0 for module in modules.value { if module.active.value && module.available.value { module.start() WIDTH = WIDTH + module.view.frame.size.width - stack.addView(module.view, in: NSStackView.Gravity.center) } } - if stack.subviews.count != 0 { + let view: NSView = NSView(frame: NSMakeRect(0, 0, WIDTH, MODULE_HEIGHT)) + + var x: CGFloat = 0 + for module in modules.value { + if module.active.value && module.available.value { + module.view.frame = CGRect(x: x, y: 0, width: module.view.frame.size.width, height: module.view.frame.size.height) + view.addSubview(module.view) + x = x + module.view.frame.size.width + } + } + + if view.subviews.count != 0 { view.frame.size.width = WIDTH - stack.frame.size.width = WIDTH - self.menuBarItem.length = WIDTH - - view.addSubview(stack) - self.menuBarButton.image = nil + self.menuBarItem.length = WIDTH self.menuBarButton.addSubview(view) } } diff --git a/Stats/Modules/Battery/BatteryReader.swift b/Stats/Modules/Battery/BatteryReader.swift index 3ba7d013..668caa43 100644 --- a/Stats/Modules/Battery/BatteryReader.swift +++ b/Stats/Modules/Battery/BatteryReader.swift @@ -33,7 +33,7 @@ class BatteryReader: Reader { updateTimer.invalidate() updateTimer = nil } - + @objc func read() { let psInfo = IOPSCopyPowerSourcesInfo().takeRetainedValue() let psList = IOPSCopyPowerSourcesList(psInfo).takeRetainedValue() as [CFTypeRef] @@ -41,10 +41,11 @@ class BatteryReader: Reader { for ps in psList { if let psDesc = IOPSGetPowerSourceDescription(psInfo, ps).takeUnretainedValue() as? [String: Any] { - let isCharging = (psDesc[kIOPSIsChargingKey] as? Bool) + let powerSourceState = (psDesc[kIOPSPowerSourceStateKey] as? String) + let isCharged = (psDesc[kIOPSIsChargedKey] as? Bool) var cap: Float = Float(psDesc[kIOPSCurrentCapacityKey] as! Int) / 100 - if !isCharging! { + if isCharged == nil && powerSourceState! == "Battery Power" { cap = 0 - cap } diff --git a/Stats/Supporting Files/About.storyboard b/Stats/Supporting Files/About.storyboard index ca836869..4f811814 100644 --- a/Stats/Supporting Files/About.storyboard +++ b/Stats/Supporting Files/About.storyboard @@ -1,8 +1,8 @@ - + - + @@ -67,8 +67,8 @@ - - + + @@ -85,8 +85,8 @@ - - + + @@ -174,7 +174,7 @@ - + diff --git a/Stats/Supporting Files/Info.plist b/Stats/Supporting Files/Info.plist index 7d6a28c0..acc461d3 100755 --- a/Stats/Supporting Files/Info.plist +++ b/Stats/Supporting Files/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.0 + 1.1.0 CFBundleVersion 1 LSApplicationCategoryType diff --git a/Stats/libs/Extensions.swift b/Stats/libs/Extensions.swift index 5967b672..3e05969e 100755 --- a/Stats/libs/Extensions.swift +++ b/Stats/libs/Extensions.swift @@ -48,6 +48,9 @@ extension Float { } return NSColor.systemOrange case 0.4...1: + if self == 1 { + return NSColor.controlTextColor + } if !colors.value { return NSColor.controlTextColor } diff --git a/resources/widgets.psd b/resources/widgets.psd index 54c0cf7e..2caaf1b1 100644 Binary files a/resources/widgets.psd and b/resources/widgets.psd differ