summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xTOOLS/osxbundle.py6
-rw-r--r--TOOLS/osxbundle/mpv.app/Contents/Info.plist2
-rwxr-xr-xTOOLS/osxbundle/mpv.app/Contents/MacOS/mpv-wrapper.sh13
-rw-r--r--TOOLS/osxbundle/mpv.app/Contents/Resources/mpv.conf1
-rw-r--r--osdep/macosx_application.m25
-rw-r--r--osdep/path-macosx.m2
6 files changed, 29 insertions, 20 deletions
diff --git a/TOOLS/osxbundle.py b/TOOLS/osxbundle.py
index e9ef8bc4de..ba0efd9e7e 100755
--- a/TOOLS/osxbundle.py
+++ b/TOOLS/osxbundle.py
@@ -39,6 +39,10 @@ def apply_plist_template(plist_file, version):
for line in fileinput.input(plist_file, inplace=1):
print (line.rstrip().replace('${VERSION}', version))
+def create_bundle_symlink(binary_name, symlink_name):
+ os.symlink(os.path.basename(binary_name),
+ os.path.join(target_directory(binary_name), symlink_name))
+
def bundle_version():
if os.path.exists('VERSION'):
x = open('VERSION')
@@ -69,6 +73,8 @@ def main():
copy_bundle(binary_name)
print("> copying binary")
copy_binary(binary_name)
+ print("> create bundle symlink")
+ create_bundle_symlink(binary_name, "mpv-bundle")
print("> generating Info.plist")
apply_plist_template(target_plist(binary_name), version)
diff --git a/TOOLS/osxbundle/mpv.app/Contents/Info.plist b/TOOLS/osxbundle/mpv.app/Contents/Info.plist
index 11e34c4548..89ff4bf6ad 100644
--- a/TOOLS/osxbundle/mpv.app/Contents/Info.plist
+++ b/TOOLS/osxbundle/mpv.app/Contents/Info.plist
@@ -173,7 +173,7 @@
</dict>
</array>
<key>CFBundleExecutable</key>
- <string>mpv-wrapper.sh</string>
+ <string>mpv-bundle</string>
<key>CFBundleIconFile</key>
<string>icon</string>
<key>CFBundleIdentifier</key>
diff --git a/TOOLS/osxbundle/mpv.app/Contents/MacOS/mpv-wrapper.sh b/TOOLS/osxbundle/mpv.app/Contents/MacOS/mpv-wrapper.sh
deleted file mode 100755
index f84c27a6e2..0000000000
--- a/TOOLS/osxbundle/mpv.app/Contents/MacOS/mpv-wrapper.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-export MPVBUNDLE="true"
-
-# set the right args for the user specified standard shell
-# to load the expected profiles and configs
-args="-c"
-case "$SHELL" in
- *bash) args="-l $args";;
- *zsh) args="-l -i $args";;
-esac
-
-cd "$(dirname "$0")"
-$SHELL $args "./mpv --player-operation-mode=pseudo-gui"
diff --git a/TOOLS/osxbundle/mpv.app/Contents/Resources/mpv.conf b/TOOLS/osxbundle/mpv.app/Contents/Resources/mpv.conf
new file mode 100644
index 0000000000..bdffa7a951
--- /dev/null
+++ b/TOOLS/osxbundle/mpv.app/Contents/Resources/mpv.conf
@@ -0,0 +1 @@
+player-operation-mode=pseudo-gui
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m
index 0379491d79..b42cba5c37 100644
--- a/osdep/macosx_application.m
+++ b/osdep/macosx_application.m
@@ -242,12 +242,26 @@ static void macosx_redirect_output_to_logfile(const char *filename)
[pool release];
}
-static bool bundle_started_from_finder()
+static bool bundle_started_from_finder(char **argv)
{
- NSDictionary *env = [[NSProcessInfo processInfo] environment];
- NSString *is_bundle = [env objectForKey:@"MPVBUNDLE"];
+ NSString *binary_path = [NSString stringWithUTF8String:argv[0]];
+ return [binary_path hasSuffix:@"mpv-bundle"];
+}
+
+static bool is_psn_argument(char *arg_to_check)
+{
+ NSString *arg = [NSString stringWithUTF8String:arg_to_check];
+ return [arg hasPrefix:@"-psn_"];
+}
+
+static void setup_bundle(int *argc, char *argv[])
+{
+ if (*argc > 1 && is_psn_argument(argv[1])) {
+ *argc = 1;
+ argv[1] = NULL;
+ }
- return is_bundle ? [is_bundle boolValue] : false;
+ setenv("MPVBUNDLE", "true", 1);
}
int cocoa_main(int argc, char *argv[])
@@ -260,7 +274,8 @@ int cocoa_main(int argc, char *argv[])
ctx.argc = &argc;
ctx.argv = &argv;
- if (bundle_started_from_finder()) {
+ if (bundle_started_from_finder(argv)) {
+ setup_bundle(&argc, argv);
macosx_redirect_output_to_logfile("mpv");
init_cocoa_application(true);
} else {
diff --git a/osdep/path-macosx.m b/osdep/path-macosx.m
index 73abb0d305..8a5a704e49 100644
--- a/osdep/path-macosx.m
+++ b/osdep/path-macosx.m
@@ -21,7 +21,7 @@
const char *mp_get_platform_path_osx(void *talloc_ctx, const char *type)
{
- if (strcmp(type, "osxbundle") == 0) {
+ if (strcmp(type, "osxbundle") == 0 && getenv("MPVBUNDLE")) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *path = [[NSBundle mainBundle] resourcePath];
char *res = talloc_strdup(talloc_ctx, [path UTF8String]);