Skip to content

Commit 73b0e26

Browse files
committed
Add launch at login setting
1 parent c28c7ab commit 73b0e26

File tree

5 files changed

+54
-8
lines changed

5 files changed

+54
-8
lines changed

IsThereNet.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
CODE_SIGN_ENTITLEMENTS = IsThereNet/IsThereNet.entitlements;
313313
CODE_SIGN_STYLE = Automatic;
314314
COMBINE_HIDPI_IMAGES = YES;
315-
CURRENT_PROJECT_VERSION = 1.6.2;
315+
CURRENT_PROJECT_VERSION = 1.7.0;
316316
DEAD_CODE_STRIPPING = YES;
317317
DEVELOPMENT_ASSET_PATHS = "\"IsThereNet/Preview Content\"";
318318
DEVELOPMENT_TEAM = RDDXV84A73;
@@ -330,7 +330,7 @@
330330
"@executable_path/../Frameworks",
331331
);
332332
MACOSX_DEPLOYMENT_TARGET = 11.0;
333-
MARKETING_VERSION = 1.6.2;
333+
MARKETING_VERSION = 1.7.0;
334334
PRODUCT_BUNDLE_IDENTIFIER = com.lowtechguys.IsThereNet;
335335
PRODUCT_NAME = "$(TARGET_NAME)";
336336
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -346,7 +346,7 @@
346346
CODE_SIGN_ENTITLEMENTS = IsThereNet/IsThereNet.entitlements;
347347
CODE_SIGN_STYLE = Automatic;
348348
COMBINE_HIDPI_IMAGES = YES;
349-
CURRENT_PROJECT_VERSION = 1.6.2;
349+
CURRENT_PROJECT_VERSION = 1.7.0;
350350
DEAD_CODE_STRIPPING = YES;
351351
DEVELOPMENT_ASSET_PATHS = "\"IsThereNet/Preview Content\"";
352352
DEVELOPMENT_TEAM = RDDXV84A73;
@@ -364,7 +364,7 @@
364364
"@executable_path/../Frameworks",
365365
);
366366
MACOSX_DEPLOYMENT_TARGET = 11.0;
367-
MARKETING_VERSION = 1.6.2;
367+
MARKETING_VERSION = 1.7.0;
368368
PRODUCT_BUNDLE_IDENTIFIER = com.lowtechguys.IsThereNet;
369369
PRODUCT_NAME = "$(TARGET_NAME)";
370370
SWIFT_EMIT_LOC_STRINGS = YES;

IsThereNet/IsThereNetApp.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,18 @@ private func log(_ message: String) {
275275
monitor!.start(queue: DispatchQueue.global())
276276

277277
#if !DEBUG
278-
if #available(macOS 13, *), SMAppService.mainApp.status == .notRegistered || SMAppService.mainApp.status == .notFound {
278+
setupLaunchAtLogin()
279+
#endif
280+
}
281+
282+
func setupLaunchAtLogin() {
283+
if #available(macOS 13, *) {
284+
if CONFIG.launchAtLogin ?? true, SMAppService.mainApp.status == .notRegistered || SMAppService.mainApp.status == .notFound {
279285
try? SMAppService.mainApp.register()
286+
} else if !(CONFIG.launchAtLogin ?? true), SMAppService.mainApp.status == .enabled {
287+
try? SMAppService.mainApp.unregister()
280288
}
281-
#endif
289+
}
282290
}
283291

284292
func startPingMonitor() {
@@ -385,13 +393,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
385393

386394
@main
387395
struct IsThereNetApp: App {
388-
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
389-
390396
init() {
391397
updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
392398
start()
393399
}
394400

401+
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
402+
395403
var body: some Scene { Settings { EmptyView() }}
396404

397405
private let updaterController: SPUStandardUpdaterController
@@ -506,6 +514,7 @@ private struct Config: Codable, Equatable {
506514
var sounds: SoundsConfig? = SoundsConfig()
507515
var colors: ColorsConfig? = ColorsConfig()
508516
var screen: String? = "all"
517+
var launchAtLogin: Bool? = true
509518
}
510519

511520
private var CONFIG_FS_WATCHER: FSEventStreamRef?
@@ -553,6 +562,7 @@ private var CONFIG: Config = {
553562
process?.terminate()
554563
process = nil
555564
pingRestartTask = mainAsyncAfter(1) { startPingMonitor() }
565+
setupLaunchAtLogin()
556566
}
557567
},
558568
nil, [CONFIG_PATH.path] as [NSString] as NSArray as CFArray,

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ The config file looks like this:
9999
},
100100
"pingTimeoutSeconds" : 1,
101101
"screen": "all",
102+
"launchAtLogin": true,
102103
"shellCommandOnStatusChange" : "echo 'Status changed to: '$STATUS' with ping time:' $PING_TIME"
103104
}
104105
```

ReleaseNotes/1.7.0.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Launch at login
2+
3+
Now launch at login can be configured through the config file.
4+
5+
The config file is located at:
6+
7+
```sh
8+
~/.config/istherenet/config.json
9+
```
10+
11+
The config now supports a new key `launchAtLogin` which can be set to `true` or `false`:
12+
13+
```json
14+
{
15+
...
16+
"launchAtLogin": false, // default is true
17+
...
18+
}
19+
```

Releases/appcast.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" version="2.0">
33
<channel>
44
<title>IsThereNet</title>
5+
<item>
6+
<title>1.7.0</title>
7+
<pubDate>Mon, 13 Jan 2025 14:39:31 +0200</pubDate>
8+
<link>https://lowtechguys.com/istherenet</link>
9+
<sparkle:fullReleaseNotesLink>https://github.com/FuzzyIdeas/IsThereNet/releases</sparkle:fullReleaseNotesLink>
10+
<sparkle:version>1.7.0</sparkle:version>
11+
<sparkle:shortVersionString>1.7.0</sparkle:shortVersionString>
12+
<sparkle:minimumSystemVersion>11.0</sparkle:minimumSystemVersion>
13+
<sparkle:releaseNotesLink>https://files.lowtechguys.com/ReleaseNotes/IsThereNet-1.7.0.html</sparkle:releaseNotesLink>
14+
<enclosure url="https://files.lowtechguys.com/releases/IsThereNet-1.7.0.dmg" length="2415398" type="application/octet-stream" sparkle:edSignature="q5Vg2ouScBx8F+3A0/x8gmk9+vFFyJ/c6HhegNYLKATWk2ZnOZYXh2xeUjKw53RrjRPO6fHt0GE3ejDg8VSnAg=="/>
15+
<sparkle:deltas>
16+
<enclosure url="https://files.lowtechguys.com/releases/IsThereNet1.7.0-1.6.2.delta" sparkle:deltaFrom="1.6.2" length="28146" type="application/octet-stream" sparkle:deltaFromSparkleExecutableSize="864784" sparkle:deltaFromSparkleLocales="de,he,ar,el,ja,fa,en" sparkle:edSignature="LQvfbxXGJNl1dtOVobMz7QhLQ4M1n9N+ufcm8qZwP+v5HhMcVqX9MLCK1ujrkPk9KHxGkZZrwYPmJhzT8RoiCQ=="/>
17+
<enclosure url="https://files.lowtechguys.com/releases/IsThereNet1.7.0-1.6.1.delta" sparkle:deltaFrom="1.6.1" length="62442" type="application/octet-stream" sparkle:deltaFromSparkleExecutableSize="865040" sparkle:deltaFromSparkleLocales="de,he,ar,el,ja,fa,en" sparkle:edSignature="ebs/xpvwYw7eP5m5yPm4XZAN5lWQTh/8mqPfVqQS7JouiiTJlQi+COvhmCnhRXPjcOSCeZBaUdh0se+N89cfAA=="/>
18+
<enclosure url="https://files.lowtechguys.com/releases/IsThereNet1.7.0-1.6.delta" sparkle:deltaFrom="1.6" length="62122" type="application/octet-stream" sparkle:deltaFromSparkleExecutableSize="865040" sparkle:deltaFromSparkleLocales="de,he,ar,el,ja,fa,en" sparkle:edSignature="D3HEZzDZ5Jyd5p7MIiJxt+wQkh2WY7nXc9bgmsfUVlQAFT9AhL3ONEfIOoRhiOVSyc82AhDfqBT5+71RXhnoDg=="/>
19+
</sparkle:deltas>
20+
</item>
521
<item>
622
<title>1.6.2</title>
723
<pubDate>Sat, 20 Jul 2024 14:05:04 +0300</pubDate>

0 commit comments

Comments
 (0)