「デフォルトアプリケーション」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(ページの作成:「Category:デスクトップ環境 en:Default applications zh-cn:Default Applications {{Related articles start}} {{Related|デスクトップ環境}} {{Related...」)
 
 
(7人の利用者による、間の33版が非表示)
1行目: 1行目:
[[Category:クトップ環境]]
+
[[Category:テム管理]]
 
[[en:Default applications]]
 
[[en:Default applications]]
[[zh-cn:Default Applications]]
+
[[ru:Default applications]]
  +
[[zh-hans:Default applications]]
{{Related articles start}}
 
  +
プログラムはさまざまな方法でデフォルトのアプリケーションの関連付けを実装します。コマンドラインプログラムは伝統的に[[環境変数#デフォルトプログラム|環境変数]]を使いますが、グラフィカルアプリケーションでは、[[Wikipedia:GIO (software)|GIO]] API、[[Qt]] API または [[xdg-utils]] の一部である {{ic|/usr/bin/xdg-open}} を実行することで、[[XDG MIME Applications]] を使用する傾向があります。[[xdg-open]] や [[XDG MIME Applications]] は非常に複雑なので、様々な代替[[#リソースオープナー|リソースオープナー]]が開発されました。次の表は、それぞれの方法のアプリケーション例です。
{{Related|デスクトップ環境}}
 
{{Related|ウィンドウマネージャ}}
 
{{Related articles end}}
 
特定のファイルタイプで使用するようにデフォルトアプリケーションを設定することが可能です (例: {{ic|HTML}} ファイルを表示するプログラムとして [[Firefox]] ウェブブラウザを設定)。ちゃんと設定することで、使用したいアプリケーションでファイルを素早く簡単に開いたり編集することができます。Linux でデフォルトアプリケーションを設定する方法は様々です。このページでは最も一般的な方法を説明します: ファイルマネージャ, MIME タイプ, 環境変数。
 
   
  +
{| class=wikitable
== MIME タイプとデスクトップエントリ ==
 
  +
! メソッド !! XDG を使用 !! アプリケーション例
  +
|-
  +
| [https://developer.gnome.org/gio/stable/GAppInfo.html GIO の GAppInfo] || Yes || [[Firefox]], [[GNOME Files]], [[PCManFM]], [[Thunar]], [[Thunderbird]], [[Telegram]]
  +
|-
  +
| {{ic|/usr/bin/xdg-open}} || By default || [[Chromium]] (ダウンロードしたファイルを開く)
  +
|-
  +
| custom || Usually not || [[mc]], [[ranger]]
  +
|-
  +
| [[環境変数#デフォルトプログラム|環境変数]] || No || [[man]], [[sudoedit]], [[systemctl]]
  +
|-
  +
| [[D-Bus]] の FileManager1 || org.freedesktop.FileManager1 || [[Firefox]] (Open containing folder), Zotero (ファイルを表示), [[Telegram]] (フォルダに表示)
  +
|}
   
  +
多くの[[デスクトップ環境]]とグラフィカル[[ファイルマネージャ]]は、デフォルトのアプリケーションを設定するための GUI を提供します。
最近ではアプリケーションは[[デスクトップエントリ]]を使って起動されます。この方法では、アプリケーションが開くことができるファイルの種類 (正確に言えば MIME タイプ) を定義できます。例えば {{ic|gimp.desktop}} には {{ic|<nowiki>MimeType=image/bmp;image/gif;...</nowiki>}} と記述されています。
 
   
  +
== 背景情報 ==
[http://www.freedesktop.org/wiki freedesktop.org] は [http://standards.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html Association between MIME types and applications] の標準に従って特定の MIME タイプのデフォルトの (使いたい) アプリケーションを指定することを推奨しています。設定するには以下のパスにある {{ic|mimeapps.list}} という名前のファイルを探して書き込みを行う必要があります:
 
  +
  +
プログラムは、ファイルや [[Wikipedia:Uniform Resource Identifier|URI]] をユーザーの好みのアプリケーションで開く必要がある場合があります。ユーザーの好みのアプリケーションでファイルを開くには、ファイルタイプを検出し(通常はファイル名の拡張子か [[Wikipedia:Media type|MIME タイプ]]にマッピングされた[[Wikipedia:List of file signatures|マジックナンバー]]を使用)、そのファイルタイプに関連するアプリケーションが存在する必要があります。
  +
  +
[[Heirloom]] UNIX のプログラムでは、MIME タイプの検出には [[Wikipedia:Media type#mime.types|mime.types]] を、アプリケーションの関連付けには [[Wikipedia:Media type#Mailcap|mailcap]] を使用していました。
  +
  +
== リソースオープナー ==
  +
  +
* '''XDG MIME Apps''': [[XDG MIME Applications]] 仕様を実装しています。
  +
* '''RegEx ルール''': 正規表現を使用して MIME タイプとアプリケーションを関連付けることができます。
  +
* '''URI サポート''': 任意の URI スキームをアプリケーションと関連付けることができます。
   
 
{| class="wikitable"
 
{| class="wikitable"
  +
! 名前 !! パッケージ !! XDG MIME Apps !! RegEx ルール !! URI サポート
! パス !! 使用方法
 
 
|-
 
|-
  +
|[[xdg-open]] || [[xdg-utils]] || {{Yes}} || {{No}} || {{Yes}}
| {{ic|$HOME/.config/$desktop-mimeapps.list}} || デスクトップごとに、ユーザーが定義します
 
 
|-
 
|-
  +
|{{man|1p|mimeopen}} || {{Pkg|perl-file-mimeinfo}} || {{Yes}} || {{No}} || {{No}}
| {{ic|$HOME/.config/mimeapps.list}} || ユーザーが定義します
 
 
|-
 
|-
  +
|mimeo || {{AUR|mimeo}} || {{Yes}} || {{Yes}} || {{Yes}}
| {{ic|/etc/xdg/$desktop-mimeapps.list}} || デスクトップごとに、システム管理者やソフトウェアが定義します
 
 
|-
 
|-
  +
|whippet || {{AUR|whippet}} || {{Yes}} || {{No}} || {{Yes}}
| {{ic|/etc/xdg/mimeapps.list}} || システム管理者やソフトウェアが定義します
 
 
|-
 
|-
  +
|linopen || {{AUR|linopen}} || {{No}} || {{Yes}} || {{Yes}}
| {{ic|$HOME/.local/share/applications/$desktop-mimeapps.list}} || デスクトップごとに、互換性のために存在しますが現在は非推奨です
 
 
|-
 
|-
  +
|mimi || {{AUR|mimi-git}} || {{No}} || {{No}} || {{Y|partly}}
| {{ic|$HOME/.local/share/applications/mimeapps.list}} || 互換性のために存在しますが現在は非推奨です
 
 
|-
 
|-
  +
|busking || {{AUR|busking-git}} || {{No}} || {{Yes}} || {{Yes}}
| {{ic|/usr/local/share/applications/$desktop-mimeapps.list}} と <br>{{ic|/usr/share/applications/$desktop-mimeapps.list}} || ディストリビューションによるデフォルト、デスクトップごと
 
 
|-
 
|-
  +
|sx-open || {{AUR|sx-open}} || {{No}} || {{Yes}} || {{Yes}}
| {{ic|/usr/local/share/applications/mimeapps.list}} と <br>{{ic|/usr/share/applications/mimeapps.list}} || ディストリビューションによるデフォルト
 
  +
|-
  +
|{{man|1|rifle}} || [[ranger]] || {{No}} || {{Yes}} || {{No}}
  +
|-
  +
|handlr || {{AUR|handlr-bin}} || {{Yes}} || {{No}} || {{Yes}}
 
|}
 
|}
   
  +
=== xdg-open ===
上の表にある、{{ic|$VARS}} は環境変数で {{ic|$desktop}} は使用しているデスクトップの名前です (小文字)。例: {{ic|kde}}, {{ic|gnome}}, {{ic|xfce}}, etc。
 
   
  +
[[xdg-open]] ([[xdg-utils]] の一部) は、[[XDG MIME Applications]] を実装し、多くのプログラムで使用されています。
The default application for a given MIME-type is specified by writing into the group {{ic|[Default Applications]}} in the {{ic|mimeapps.list}} file. In the following example, application {{ic|default1.desktop}} (if it is installed) will be used for {{ic|mimetype1}}, and otherwise {{ic|default2.desktop}} (if it is installed and {{ic|default1.desktop}} is not):
 
   
  +
[[xdg-utils]] 版の [[xdg-open]] は複雑なため、間違ったデフォルトのアプリケーションが開かれる場合はデバッグが困難になる場合があります。このため、これを改善しようとする代替手段が多く存在します。これらの代替品のいくつかは、{{ic|/usr/bin/xdg-open}} 実行ファイルを置き換えるので、ほとんどのアプリケーションのデフォルトのアプリケーションの動作を変更します。その他は、単にデフォルトアプリケーションを選択するための代替方法を提供するものです。
[Default Applications]
 
mimetype1=default1.desktop;default2.desktop
 
   
  +
=== perl-file-mimeinfo ===
The applications are written as a semicolon-separated list of [http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#desktop-file-id desktop file IDs].
 
   
  +
{{Pkg|perl-file-mimeinfo}} は {{man|1p|mimeopen}} と {{man|1p|mimetype}} というツールを提供します。これらは、{{pkg|xdg-utils}} の同等品より少し良いインターフェイスを持っています。
In the absence of such an entry, the next {{ic|mimeapps.list}} in the path hierarchy will be checked. Once all levels have been checked, if no entry could be found, then programs can pick any of the ''.desktop'' files associated with the MIME-type, taking into account added and removed associations as per these other groups which may be specified in {{ic|mimeapps.list}} files:
 
 
[Added Associations]
 
mimetype1=foo1.desktop;foo2.desktop;foo3.desktop
 
mimetype2=foo4.desktop
 
[Removed Associations]
 
mimetype1=foo5.desktop
 
 
The {{ic|[Added Associations]}} group defines additional associations of applications with MIME-types, as if the ''.desktop'' file was listing this MIME-type in the first place. The {{ic|[Removed Associations]}} group removes associations of applications with MIME-types, as if the ''.desktop'' file was '''not''' listing this MIME-type in the first place. The entries in {{ic|[Default Applications]}} should also be considered to add an association between application and MIME-type in the same manner.
 
 
{{Note|
 
* Arch Linux itself does not provide any system-wide preferences for associations, but other distributions and specific desktop environments may do so via {{ic|mimeapps.list}} or the older but deprecated {{ic|defaults.list}} files.
 
* As the standards for setting default applications have been recently changed, not all programs will comply with them yet. Indeed, the programs provided by freedesktop.org's {{Pkg|xdg-utils}} package do not fully follow their own standards!
 
* Your choice of desktop environment, or none, will also affect how your default applications are stored.
 
* When the program {{ic|update-desktop-database}} is run (usually as root during the (un)installation of a package), it updates files called {{ic|mimeinfo.cache}} in the {{ic|/usr/local/share/applications}} and {{ic|/usr/share/applications}} directories. These files keep track of which MIME-types are associated with which ''.desktop'' files overall. This file should not be edited by the user.
 
}}
 
 
=== ファイルマネージャ ===
 
 
Most file managers will allow for specific applications to be set as the defaults for various file types. New defaults may also be set at any time. For example, to set a default application using {{pkg|thunar}}, the native file manager for [[Xfce]]:
 
 
* {{ic|right-click}} the file-type desired
 
* Select {{ic|Open with another application}}
 
* Select the desired application
 
* Ensure that the {{ic|Use as default for this kind of file}} check-box is ticked
 
* Click the {{ic|Open}} button.
 
 
The general process will be very similar for most other popular file managers, including [[PCManFM]] and {{pkg|spacefm}}.
 
 
=== Gnome Control Center ===
 
 
If it's installed, run {{ic|gnome-control-center}}, open {{ic|System}} &gt; {{ic|Details}} &gt; {{ic|Default Applications}}.
 
 
=== gnome-defaults-list ===
 
 
{{AUR|gnome-defaults-list}} is available from the [[AUR]], and contains a list of file-types and programs specific to the GNOME desktop. The list is installed to {{ic|/etc/gnome/defaults.list}}.
 
 
Open this file with a text editor. Here you can replace a given application with the name of the program of your choice. For example, the media-player {{ic|totem}} can be replaced with another, such as {{ic|vlc}}. Save the file to {{ic|~/.local/share/applications/defaults.list}}.
 
 
=== xdg-open ===
 
   
  +
# determine a file's MIME type
[[xdg-open]] is a desktop-independent tool for starting default applications. Many applications invoke the {{ic|xdg-open}} command internally. xdg-open uses xdg-mime to query {{ic|~/.local/share/applications/mimeapps.list}} (among other things; if you use a mainstream DE like GNOME, KDE or LXDE, xdg-open might try using their specific tools before xdg-mime) to find the MIME type of the file that is to be opened and the default application associated with that MIME type.
 
  +
$ mimetype photo.jpeg
  +
photo.jpeg: image/jpeg
  +
  +
# choose the default application for this file
  +
$ mimeopen -d photo.jpeg
  +
Please choose an application
  +
  +
1) Feh (feh)
  +
2) GNU Image Manipulation Program (gimp)
  +
3) Pinta (pinta)
  +
  +
use application #
  +
  +
# open a file with its default application
  +
$ mimeopen -n photo.jpeg
   
  +
最も重要なことは、[[xdg-utils]] プログラムが[[デスクトップ環境]]を検出しない場合、MIME タイプ検出のために {{ic|mimetype}} の代わりに {{ic|file}} を実際に呼び出すことです。{{ic|file}} は XDG 標準に準拠していないため、これは重要なことです。
See [[xdg-open]] for more information.
 
   
  +
{{Note|0.28-1 以前の {{pkg|perl-file-mimeinfo}} は XDG 標準に''完全に''従っていたわけではありません。例えば、[https://github.com/mbeijen/File-MimeInfo/issues/20 distribution-wide ディストリビューション全体のデフォルト]を読み込まなかったり、[https://github.com/mbeijen/File-MimeInfo/issues/8 非推奨の場所」」に設定を保存していました。}}
=== ファイルの関連付けのカスタマイズ ===
 
   
  +
=== mimeo ===
The following method creates a custom mime type and file association manually. This is useful if your desktop does not have a mime type/file association editor installed. In this example, a fictional multimedia application 'foobar' will be associated with all {{ic|*.foo}} files. This will only affect the current user.
 
   
  +
{{aur|mimeo}} は {{ic|xdg-open}} と {{ic|xdg-mime}} の機能を統合したツール {{ic|mimeo}} を提供します。
First, create the file {{ic|~/.local/share/mime/packages/application-x-foobar.xml}}:
 
   
  +
# determine a file's MIME type
$ mkdir -p ~/.local/share/mime/packages
 
  +
$ mimeo -m photo.jpeg
$ cd ~/.local/share/mime/packages
 
  +
photo.jpeg
$ touch application-x-foobar.xml
 
  +
image/jpeg
  +
  +
# choose the default application for this MIME type
  +
$ mimeo --add image/jpeg feh.desktop
  +
  +
# open a file with its default application
  +
$ mimeo photo.jpeg
   
  +
しかし、''xdg-utils'' との大きな違いは、mimeoはより複雑な関連付けを可能にするカスタムの「関連付けファイル」をサポートしていることです。例えば、正規表現のマッチに基づいた特定のコマンドライン引数を渡すことができます。
Then edit {{ic|~/.local/share/mime/packages/application-x-foobar.xml}} and add this text:
 
   
  +
# open youtube links in VLC without opening a new instance
{{bc|<nowiki>
 
  +
vlc --one-instance --playlist-enqueue %U
<?xml version="1.0" encoding="UTF-8"?>
 
  +
^https?://(www.)?youtube.com/watch\?.*v=
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
 
<mime-type type="application/x-foobar">
 
<comment>foo file</comment>
 
<icon name="application-x-foobar"/>
 
<glob-deleteall/>
 
<glob pattern="*.foo"/>
 
</mime-type>
 
</mime-info>
 
</nowiki>}}
 
   
  +
{{aur|xdg-utils-mimeo}} は、デスクトップ環境が検出されない場合に {{ic|xdg-open}} が mimeo にフォールバックするように ''xdg-utils'' にパッチを当てます。
Note that you can use any icon, including one for another application.
 
   
  +
=== whippet ===
Next, edit or create the file {{ic|~/.local/share/applications/foobar.desktop}} to contain something like:
 
   
  +
{{aur|whippet}} は {{ic|xdg-open}} に似たツール {{ic|whippet}} を提供します。 {{pkg|libnotify}} でエラーを表示し、{{pkg|dmenu}} で開くアプリケーションの選択肢を表示することで、X11 との統合を実現しています。
{{bc|<nowiki>
 
[Desktop Entry]
 
Name=Foobar
 
Exec=/usr/bin/foobar
 
MimeType=application/x-foobar
 
Icon=foobar
 
Terminal=false
 
Type=Application
 
Categories=AudioVideo;Player;Video;
 
Comment=
 
</nowiki>}}
 
   
  +
# open a file with its default application
Note that Categories should be set appropriately for the application type (in this example, a multimedia app).
 
  +
$ whippet -M photo.jpeg
  +
  +
# choose from all possible applications for opening a file (without setting a default)
  +
$ whippet -m photo.jpeg
   
  +
[[XDG MIME Applications]] の実装に加えて、''whippet'' は application/MIME タイプ/正規表現の関連性を加えた SQlite データベースを使って、どのアプリケーションを使用するかを決定することができます。
Now update the applications and mime database with:
 
   
  +
=== handlr ===
$ update-desktop-database ~/.local/share/applications
 
$ update-mime-database ~/.local/share/mime
 
   
  +
Rust で書かれた {{Pkg|handlr}} は {{ic|xdg-open}} と {{ic|xdg-mime}} の機能を効率的なインタフェースで提供します。
Programs that use mime types, such as file managers, should now open {{ic|*.foo}} files with foobar. (You may need to restart your file manager to see the change.)
 
   
  +
{{ic|xdg-utils}} と比較すると、以下のような点が挙げられます。
=== 複数のデスクトップ環境の設定を管理 ===
 
  +
* 拡張子による関連付けの設定、mime タイプを調べたり覚えたりする必要性を排除
  +
* mime タイプと拡張子の検証
  +
* {{ic|mimeapps.list}} から無効なエントリを削除します。
  +
* ファイル名が曖昧な場合、ファイルの内容から mime タイプをインテリジェントに検出します。
  +
* mime、拡張子、デスクトップエントリーのオートコンプリートに対応
   
  +
# The following two are identical
The {{ic|OnlyShowIn}} field of a .desktop file may be useful; see [http://standards.freedesktop.org/menu-spec/latest/ this page].
 
  +
handlr set .png feh.desktop
  +
handlr set image/png feh.desktop
  +
  +
# List default apps
  +
handlr list
  +
  +
# Get the handler for a mime/extension
  +
$ handlr get .png --json
  +
{"handler":"pqiv.desktop","name":"pqiv","cmd":"/usr/bin/pqiv"}
  +
  +
# Launch a handler with optional path/URL
  +
handlr launch x-scheme-handler/https
  +
handlr launch x-scheme-handler/https -- https://google.ca
   
  +
{{aur|xdg-utils-handlr}} は、内部で {{ic|handlr}} を使用して {{ic|xdg-utils}} を置き換える{{ic|xdg-open}} を提供します。
== 環境変数を使う ==
 
   
  +
=== ミニマルなリプレイスメント ===
グラフィカルでないプログラムのほとんどは {{ic|EDITOR}} や {{ic|BROWSER}} などの[[環境変数]]を使います。環境変数はターミナルの自動起動ファイルで設定できます (例: {{ic|~/.bashrc}}):
 
   
  +
以下のパッケージは独自の {{ic|/usr/bin/xdg-open}} スクリプトを提供しているため、 {{Pkg|xdg-utils}} と競合して提供されます。
{{hc|~/.bashrc|<nowiki>
 
export EDITOR="nano"
 
export BROWSER="firefox"
 
</nowiki>}}
 
   
  +
もし、{{Pkg|xdg-utils}} を使用しながら、これらのリソースオープナーを使用したい場合、{{ic|/usr/bin}} より前の PATH ディレクトリに手動でインストールしてください。
== トラブルシューティング ==
 
   
  +
* {{AUR|mimi-git}} - 130 行の Bash スクリプトで、MIME タイプごとにコマンド引数を変更することができます。
=== (ファイルマネージャにある) コンテキストメニューの「他のアプリケーションで開く」でアプリケーションが表示されない ===
 
  +
* {{AUR|busking-git}} - 80 行の Perl スクリプトで、''mimi''に似ていますが、正規表現もサポートしています。
   
  +
==== mailcap の実行 ====
Sometimes, a certain application will not appear in the right-click ''Open With...'' dialog. To fix this problem, locate the {{Ic|.desktop}} file in {{Ic|/usr/share/applications}}, edit it as root, and add {{Ic|%U}} to the end of the {{Ic|1=<nowiki>Exec=</nowiki>}} line. For example, Kile currently has this problem; you need to edit {{Ic|/usr/share/applications/kde4/kile.desktop}} and change the line reading {{Ic|1=<nowiki>Exec=kile</nowiki>}} to read {{Ic|1=<nowiki>Exec=kile %U</nowiki>}}. Also, please file a bug against the upstream project if you notice this problem.
 
   
  +
{{Warning|{{AUR|run-mailcap}} を使うと {{ic|xdg-open}} がそれに委譲する可能性があります。もし {{Pkg|mailcap}} の {{ic|/etc/mailcap}} を使っているならば、これも {{ic|xdg-open}} に委譲されるので、無限ループを引き起こします。}}
You may also have to edit the {{Ic|MimeType}} list in the {{Ic|.desktop}} file if you install extensions that allow an application to handle additional MIME types.
 

2024年1月18日 (木) 16:34時点における最新版

プログラムはさまざまな方法でデフォルトのアプリケーションの関連付けを実装します。コマンドラインプログラムは伝統的に環境変数を使いますが、グラフィカルアプリケーションでは、GIO API、Qt API または xdg-utils の一部である /usr/bin/xdg-open を実行することで、XDG MIME Applications を使用する傾向があります。xdg-openXDG MIME Applications は非常に複雑なので、様々な代替リソースオープナーが開発されました。次の表は、それぞれの方法のアプリケーション例です。

メソッド XDG を使用 アプリケーション例
GIO の GAppInfo Yes Firefox, GNOME Files, PCManFM, Thunar, Thunderbird, Telegram
/usr/bin/xdg-open By default Chromium (ダウンロードしたファイルを開く)
custom Usually not mc, ranger
環境変数 No man, sudoedit, systemctl
D-Bus の FileManager1 org.freedesktop.FileManager1 Firefox (Open containing folder), Zotero (ファイルを表示), Telegram (フォルダに表示)

多くのデスクトップ環境とグラフィカルファイルマネージャは、デフォルトのアプリケーションを設定するための GUI を提供します。

背景情報

プログラムは、ファイルや URI をユーザーの好みのアプリケーションで開く必要がある場合があります。ユーザーの好みのアプリケーションでファイルを開くには、ファイルタイプを検出し(通常はファイル名の拡張子か MIME タイプにマッピングされたマジックナンバーを使用)、そのファイルタイプに関連するアプリケーションが存在する必要があります。

Heirloom UNIX のプログラムでは、MIME タイプの検出には mime.types を、アプリケーションの関連付けには mailcap を使用していました。

リソースオープナー

  • XDG MIME Apps: XDG MIME Applications 仕様を実装しています。
  • RegEx ルール: 正規表現を使用して MIME タイプとアプリケーションを関連付けることができます。
  • URI サポート: 任意の URI スキームをアプリケーションと関連付けることができます。
名前 パッケージ XDG MIME Apps RegEx ルール URI サポート
xdg-open xdg-utils Yes No Yes
mimeopen(1p) perl-file-mimeinfo Yes No No
mimeo mimeoAUR Yes Yes Yes
whippet whippetAUR Yes No Yes
linopen linopenAUR No Yes Yes
mimi mimi-gitAUR No No partly
busking busking-gitAUR No Yes Yes
sx-open sx-openAUR No Yes Yes
rifle(1) ranger No Yes No
handlr handlr-binAUR Yes No Yes

xdg-open

xdg-open (xdg-utils の一部) は、XDG MIME Applications を実装し、多くのプログラムで使用されています。

xdg-utils 版の xdg-open は複雑なため、間違ったデフォルトのアプリケーションが開かれる場合はデバッグが困難になる場合があります。このため、これを改善しようとする代替手段が多く存在します。これらの代替品のいくつかは、/usr/bin/xdg-open 実行ファイルを置き換えるので、ほとんどのアプリケーションのデフォルトのアプリケーションの動作を変更します。その他は、単にデフォルトアプリケーションを選択するための代替方法を提供するものです。

perl-file-mimeinfo

perl-file-mimeinfomimeopen(1p)mimetype(1p) というツールを提供します。これらは、xdg-utils の同等品より少し良いインターフェイスを持っています。

# determine a file's MIME type
$ mimetype photo.jpeg
photo.jpeg: image/jpeg

# choose the default application for this file
$ mimeopen -d photo.jpeg
Please choose an application

    1) Feh (feh)
    2) GNU Image Manipulation Program (gimp)
    3) Pinta (pinta)

use application #

# open a file with its default application
$ mimeopen -n photo.jpeg

最も重要なことは、xdg-utils プログラムがデスクトップ環境を検出しない場合、MIME タイプ検出のために mimetype の代わりに file を実際に呼び出すことです。file は XDG 標準に準拠していないため、これは重要なことです。

ノート: 0.28-1 以前の perl-file-mimeinfo は XDG 標準に完全に従っていたわけではありません。例えば、distribution-wide ディストリビューション全体のデフォルトを読み込まなかったり、[https://github.com/mbeijen/File-MimeInfo/issues/8 非推奨の場所」」に設定を保存していました。

mimeo

mimeoAURxdg-openxdg-mime の機能を統合したツール mimeo を提供します。

# determine a file's MIME type
$ mimeo -m photo.jpeg
photo.jpeg
  image/jpeg

# choose the default application for this MIME type
$ mimeo --add image/jpeg feh.desktop

# open a file with its default application
$ mimeo photo.jpeg

しかし、xdg-utils との大きな違いは、mimeoはより複雑な関連付けを可能にするカスタムの「関連付けファイル」をサポートしていることです。例えば、正規表現のマッチに基づいた特定のコマンドライン引数を渡すことができます。

# open youtube links in VLC without opening a new instance
vlc --one-instance --playlist-enqueue %U
  ^https?://(www.)?youtube.com/watch\?.*v=

xdg-utils-mimeoAUR は、デスクトップ環境が検出されない場合に xdg-open が mimeo にフォールバックするように xdg-utils にパッチを当てます。

whippet

whippetAURxdg-open に似たツール whippet を提供します。 libnotify でエラーを表示し、dmenu で開くアプリケーションの選択肢を表示することで、X11 との統合を実現しています。

# open a file with its default application
$ whippet -M photo.jpeg

# choose from all possible applications for opening a file (without setting a default)
$ whippet -m photo.jpeg

XDG MIME Applications の実装に加えて、whippet は application/MIME タイプ/正規表現の関連性を加えた SQlite データベースを使って、どのアプリケーションを使用するかを決定することができます。

handlr

Rust で書かれた handlrxdg-openxdg-mime の機能を効率的なインタフェースで提供します。

xdg-utils と比較すると、以下のような点が挙げられます。

  • 拡張子による関連付けの設定、mime タイプを調べたり覚えたりする必要性を排除
  • mime タイプと拡張子の検証
  • mimeapps.list から無効なエントリを削除します。
  • ファイル名が曖昧な場合、ファイルの内容から mime タイプをインテリジェントに検出します。
  • mime、拡張子、デスクトップエントリーのオートコンプリートに対応
# The following two are identical
handlr set .png feh.desktop
handlr set image/png feh.desktop

# List default apps
handlr list

# Get the handler for a mime/extension
$ handlr get .png --json
{"handler":"pqiv.desktop","name":"pqiv","cmd":"/usr/bin/pqiv"}

# Launch a handler with optional path/URL
handlr launch x-scheme-handler/https
handlr launch x-scheme-handler/https -- https://google.ca

xdg-utils-handlrAUR は、内部で handlr を使用して xdg-utils を置き換えるxdg-open を提供します。

ミニマルなリプレイスメント

以下のパッケージは独自の /usr/bin/xdg-open スクリプトを提供しているため、 xdg-utils と競合して提供されます。

もし、xdg-utils を使用しながら、これらのリソースオープナーを使用したい場合、/usr/bin より前の PATH ディレクトリに手動でインストールしてください。

  • mimi-gitAUR - 130 行の Bash スクリプトで、MIME タイプごとにコマンド引数を変更することができます。
  • busking-gitAUR - 80 行の Perl スクリプトで、mimiに似ていますが、正規表現もサポートしています。

mailcap の実行

警告: run-mailcapAUR を使うと xdg-open がそれに委譲する可能性があります。もし mailcap/etc/mailcap を使っているならば、これも xdg-open に委譲されるので、無限ループを引き起こします。