Add detection for available macOS applications and add check for Skim.app as alternate PDF viewer.

This commit is contained in:
Stephan Witt 2022-08-08 15:46:57 +02:00
parent a89f2fd08c
commit 4296df9960

View File

@ -357,6 +357,18 @@ def check_java():
return ''
def checkMacOSappInstalled(prog):
'''
Use metadata lookup to search for an "installed" macOS application bundle.
'''
if sys.platform == 'darwin' and len(prog) >= 1:
command = r'mdfind "kMDItemContentTypeTree == \"com.apple.application\"c && kMDItemFSName == \"%s\""' % prog
result = cmdOutput(command)
logger.debug(command + ": " + result)
return result != ''
return False
def checkProgAlternatives(description, progs, rc_entry=None,
alt_rc_entry=None, path=None, not_found=''):
'''
@ -395,6 +407,10 @@ def checkProgAlternatives(description, progs, rc_entry=None,
continue
msg = '+checking for "' + ac_word + '"... '
found_alt = False
if len(alt_rc_entry) >= 1 and ac_word.endswith('.app') and checkMacOSappInstalled(ac_word):
logger.info('+add alternative app ' + ac_word)
addToRC(alt_rc_entry[0].replace('%%', ac_word))
found_alt = True
for ac_dir in path:
if hasattr(os, "access") and not os.access(ac_dir, os.F_OK):
continue
@ -812,7 +828,7 @@ def checkFormatEntries(dtl_tools):
checkViewer('a PDF previewer',
['pdfview', 'kpdf', 'okular', 'qpdfview --unique',
'evince', 'xreader', 'kghostview', 'xpdf', 'SumatraPDF',
'acrobat', 'acroread', 'mupdf',
'acrobat', 'acroread', 'mupdf', 'Skim.app',
'gv', 'ghostview', 'AcroRd32', 'gsview64', 'gsview32'],
rc_entry = [r'''\Format pdf pdf "PDF (ps2pdf)" P "%%" "" "document,vector,menu=export" ""
\Format pdf2 pdf "PDF (pdflatex)" F "%%" "" "document,vector,menu=export" ""