[ Prev ] [ Index ] [ Next ]

Default Applications

Zim opens files and attachments with other applications. Usually clicking on a link will start the appropriate application for your system. And the "Open With..." menu in the context menu (click the right mouse button on the link) gives alternative applications.

If you want to change the default application, or you want to add additional applications to the "Open With..." menu, there is a menu item "Customize..." at the bottom of the popup. This item brings up a dialog that allows changing the default application and adding new applications.

Configure Applications Dialog

The Configure Applications dialog has a drop down menu to choice a default application. Applications zim knows about are shown in this drop down. Also there is a special menu item "System Default" which means to use whatever application is the default used by the operating system.

Note that there may be applications installed that zim does not know about. Setting the default to "System Default" may result in the correct application being used, even if it is not shown in the list.

To add applications to the list (and to the "Open With..." menu) click the button "Add Application", this will bring up the Add New Application dialog.

Add Application Dialog

The Add Application dialog allows to add a new application for a specific file type.

The Name is the application name and Command is the command to execute. Usually this is just the name of an executable or a script to execute. The command can also use the following special codes:

%f a single file path to be opened
%F a list of file paths to be opened
%u a single URL to be opened
%U a list of URLs to be opened
%c the application name

If "Make default application" is enabled the new application will become the new default. This implies that it does not show up in the menu itself. If this is not set the new application will just be added to the menu.

Technical Details

Zim uses the XDG Desktop Entry spec to store and retrieve application informations. The default application per mimetype is stored in a file in the XDG_DATA_HOME folder, typically ~/local/share/applications/defaults.list . This file with defaults is not part of the spec, but it seems to be in line with the implementation for the Gnome and KDE desktop environments.

To populate the "Open With..." menu zim searches the XDG_DATA_HOME/share/applications/ and XDG_DATA_DIRS/share/applications/ folders for .desktop files that list the specific mimetype. As an optimization we assume a file "mimeinfo.cache" to be present that lists applications entries by mimetype

When the user adds a new application zim creates a new .desktop file in the XDG_DATA_HOME folder and updates the cache. Next time it lists applications for a specific type, this entry will show up. For a new default application we also update defaults.list, but the desktop entry has "NoDisplay" set, so it is hidden from the menu.

Zim uses the XDG MimeInfo spec or the mimetypes module to determine file types. As an extension for URL and URI schemes the "x-scheme-handler/" mimetype is used. So "x-scheme-handler/http" is used to configure the webbrowser, "x-scheme-handler/mailto" for the email client, etc.

If no default application is found, zim uses operating system specific fallbacks. For files and email this mean calling "os.startfile()" on Windows, the "open" command on OSX, and the "xdg-open" and "xdg-email" commands on Linux and unix other systems. For URLs the "webbrowser" module is used as generic fallback. The "webbrowser" module is also used for files and email when e.g. the "xdg-open" or "xdg-email" commands are not found. (The webbrowser module does not only check specific browsers, but also tries system APIs that handle files as well.)

So on windows zim uses the XDG system to store application preferences, even though this is not the native system on windows. The fallback is an API (os.startfile()) that uses applications known to the Windows registry. As a result zim will just use the default installed applications on Windows, but this can be overruled by installing Desktop Entry files.

If you want to clean up custom application entries, have a look at the folder ~/.local/share/applications (or the equivalent XDG_DATA_HOME folder)

See Config Files for an overview of the various XDG file paths.

The XDG Desktop Entry spec and the XDG MimeInfo spec can be found here: http://www.freedesktop.org/wiki/Specifications

\Приложения по умолчанию
====================

Zim открывает файлы и вложения с другими приложениями. Обычно нажав на ссылку, вы запускаете соответствующее приложение для вашей системы. А в меню «Открыть с помощью ...» в контекстном меню (щелкните правой кнопкой мыши по ссылке) отображаются альтернативные приложения.

Если вы хотите изменить приложение по умолчанию или добавить дополнительные приложения в меню «Открыть с помощью…», в ​​нижней части всплывающего меню есть пункт «Настроить ...». Этот пункт вызывает диалог, который позволяет изменить приложение по умолчанию и добавить новые приложения.

Диалог настройки приложений
-----------------------------
В диалоговом окне «Настройка приложений» есть раскрывающееся меню для выбора приложения по умолчанию. Приложения, о которых знает zim, показаны в этом раскрывающемся списке. Также есть специальный пункт меню «System Default», который означает использование любого приложения по умолчанию, используемого операционной системой.

Обратите внимание, что могут быть установлены приложения, о которых zim не знает. Установка значения по умолчанию «System Default» может привести к правильному использованию приложения, даже если оно не отображается в списке.

Чтобы добавить приложения в список (и в меню «Открыть с помощью ...»), нажмите кнопку «Добавить приложение», откроется диалоговое окно «Добавить новое приложение».

Диалог добавления приложения
----------------------
Диалоговое окно «Добавить приложение» позволяет добавить новое приложение для файла определенного типа.

Имя - это имя приложения, а Command - команда для выполнения. Обычно это просто имя исполняемого файла или сценария для выполнения. Команда также может использовать следующие специальные коды:

% f отдельный путь к файлу, который нужно открыть
% F список путей к файлам, которые нужно открыть
% u один URL, который нужно открыть
% U список открываемых URL
% c имя приложения

Если «Сделать приложение по умолчанию» включено, новое приложение станет новым по умолчанию. Это означает, что он не отображается в самом меню. Если это не установлено, новое приложение будет просто добавлено в меню.

Технические подробности
-----------------
Zim использует XDG Desktop Entry для хранения и извлечения информации о приложении. Приложение по умолчанию для каждого mimetype хранится в файле в папке XDG_DATA_HOME, обычно ~ / local / share / application / defaults.list. Этот файл со значениями по умолчанию не является частью спецификации, но, похоже, соответствует реализации для рабочих сред Gnome и KDE.

Чтобы заполнить меню «Открыть с помощью ...», zim ищет в папках XDG_DATA_HOME / share / Applications / и XDG_DATA_DIRS / share / Applications / файлы .desktop, в которых указан определенный mimetype. В качестве оптимизации мы предполагаем наличие файла «mimeinfo.cache», в котором перечислены записи приложений по mimetype.

Когда пользователь добавляет новое приложение, zim создает новый файл .desktop в папке XDG_DATA_HOME и обновляет кэш. В следующий раз, когда в нем перечислены приложения для определенного типа, эта запись будет отображаться. Для нового приложения по умолчанию мы также обновляем defaults.list, но на рабочем столе установлена ​​запись «NoDisplay», поэтому она скрыта от меню.

Zim использует спецификацию XDG MimeInfo или модуль mimetypes для определения типов файлов. В качестве расширения для схем URL и URI используется mimetype «x-circuit-handler /». Таким образом, «x-схема-обработчик / http» используется для настройки веб-браузера, «x-схема-обработчик / mailto» для почтового клиента и т. Д.

Если приложение по умолчанию не найдено, zim использует откат для конкретной операционной системы. Для файлов и электронной почты это означает вызов «os.startfile ()» в Windows, команду «open» в OSX и команды «xdg-open» и «xdg-email» в Linux и других системах unix. Для URL-адресов модуль «веб-браузер» используется в качестве общего запасного варианта. Модуль "веб-браузер" также используется для файлов и электронной почты, например, когда команды "xdg-open" или "xdg-email" не найдены. (Модуль webbrowser не только проверяет определенные браузеры, но и пытается системные API, которые также обрабатывают файлы.)

Таким образом, в Windows Zim использует систему XDG для хранения настроек приложения, даже если это не собственная система Windows. Резервным является API (os.startfile ()), который использует приложения, известные в реестре Windows. В результате zim будет просто использовать установленные по умолчанию приложения в Windows, но это можно отменить, установив файлы Desktop Entry.

Если вы хотите очистить пользовательские записи приложений, взгляните на папку ~ / .local / share / Applications (или эквивалентную папку XDG_DATA_HOME)

См. Файлы конфигурации для обзора различных путей к файлам XDG.

Спецификацию XDG Desktop Entry и XDG MimeInfo можно найти здесь: http://www.freedesktop.org/wiki/Specifications


Backlinks: Help