Skip to content

Commit f89482d

Browse files
committed
Merge branch 'release/1.2.2'
2 parents d666ea6 + e19ae3d commit f89482d

File tree

21 files changed

+1518
-116
lines changed

21 files changed

+1518
-116
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ macOS app for rating music in iTunes/Music.app
1212
[https://github.com/MainasuK/Song-Rating/releases](https://github.com/MainasuK/Song-Rating/releases)
1313

1414
## FAQ
15-
Coming soon
15+
### How can I check the track rating in iTunes/Music.app?
16+
Check the checkbox for "Star Ratings" in General preferences. [More info](https://support.apple.com/guide/music/general-preferences-mus4130f48/mac)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// AppDelegate.swift
3+
// Song Rating Helper
4+
//
5+
// Created by Cirno MainasuK on 2019-10-26.
6+
// Copyright © 2019 Cirno MainasuK. All rights reserved.
7+
//
8+
9+
import Cocoa
10+
import os
11+
12+
// Ref: https://developer.apple.com/library/archive/documentation/Security/Conceptual/AppSandboxDesignGuide/DesigningYourSandbox/DesigningYourSandbox.html#//apple_ref/doc/uid/TP40011183-CH4-SW3
13+
// https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLoginItems.html#//apple_ref/doc/uid/10000172i-SW5-SW1
14+
// https://products.delitestudio.com/start-dockless-apps-at-login-with-app-sandbox-enabled/
15+
16+
@NSApplicationMain
17+
class AppDelegate: NSObject, NSApplicationDelegate {
18+
19+
func applicationDidFinishLaunching(_ aNotification: Notification) {
20+
21+
let mainAppIdentifier = "com.mainasuk.Song-Rating"
22+
let runningApps = NSWorkspace.shared.runningApplications
23+
let isRunning = runningApps.contains(where: { $0.bundleIdentifier == mainAppIdentifier })
24+
25+
guard !isRunning else {
26+
os_log("%{public}s[%{public}ld], %{public}s: Main app isRunning. Helper exit", ((#file as NSString).lastPathComponent), #line, #function)
27+
terminate()
28+
return
29+
}
30+
31+
DistributedNotificationCenter.default().addObserver(self, selector: #selector(AppDelegate.terminate), name: .killLauncher, object: mainAppIdentifier)
32+
33+
let path = Bundle.main.bundlePath as NSString
34+
var components = path.pathComponents
35+
components.removeLast()
36+
components.removeLast()
37+
components.removeLast()
38+
components.append("MacOS")
39+
components.append("Song Rating")
40+
41+
let newPath = NSString.path(withComponents: components)
42+
43+
os_log("%{public}s[%{public}ld], %{public}s: launch %{public}s", ((#file as NSString).lastPathComponent), #line, #function, newPath)
44+
NSWorkspace.shared.launchApplication(newPath)
45+
}
46+
47+
}
48+
49+
extension AppDelegate {
50+
51+
@objc private func terminate() {
52+
// os_log("%{public}s[%{public}ld], %{public}s: exit", ((#file as NSString).lastPathComponent), #line, #function)
53+
NSApp.terminate(nil)
54+
}
55+
56+
}
57+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "mac",
5+
"size" : "16x16",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "mac",
10+
"size" : "16x16",
11+
"scale" : "2x"
12+
},
13+
{
14+
"idiom" : "mac",
15+
"size" : "32x32",
16+
"scale" : "1x"
17+
},
18+
{
19+
"idiom" : "mac",
20+
"size" : "32x32",
21+
"scale" : "2x"
22+
},
23+
{
24+
"idiom" : "mac",
25+
"size" : "128x128",
26+
"scale" : "1x"
27+
},
28+
{
29+
"idiom" : "mac",
30+
"size" : "128x128",
31+
"scale" : "2x"
32+
},
33+
{
34+
"idiom" : "mac",
35+
"size" : "256x256",
36+
"scale" : "1x"
37+
},
38+
{
39+
"idiom" : "mac",
40+
"size" : "256x256",
41+
"scale" : "2x"
42+
},
43+
{
44+
"idiom" : "mac",
45+
"size" : "512x512",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "mac",
50+
"size" : "512x512",
51+
"scale" : "2x"
52+
}
53+
],
54+
"info" : {
55+
"version" : 1,
56+
"author" : "xcode"
57+
}
58+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

Song Rating Helper/Base.lproj/Main.storyboard

Lines changed: 684 additions & 0 deletions
Large diffs are not rendered by default.

Song Rating Helper/Info.plist

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIconFile</key>
10+
<string></string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>$(MARKETING_VERSION)</string>
21+
<key>CFBundleVersion</key>
22+
<string>1</string>
23+
<key>LSApplicationCategoryType</key>
24+
<string>public.app-category.utilities</string>
25+
<key>LSBackgroundOnly</key>
26+
<true/>
27+
<key>LSMinimumSystemVersion</key>
28+
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
29+
<key>NSHumanReadableCopyright</key>
30+
<string>Copyright © 2019 Cirno MainasuK. All rights reserved.</string>
31+
<key>NSMainStoryboardFile</key>
32+
<string>Main</string>
33+
<key>NSPrincipalClass</key>
34+
<string>NSApplication</string>
35+
<key>NSSupportsAutomaticTermination</key>
36+
<true/>
37+
<key>NSSupportsSuddenTermination</key>
38+
<true/>
39+
</dict>
40+
</plist>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// NotificationName.swift
3+
// Song Rating
4+
//
5+
// Created by Cirno MainasuK on 2019-10-26.
6+
// Copyright © 2019 Cirno MainasuK. All rights reserved.
7+
//
8+
9+
import Cocoa
10+
11+
extension Notification.Name {
12+
static let killLauncher = Notification.Name("killLauncher")
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.files.user-selected.read-only</key>
8+
<true/>
9+
</dict>
10+
</plist>

0 commit comments

Comments
 (0)