Skip to content

Commit c16bea5

Browse files
committed
prompt to move to applications folder
1 parent ecb4319 commit c16bea5

2 files changed

Lines changed: 110 additions & 2 deletions

File tree

boringNotch/Localizable.xcstrings

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3211,6 +3211,10 @@
32113211
},
32123212
"Brightness" : {
32133213

3214+
},
3215+
"Brightness Source" : {
3216+
"comment" : "A label for the picker that selects the brightness control source.",
3217+
"isCommentAutoGenerated" : true
32143218
},
32153219
"Calendar" : {
32163220
"localizations" : {
@@ -7425,6 +7429,10 @@
74257429
}
74267430
}
74277431
},
7432+
"Enable gradient" : {
7433+
"comment" : "A label for enabling or disabling the gradient effect on the OSD.",
7434+
"isCommentAutoGenerated" : true
7435+
},
74287436
"Enable haptic feedback" : {
74297437
"localizations" : {
74307438
"ar" : {
@@ -10344,6 +10352,10 @@
1034410352
},
1034510353
"Interaction" : {
1034610354

10355+
},
10356+
"Keyboard Source" : {
10357+
"comment" : "A label for the keyboard brightness control source in the OSD settings.",
10358+
"isCommentAutoGenerated" : true
1034710359
},
1034810360
"Launch at login" : {
1034910361

@@ -13562,6 +13574,10 @@
1356213574
}
1356313575
}
1356413576
},
13577+
"Now Playing" : {
13578+
"comment" : "Name of the media controller type that represents the \"Now Playing\" option.",
13579+
"isCommentAutoGenerated" : true
13580+
},
1356513581
"Open Calendar Settings" : {
1356613582
"localizations" : {
1356713583
"ar" : {
@@ -14063,6 +14079,10 @@
1406314079
}
1406414080
}
1406514081
},
14082+
"Option (⌥) Key Behavior" : {
14083+
"comment" : "A label for the option key behavior setting in the OS",
14084+
"isCommentAutoGenerated" : true
14085+
},
1406614086
"Option key behaviour" : {
1406714087
"extractionState" : "stale",
1406814088
"localizations" : {
@@ -15518,6 +15538,10 @@
1551815538
}
1551915539
}
1552015540
},
15541+
"Replace System OSD" : {
15542+
"comment" : "A toggle that allows the user to enable or disable replacing the system-provided",
15543+
"isCommentAutoGenerated" : true
15544+
},
1552115545
"Request Accessibility" : {
1552215546
"extractionState" : "stale",
1552315547
"localizations" : {
@@ -17543,6 +17567,10 @@
1754317567
}
1754417568
}
1754517569
},
17570+
"Show OSD in open notch" : {
17571+
"comment" : "A toggle that lets the user decide whether to show the OSD",
17572+
"isCommentAutoGenerated" : true
17573+
},
1754617574
"Show percentage" : {
1754717575
"extractionState" : "stale",
1754817576
"localizations" : {
@@ -17644,6 +17672,14 @@
1764417672
}
1764517673
}
1764617674
},
17675+
"Show percentage (closed notch)" : {
17676+
"comment" : "A toggle that enables or disables displaying the percentage of the screen that",
17677+
"isCommentAutoGenerated" : true
17678+
},
17679+
"Show percentage (open notch)" : {
17680+
"comment" : "A toggle that enables or disables displaying the percentage of the screen that",
17681+
"isCommentAutoGenerated" : true
17682+
},
1764717683
"Show power status icons" : {
1764817684
"localizations" : {
1764917685
"ar" : {
@@ -17944,6 +17980,10 @@
1794417980
}
1794517981
}
1794617982
},
17983+
"Show shadow" : {
17984+
"comment" : "A toggle to show or hide the shadow of the system event indicator.",
17985+
"isCommentAutoGenerated" : true
17986+
},
1794717987
"Show sneak peek on playback changes" : {
1794817988
"localizations" : {
1794917989
"ar" : {
@@ -19903,6 +19943,14 @@
1990319943
}
1990419944
}
1990519945
},
19946+
"Use accent color" : {
19947+
"comment" : "A toggle that lets the user choose whether the system event indicator should use the accent",
19948+
"isCommentAutoGenerated" : true
19949+
},
19950+
"Use inline style" : {
19951+
"comment" : "A toggle that lets the user choose whether to use the inline style for the OS",
19952+
"isCommentAutoGenerated" : true
19953+
},
1990619954
"Use your macOS system accent color" : {
1990719955
"localizations" : {
1990819956
"ar" : {
@@ -20408,6 +20456,10 @@
2040820456
},
2040920457
"Volume" : {
2041020458

20459+
},
20460+
"Volume Source" : {
20461+
"comment" : "A caption displayed underneath the picker for the volume source in the OSD settings.",
20462+
"isCommentAutoGenerated" : true
2041120463
},
2041220464
"Welcome" : {
2041320465
"localizations" : {
@@ -21110,5 +21162,5 @@
2111021162
}
2111121163
}
2111221164
},
21113-
"version" : "1.0"
21165+
"version" : "1.1"
2111421166
}

boringNotch/boringNotchApp.swift

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
441441
}
442442

443443
setupDragDetectors()
444+
445+
checkForApplicationsFolder() // added check call here
444446

445447
if coordinator.firstLaunch {
446448
DispatchQueue.main.async {
@@ -626,4 +628,58 @@ class AppDelegate: NSObject, NSApplicationDelegate {
626628
onboardingWindowController?.window?.makeKeyAndOrderFront(nil)
627629
onboardingWindowController?.window?.orderFrontRegardless()
628630
}
629-
}
631+
632+
private func checkForApplicationsFolder() {
633+
// Define Application folders paths
634+
let systemAppsPath = "/Applications"
635+
let userAppsPath = NSHomeDirectory() + "/Applications"
636+
637+
// Get path of executable
638+
let appPath = Bundle.main.bundlePath
639+
640+
// Check if the app is already in either Applications folder
641+
if !appPath.hasPrefix(systemAppsPath) && !appPath.hasPrefix(userAppsPath) {
642+
643+
// Alert move is recommended
644+
let alertMove = NSAlert()
645+
alertMove.messageText = "Move to Applications folder?"
646+
alertMove.informativeText = "Boring Notch works best when run from your Applications folder. Would you like to move it there now?"
647+
alertMove.alertStyle = .informational
648+
alertMove.addButton(withTitle: "Move")
649+
alertMove.addButton(withTitle: "Keep in Place")
650+
651+
// Move application if selected
652+
if alertMove.runModal() == .alertFirstButtonReturn {
653+
moveSelfToApplications(appPath: appPath)
654+
}
655+
}
656+
}
657+
658+
private func moveSelfToApplications(appPath: String) {
659+
// Retrieve app name at runtime
660+
let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String
661+
?? Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String
662+
?? "BoringNotch" // Default to BoringNotch if no name was found
663+
664+
// Run script to move application and relaunch
665+
let scripts = """
666+
tell application "Finder"
667+
set appPath to POSIX file "\(appPath)" as alias
668+
set targetPath to POSIX file "/Applications" as alias
669+
move appPath to targetPath with replacing
670+
end tell
671+
tell application "\(appName)" to activate
672+
"""
673+
674+
// Error handling
675+
var error: NSDictionary?
676+
if let scriptObject = NSAppleScript(source: scripts) {
677+
scriptObject.executeAndReturnError(&error)
678+
}
679+
680+
if error != nil {
681+
// Handle error if script fails
682+
print("Error moving app: \(String(describing: error))")
683+
}
684+
}
685+
}

0 commit comments

Comments
 (0)