added backgrounder.swift

more stuff
and stuff

tried to add background location tracking
 - it didnt work
This commit is contained in:
neon443
2025-08-24 20:38:12 +01:00
parent d40ef8e03c
commit a7783eab47
5 changed files with 84 additions and 5 deletions

View File

@@ -42,6 +42,7 @@
A9485C732E1AECD000209824 /* JetBrainsMonoNerdFontMono-BoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A9485C6F2E1AECD000209824 /* JetBrainsMonoNerdFontMono-BoldItalic.ttf */; }; A9485C732E1AECD000209824 /* JetBrainsMonoNerdFontMono-BoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A9485C6F2E1AECD000209824 /* JetBrainsMonoNerdFontMono-BoldItalic.ttf */; };
A9485C762E1AF59F00209824 /* FontManagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9485C752E1AF59F00209824 /* FontManagerView.swift */; }; A9485C762E1AF59F00209824 /* FontManagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9485C752E1AF59F00209824 /* FontManagerView.swift */; };
A9485C782E1BFA5000209824 /* ThemeEditorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9485C772E1BFA5000209824 /* ThemeEditorView.swift */; }; A9485C782E1BFA5000209824 /* ThemeEditorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9485C772E1BFA5000209824 /* ThemeEditorView.swift */; };
A94B832F2E5B929C00EBA09C /* Backgrounder.swift in Sources */ = {isa = PBXBuildFile; fileRef = A94B832E2E5B929C00EBA09C /* Backgrounder.swift */; };
A95FAA472DF3884B00DE2F5A /* Config.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = A95FAA462DF3884B00DE2F5A /* Config.xcconfig */; }; A95FAA472DF3884B00DE2F5A /* Config.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = A95FAA462DF3884B00DE2F5A /* Config.xcconfig */; };
A95FAA542DF4B62900DE2F5A /* LibSSH.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A95FAA502DF4B62100DE2F5A /* LibSSH.xcframework */; }; A95FAA542DF4B62900DE2F5A /* LibSSH.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A95FAA502DF4B62100DE2F5A /* LibSSH.xcframework */; };
A95FAA552DF4B62900DE2F5A /* LibSSH.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = A95FAA502DF4B62100DE2F5A /* LibSSH.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; A95FAA552DF4B62900DE2F5A /* LibSSH.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = A95FAA502DF4B62100DE2F5A /* LibSSH.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -178,6 +179,7 @@
A9485C702E1AECD000209824 /* JetBrainsMonoNerdFontMono-Italic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "JetBrainsMonoNerdFontMono-Italic.ttf"; sourceTree = "<group>"; }; A9485C702E1AECD000209824 /* JetBrainsMonoNerdFontMono-Italic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "JetBrainsMonoNerdFontMono-Italic.ttf"; sourceTree = "<group>"; };
A9485C752E1AF59F00209824 /* FontManagerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontManagerView.swift; sourceTree = "<group>"; }; A9485C752E1AF59F00209824 /* FontManagerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontManagerView.swift; sourceTree = "<group>"; };
A9485C772E1BFA5000209824 /* ThemeEditorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeEditorView.swift; sourceTree = "<group>"; }; A9485C772E1BFA5000209824 /* ThemeEditorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeEditorView.swift; sourceTree = "<group>"; };
A94B832E2E5B929C00EBA09C /* Backgrounder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Backgrounder.swift; sourceTree = "<group>"; };
A95FAA462DF3884B00DE2F5A /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = SOURCE_ROOT; }; A95FAA462DF3884B00DE2F5A /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = SOURCE_ROOT; };
A95FAA502DF4B62100DE2F5A /* LibSSH.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = LibSSH.xcframework; path = Frameworks/LibSSH.xcframework; sourceTree = "<group>"; }; A95FAA502DF4B62100DE2F5A /* LibSSH.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = LibSSH.xcframework; path = Frameworks/LibSSH.xcframework; sourceTree = "<group>"; };
A95FAA512DF4B62100DE2F5A /* openssl.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = openssl.xcframework; path = Frameworks/openssl.xcframework; sourceTree = "<group>"; }; A95FAA512DF4B62100DE2F5A /* openssl.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = openssl.xcframework; path = Frameworks/openssl.xcframework; sourceTree = "<group>"; };
@@ -593,6 +595,7 @@
children = ( children = (
A9C060EA2E357FD300CA9374 /* Haptics.swift */, A9C060EA2E357FD300CA9374 /* Haptics.swift */,
A90B38332E3EA046002B56FC /* Bundle.swift */, A90B38332E3EA046002B56FC /* Bundle.swift */,
A94B832E2E5B929C00EBA09C /* Backgrounder.swift */,
); );
path = Misc; path = Misc;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -869,6 +872,7 @@
A923172D2E07138000ECE1E6 /* SSHTerminalDelegate.swift in Sources */, A923172D2E07138000ECE1E6 /* SSHTerminalDelegate.swift in Sources */,
A90936882E1AC51100856059 /* Fonts.swift in Sources */, A90936882E1AC51100856059 /* Fonts.swift in Sources */,
A9FD37552E143D23005319A8 /* SecKeyConvertible.swift in Sources */, A9FD37552E143D23005319A8 /* SecKeyConvertible.swift in Sources */,
A94B832F2E5B929C00EBA09C /* Backgrounder.swift in Sources */,
A96C6AFE2E0C43B600F377FE /* Keypair.swift in Sources */, A96C6AFE2E0C43B600F377FE /* Keypair.swift in Sources */,
A90B38322E3E8FC9002B56FC /* AboutView.swift in Sources */, A90B38322E3E8FC9002B56FC /* AboutView.swift in Sources */,
A9C4140C2E096DB7005E3047 /* SSHError.swift in Sources */, A9C4140C2E096DB7005E3047 /* SSHError.swift in Sources */,
@@ -1052,6 +1056,10 @@
INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO;
INFOPLIST_KEY_NSFaceIDUsageDescription = "ShhShell uses Face ID to verify your identity"; INFOPLIST_KEY_NSFaceIDUsageDescription = "ShhShell uses Face ID to verify your identity";
INFOPLIST_KEY_NSLocalNetworkUsageDescription = "Needed to communicate with SSH Servers"; INFOPLIST_KEY_NSLocalNetworkUsageDescription = "Needed to communicate with SSH Servers";
INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "Required to keep SSH connections alive, if enabled";
INFOPLIST_KEY_NSLocationAlwaysUsageDescription = "Required to keep SSH connections alive, if enabled";
INFOPLIST_KEY_NSLocationUsageDescription = "Required to keep SSH connections alive, if enabled";
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Required to keep SSH connections alive, if enabled";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES;
@@ -1092,6 +1100,10 @@
INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO;
INFOPLIST_KEY_NSFaceIDUsageDescription = "ShhShell uses Face ID to verify your identity"; INFOPLIST_KEY_NSFaceIDUsageDescription = "ShhShell uses Face ID to verify your identity";
INFOPLIST_KEY_NSLocalNetworkUsageDescription = "Needed to communicate with SSH Servers"; INFOPLIST_KEY_NSLocalNetworkUsageDescription = "Needed to communicate with SSH Servers";
INFOPLIST_KEY_NSLocationAlwaysAndWhenInUseUsageDescription = "Required to keep SSH connections alive, if enabled";
INFOPLIST_KEY_NSLocationAlwaysUsageDescription = "Required to keep SSH connections alive, if enabled";
INFOPLIST_KEY_NSLocationUsageDescription = "Required to keep SSH connections alive, if enabled";
INFOPLIST_KEY_NSLocationWhenInUseUsageDescription = "Required to keep SSH connections alive, if enabled";
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES;

View File

@@ -0,0 +1,58 @@
//
// Backgrounder.swift
// ShhShell
//
// Created by neon443 on 24/08/2025.
//
import Foundation
import CoreLocation
class Backgrounder: NSObject, CLLocationManagerDelegate, ObservableObject {
private let manager = CLLocationManager()
@MainActor
static var shared: Backgrounder = Backgrounder()
override init() {
super.init()
manager.delegate = self
if checkPermsStatus() {
manager.allowsBackgroundLocationUpdates = true
}
}
func startBgTracking() {
manager.allowsBackgroundLocationUpdates = true
manager.pausesLocationUpdatesAutomatically = false
manager.startMonitoringSignificantLocationChanges()
print("started tgracking")
}
func stopBgTracking() {
manager.stopUpdatingLocation()
manager.allowsBackgroundLocationUpdates = false
print("stopped tracking")
}
func requestPerms() {
manager.requestAlwaysAuthorization()
}
func checkPermsStatus() -> Bool {
let status = manager.authorizationStatus
switch status {
case .authorized, .notDetermined, .restricted, .denied, .authorizedWhenInUse:
return false
case .authorizedAlways:
return true
default:
return false
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print("tracking started yay")
}
}

View File

@@ -101,8 +101,6 @@ struct ConnectionView: View {
Button(role: .destructive) { Button(role: .destructive) {
handler.host.key = handler.getHostkey() handler.host.key = handler.getHostkey()
handler.disconnect() handler.disconnect()
// handler.go()
// showTerminal = checkShell(handler.state)
} label: { } label: {
Text("Accept Hostkey") Text("Accept Hostkey")
} }

View File

@@ -48,8 +48,8 @@ struct SettingsView: View {
} }
Slider( Slider(
value: $hostsManager.settings.scrollback, value: $hostsManager.settings.scrollback,
in: 100...10_000, in: 250...10_000,
step: 100 step: 250
) )
} }
} }
@@ -77,7 +77,7 @@ struct SettingsView: View {
.frame(width: 4, height: 40) .frame(width: 4, height: 40)
case .underline: case .underline:
Rectangle() Rectangle()
.frame(width: 25, height: 4) .frame(width: 20, height: 4)
.padding(.top, 36) .padding(.top, 36)
} }
} }
@@ -111,6 +111,11 @@ struct SettingsView: View {
} }
Toggle("location persistence", systemImage: "location.fill", isOn: $hostsManager.settings.locationPersist) Toggle("location persistence", systemImage: "location.fill", isOn: $hostsManager.settings.locationPersist)
.onChange(of: hostsManager.settings.locationPersist) { _ in
if hostsManager.settings.locationPersist && !Backgrounder.shared.checkPermsStatus() {
Backgrounder.shared.requestPerms()
}
}
Toggle("bell sound", systemImage: "bell.and.waves.left.and.right", isOn: $hostsManager.settings.bellSound) Toggle("bell sound", systemImage: "bell.and.waves.left.and.right", isOn: $hostsManager.settings.bellSound)
Toggle("bell haptic",systemImage: "iphone.radiowaves.left.and.right", isOn: $hostsManager.settings.bellHaptic) Toggle("bell haptic",systemImage: "iphone.radiowaves.left.and.right", isOn: $hostsManager.settings.bellHaptic)

View File

@@ -151,6 +151,9 @@ struct ShellTabView: View {
.frame(height: 30) .frame(height: 30)
.onDisappear { .onDisappear {
UIApplication.shared.isIdleTimerDisabled = false UIApplication.shared.isIdleTimerDisabled = false
if container.sessions.isEmpty {
Backgrounder.shared.stopBgTracking()
}
} }
.onAppear { .onAppear {
if selectedID == nil { if selectedID == nil {
@@ -161,6 +164,9 @@ struct ShellTabView: View {
} }
} }
UIApplication.shared.isIdleTimerDisabled = hostsManager.settings.caffeinate UIApplication.shared.isIdleTimerDisabled = hostsManager.settings.caffeinate
if hostsManager.settings.locationPersist {
Backgrounder.shared.startBgTracking()
}
} }
} }