Skip to content

Commit

Permalink
Merge pull request #133 from gao-sun/v1.5
Browse files Browse the repository at this point in the history
v1.5
  • Loading branch information
gao-sun authored Dec 28, 2020
2 parents 0d73213 + 0b9d340 commit ebb5361
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Resource/uk.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
"ui.network" = "Мережа";
"ui.menu_view" = "Вигляд Меню";
"ui.empty" = "Порожньо";
"ui.hidden_by_system.title" = "Компоненти смуги меню "eul" примусово приховані системою";
"ui.hidden_by_system.title" = "Компоненти смуги меню \"eul\" примусово приховані системою";
"ui.hidden_by_system.message" = "Спробуйте зменшити к-сть компонент в налаштуваннях";
"ui.hidden_by_system.open" = "Відкрити Налаштування";
"ui.hidden_by_system.dismiss" = "Відхилити";
Expand Down
40 changes: 20 additions & 20 deletions eul.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@
CODE_SIGN_ENTITLEMENTS = MemoryWidget/MemoryWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 27;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = MemoryWidget/Info.plist;
Expand All @@ -1535,7 +1535,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.8;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.MemoryWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1551,7 +1551,7 @@
CODE_SIGN_ENTITLEMENTS = MemoryWidget/MemoryWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 27;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = MemoryWidget/Info.plist;
Expand All @@ -1561,7 +1561,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.8;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.MemoryWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1577,7 +1577,7 @@
CODE_SIGN_ENTITLEMENTS = NetworkWidget/NetworkWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 27;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = NetworkWidget/Info.plist;
Expand All @@ -1587,7 +1587,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.8;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.NetworkWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1603,7 +1603,7 @@
CODE_SIGN_ENTITLEMENTS = NetworkWidget/NetworkWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 27;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = NetworkWidget/Info.plist;
Expand All @@ -1613,7 +1613,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.8;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.NetworkWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -1748,7 +1748,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 27;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -1760,7 +1760,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.4.8;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
Expand All @@ -1779,7 +1779,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 27;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -1791,7 +1791,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.4.8;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "";
Expand All @@ -1807,7 +1807,7 @@
CODE_SIGN_ENTITLEMENTS = BatteryWidget/BatteryWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 27;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = BatteryWidget/Info.plist;
Expand All @@ -1817,7 +1817,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.8;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.BatteryWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1833,7 +1833,7 @@
CODE_SIGN_ENTITLEMENTS = BatteryWidget/BatteryWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 27;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = BatteryWidget/Info.plist;
Expand All @@ -1843,7 +1843,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.8;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.BatteryWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1859,7 +1859,7 @@
CODE_SIGN_ENTITLEMENTS = CpuWidget/CpuWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 27;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = CpuWidget/Info.plist;
Expand All @@ -1869,7 +1869,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.8;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.CpuWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1885,7 +1885,7 @@
CODE_SIGN_ENTITLEMENTS = CpuWidget/CpuWidget.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 27;
CURRENT_PROJECT_VERSION = 28;
DEVELOPMENT_TEAM = M8G2RFZVFV;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = CpuWidget/Info.plist;
Expand All @@ -1895,7 +1895,7 @@
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.8;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.gaosun.eul.CpuWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand Down
6 changes: 5 additions & 1 deletion eul/StatusBar/StatusBarItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ extension Notification.Name {
}

class StatusBarItem: NSObject, NSMenuDelegate {
static let launchTime = Date()

@ObservedObject var preferenceStore = SharedStore.preference

let config: StatusBarConfig
Expand Down Expand Up @@ -64,8 +66,10 @@ class StatusBarItem: NSObject, NSMenuDelegate {
return
}

// add delay on launch due to potential false alarm
let interval = max(15 + StatusBarItem.launchTime.timeIntervalSinceNow, 1.5)
visibilityTimer?.invalidate()
visibilityTimer = Timer.scheduledTimer(withTimeInterval: 1.5, repeats: false, block: { _ in
visibilityTimer = Timer.scheduledTimer(withTimeInterval: interval, repeats: false, block: { _ in
self.checkStatusItemVisibility()
})
}
Expand Down
2 changes: 1 addition & 1 deletion eul/Store/NetworkTopStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class NetworkTopStore: ObservableObject {
}

private func run() {
guard let string = shell("nettop -L 1 -P -x -J bytes_in,bytes_out -s \(interval)") else {
guard let string = shell("nettop -L 1 -P -x -J bytes_in,bytes_out") else {
print("unable to fetch network activity, please make sure nettop is available")
return
}
Expand Down
17 changes: 13 additions & 4 deletions eul/Utilities/Shell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ func shell(_ args: String...) -> String? {

task.standardOutput = pipe
task.standardError = error
task.launchPath = "/bin/bash"
task.executableURL = URL(fileURLWithPath: "/bin/bash")
task.arguments = ["-c"] + args
task.launch()

do {
try task.run()
} catch {
print("⚠️ shell executed with error", error)
}

let data = pipe.fileHandleForReading.readDataToEndOfFile()
let output = String(data: data, encoding: .utf8)
Expand All @@ -43,7 +48,7 @@ func shellPipe(_ args: String..., onData: ((String) -> Void)? = nil, didTerminat
Print("shell pipe with", args)

task.standardOutput = pipe
task.launchPath = "/bin/bash"
task.executableURL = URL(fileURLWithPath: "/bin/bash")
task.arguments = ["-c"] + args

var buffer = Data()
Expand Down Expand Up @@ -73,7 +78,11 @@ func shellPipe(_ args: String..., onData: ((String) -> Void)? = nil, didTerminat

DispatchQueue(label: "shellPipe-\(UUID().uuidString)", qos: .background, attributes: .concurrent).async {
Print("good to launch")
task.launch()
do {
try task.run()
} catch {
print("⚠️ shell pipe executed with error", error)
}
}

return task
Expand Down
2 changes: 1 addition & 1 deletion eul/Views/Chart/LineChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct LineChart: View {
ZStack {
Group {
closedPath()
.fill(LinearGradient(gradient: Gradient(colors: [.text, Color.text.opacity(0.9)]), startPoint: .bottom, endPoint: .top))
.fill(Color.text)
path()
.stroke(Color.text, style: StrokeStyle(lineWidth: 2, lineJoin: .round))
}
Expand Down

0 comments on commit ebb5361

Please sign in to comment.