在 Mac 终端上查找 "reminder.app" 的路径(非英语本地化)

Finding path to "reminder.app" on Mac terminal (non-English localization)

我在 Big Sur 11.2.2 上使用 Macbook Air,语言设置为日语。

我试图在 Python 3.8.5 上使用 subprocess.Popen( ) 启动“reminder.app”。互动 shell。但是我无法启动 Reminders.app 即使我使用指定的日文应用程序名称(以及 Calculator.app 、 Dictionary.app 和许多其他以日文应用程序名称显示的名称)。但是我可以启动我安装的应用程序。

>>> import subprocess
>>> subprocess.Popen(['open', '/Applications/Reminders.app/'])
<subprocess.Popen object at 0x7ffa8e233e80>
The file /Applications/Reminders.app does not exist.

>>> subprocess.Popen(['open', '/Applications/リマインダー.app/']) # Japanese name of app
<subprocess.Popen object at 0x7ffa8e233d60>
The file /Applications/リマインダー.app does not exist.

subpsubprocess.Popen(['open', '/Applications/Safari.app/'])
<subprocess.Popen object at 0x7ffa8e233bb0>
# success!

我已经使用 Finder 进行了检查,我要查找的所有应用程序都显示在 GUI 界面中,尽管给出的是日文名称。但是,即使使用 ls -a.

,也无法在终端命令行上找到或操作这些应用程序

如何找到提醒应用程序的路径,以便与 subprocess.Popen() 一起使用?

会不会因为我使用的是非英文系统语言,所以不能这样做?

使用此命令:

find / -xdev -name Reminders.app 2> /dev/null

您会发现:/System/Applications/Reminders.app

如果你想启动它,而不是仅仅找到它,你可以试试这个命令行:

osascript -e 'tell application "Reminders" to activate'

不知道能不能用日文名字代替,但值得一试。所以从 Python:

import os
os.system('osascript -e \'tell application \"Reminders\" to activate\'')

import subprocess
subprocess.Popen(['/usr/bin/osascript', '-e', 'tell application \"Reminders\" to activate'])

osascript 命令基本上是 运行 单引号中的小 AppleScript。我没有尝试做任何更复杂的事情,但我认为,作为一个 Apple 程序,它支持各种 AppleEvents,因此您可以做一些很酷的事情,比如使用 Python 代码中的 AppleScript 实际安排提醒。