Browse Source

Don't hardcode path to LyX app on Mac

Ryan C. Thompson 9 years ago
parent
commit
88907ff7d2
1 changed files with 7 additions and 1 deletions
  1. 7 1
      dodo.py

+ 7 - 1
dodo.py

@@ -15,6 +15,11 @@ DOIT_CONFIG = {
     'default_tasks': ['publish_to_mneme'],
 }
 
+def find_mac_app(name):
+    return check_output(
+        ["mdfind",
+         "kMDItemDisplayName==%s&&kMDItemKind==Application" % (name,) ]).strip()
+
 def glob_recursive(pattern, top=".", include_hidden=False, *args, **kwargs):
     """Combination of glob.glob and os.walk.
 
@@ -29,7 +34,8 @@ os.walk."""
             if fnmatch(f, pattern):
                 yield os.path.normpath(os.path.join(path, f))
 
-LYXPATH = find_executable("lyx") or "/Applications/LyX.app/Contents/MacOS/lyx"
+LYXPATH = find_executable("lyx") or \
+    os.path.join(find_mac_app("LyX"), "Contents/MacOS/lyx")
 
 def task_lyx2pdf():
     yield {