答案1
这是一个简短的 Python 程序:
#!/usr/bin/env python3
from gi.repository import Gio
import sys
if len(sys.argv) != 2:
print('Error: Exactly one command line argument needed')
sys.exit(1)
for app in Gio.app_info_get_all_for_type(sys.argv[1]):
print(app.get_id())
将其保存在文件中,例如/usr/local/bin/mimeapps
。然后你可以像这样使用它
$ mimeapps text/plain
emacs.desktop
libreoffice-writer.desktop
pluma.desktop
vim.desktop