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

提供: ArchWiki
ナビゲーションに移動 検索に移動
(カテゴリーを修正)
 
(3人の利用者による、間の17版が非表示)
3行目: 3行目:
 
[[ru:Default applications]]
 
[[ru:Default applications]]
 
[[zh-hans:Default applications]]
 
[[zh-hans:Default applications]]
プログラムはさまざまな方法でデフォルトのアプリケーションの関連付けを実装します。コマンドラインプログラムは伝統的に[[環境変数#デフォルトプログラム|環境変数]]を使いますが、グラフィカルアプリケーションでは、[[Wikipedia:GIO (software)|GIO]] API、[[Qt]] API または [[xdg-utils]] の一部である {{ic|/usr/bin/xdg-open}} を実行することで、[[XDG MIME Applications]] を使用する傾向があります。[[xdg-open]] や [[XDG MIME Applications]] は非常に複雑なので、様々な代替リソースオープナーが開発されました。次の表は、それぞれの方法のアプリケーション例です。
+
プログラムはさまざまな方法でデフォルトのアプリケーションの関連付けを実装します。コマンドラインプログラムは伝統的に[[環境変数#デフォルトプログラム|環境変数]]を使いますが、グラフィカルアプリケーションでは、[[Wikipedia:GIO (software)|GIO]] API、[[Qt]] API または [[xdg-utils]] の一部である {{ic|/usr/bin/xdg-open}} を実行することで、[[XDG MIME Applications]] を使用する傾向があります。[[xdg-open]] や [[XDG MIME Applications]] は非常に複雑なので、様々な代替[[#リソースオープナー|リソースオープナー]]が開発されました。次の表は、それぞれの方法のアプリケーション例です。
   
 
{| class=wikitable
 
{| class=wikitable
! メソッド !! XDG を使用 !! アプリケーション例
+
! メソッド !! XDG を使用 !! アプリケーション例 !! アソシエーションをチェック
 
|-
 
|-
| [https://developer.gnome.org/gio/stable/GAppInfo.html GIO's GAppInfo] || Yes || [[Firefox]], [[GNOME Files]], [[PCManFM]], [[Thunar]], [[Thunderbird]], [[Telegram]]
+
| [https://developer.gnome.org/gio/stable/GAppInfo.html GIO GAppInfo] || Yes || [[Firefox]], [[GNOME Files]], [[PCManFM]], [[Thunar]], [[Thunderbird]], [[Telegram]] || {{ic|gio mime ''mimetype''}}
 
|-
 
|-
| {{ic|/usr/bin/xdg-open}} || By default || [[Chromium]] (ダウンロードしたファイルを開く)
+
| {{ic|/usr/bin/xdg-open}} || By default || [[Chromium]] (ダウンロードしたファイルを開く) || {{ic|xdg-mime query default ''mimetype''}}
 
|-
 
|-
| custom || Usually not || [[mc]], [[ranger]]
+
| custom || Usually not || [[mc]], [[ranger]] || {{-}}
 
|-
 
|-
| [[環境変数#デフォルトプログラム|環境変数]] || No || [[man]], [[sudoedit]], [[systemctl]]
+
| [[環境変数#デフォルトプログラム|環境変数]] || No || [[man]], [[sudoedit]], [[systemctl]] || {{-}}
 
|-
 
|-
| [[D-Bus]] の FileManager1 || org.freedesktop.FileManager1 || [[Firefox]] (Open containing folder), Zotero (ファイルを表示), [[Telegram]] (フォルダに表示)
+
| [[D-Bus]] の FileManager1 || org.freedesktop.FileManager1 || [[Firefox]] (Open containing folder), Zotero (ファイルを表示), [[Telegram]] (フォルダに表示) || {{-}}
 
|}
 
|}
   
 
多くの[[デスクトップ環境]]とグラフィカル[[ファイルマネージャ]]は、デフォルトのアプリケーションを設定するための GUI を提供します。
 
多くの[[デスクトップ環境]]とグラフィカル[[ファイルマネージャ]]は、デフォルトのアプリケーションを設定するための GUI を提供します。
   
  +
{{Note|[[XDG MIME Applications]] 仕様では、MIME タイプ定義ファイルに他のタイプのサブクラスやエイリアスを作成することができます。このため、アプリケーションで対象となる型は直接サポートされないものの、サブクラス化された型はサポートされるような MIME 型が存在する場合、その取り扱いが不明確になる可能性があります。例えば、Firefox は {{ic|application/rss+xml}} を GIO 経由で解決し、最終的に自分自身で開くことができます。これは、タイプが {{ic|application/xml}} をサブクラス化し、Firefox がそのデフォルトハンドラであるためです。}}
== Background information ==
 
   
  +
== 背景情報 ==
Programs sometimes need to open a file or a [[Wikipedia:Uniform Resource Identifier|URI]] in the user's preferred application. To open a file in the user's preferred application the filetype needs to be detected (usually using filename extensions or [[Wikipedia:List of file signatures|magic numbers]] mapped to [[Wikipedia:Media type|MIME types]]) and there needs to be an application associated with the filetype.
 
   
  +
プログラムは、ファイルや [[Wikipedia:Uniform Resource Identifier|URI]] をユーザーの好みのアプリケーションで開く必要がある場合があります。ユーザーの好みのアプリケーションでファイルを開くには、ファイルタイプを検出し(通常はファイル名の拡張子か [[Wikipedia:Media type|MIME タイプ]]にマッピングされた[[Wikipedia:List of file signatures|マジックナンバー]]を使用)、そのファイルタイプに関連するアプリケーションが存在する必要があります。
[[Heirloom]] UNIX programs used [[Wikipedia:Media type#mime.types|mime.types]] for MIME type detection and [[Wikipedia:Media type#Mailcap|mailcap]] for application association.
 
  +
  +
[[Heirloom]] UNIX のプログラムでは、MIME タイプの検出には [[Wikipedia:Media type#mime.types|mime.types]] を、アプリケーションの関連付けには [[Wikipedia:Media type#Mailcap|mailcap]] を使用していました。
   
 
== リソースオープナー ==
 
== リソースオープナー ==
   
* '''XDG MIME Apps''': implements the [[XDG MIME Applications]] specification
+
* '''XDG MIME Apps''': [[XDG MIME Applications]] 仕様を実装しています。
  +
* '''RegEx ルール''': 正規表現を使用して MIME タイプとアプリケーションを関連付けることができます。
* '''RegEx rules''': allows MIME types to be associated with applications using regular expressions
 
  +
* '''URI サポート''': 任意の URI スキームをアプリケーションと関連付けることができます。
* '''URI support''': allows arbitrary URI schemes to be associated with applications
 
   
 
{| class="wikitable"
 
{| class="wikitable"
! Name !! Package !! XDG MIME Apps !! RegEx rules !! URI support
+
! 名前 !! パッケージ !! XDG MIME Apps !! RegEx ルール !! URI サポート
 
|-
 
|-
 
|[[xdg-open]] || [[xdg-utils]] || {{Yes}} || {{No}} || {{Yes}}
 
|[[xdg-open]] || [[xdg-utils]] || {{Yes}} || {{No}} || {{Yes}}
  +
|-
  +
|{{man|1|gio}} || {{pkg|glib2}} || {{Yes}} || {{-}} || {{Yes}}
 
|-
 
|-
 
|{{man|1p|mimeopen}} || {{Pkg|perl-file-mimeinfo}} || {{Yes}} || {{No}} || {{No}}
 
|{{man|1p|mimeopen}} || {{Pkg|perl-file-mimeinfo}} || {{Yes}} || {{No}} || {{No}}
42行目: 46行目:
 
|mimeo || {{AUR|mimeo}} || {{Yes}} || {{Yes}} || {{Yes}}
 
|mimeo || {{AUR|mimeo}} || {{Yes}} || {{Yes}} || {{Yes}}
 
|-
 
|-
|whippet || {{AUR|whippet}} || {{Yes}} || {{No}} || {{Yes}}
+
|mimi || {{AUR|mimi}}, {{AUR|mimi-git}} || {{No}} || {{No}} || {{Y|部分的に}}
 
|-
 
|-
|linopen || {{AUR|linopen}} || {{No}} || {{Yes}} || {{Yes}}
+
|busking || {{AUR|busking-git}} || {{No}} || {{Yes}} || {{Yes}}
 
|-
 
|-
|mimi || {{AUR|mimi-git}} || {{No}} || {{No}} || {{Y|partly}}
+
|{{man|1|rifle}} || [[ranger]] || {{No}} || {{Yes}} || {{No}}
 
|-
 
|-
|busking || {{AUR|busking-git}} || {{No}} || {{Yes}} || {{Yes}}
+
|handlr || {{pkg|handlr-regex}} || {{Yes}} || {{Yes}} || {{Yes}}
 
|-
 
|-
|sx-open || {{AUR|sx-open}} || {{No}} || {{Yes}} || {{Yes}}
+
|clifm || {{AUR|clifm}} || {{No}} || {{Yes}} || {{Y|部分的に}}
|-
 
|{{man|1|rifle}} || [[ranger]] || {{No}} || {{Yes}} || {{No}}
 
 
|-
 
|-
|handlr || {{AUR|handlr-bin}} || {{Yes}} || {{No}} || {{Yes}}
+
|mimejs-git || {{AUR|mimejs-git}} || {{No}} || {{No}} || {{Yes}}
 
|}
 
|}
   
 
=== xdg-open ===
 
=== xdg-open ===
   
[[xdg-open]] (part of [[xdg-utils]]) implements [[XDG MIME Applications]] and is used by many programs.
+
[[xdg-open]] ([[xdg-utils]] の一部) は、[[XDG MIME Applications]] を実装し、多くのプログラムで使用されています。
   
  +
[[xdg-utils]] 版の [[xdg-open]] は複雑なため、間違ったデフォルトのアプリケーションが開かれる場合はデバッグが困難になる場合があります。このため、これを改善しようとする代替手段が多く存在します。これらの代替品のいくつかは、{{ic|/usr/bin/xdg-open}} 実行ファイルを置き換えるので、ほとんどのアプリケーションのデフォルトのアプリケーションの動作を変更します。その他は、単にデフォルトアプリケーションを選択するための代替方法を提供するものです。
Because of the complexity of the [[xdg-utils]] version of [[xdg-open]], it can be difficult to debug when the wrong default application is being opened. Because of this, there are many alternatives that attempt to improve upon it. Several of these alternatives replace the {{ic|/usr/bin/xdg-open}} executable, thus changing the default application behavior of most applications. Others simply provide an alternative method of choosing default applications.
 
   
 
=== perl-file-mimeinfo ===
 
=== perl-file-mimeinfo ===
   
{{Pkg|perl-file-mimeinfo}} provides the tools {{man|1p|mimeopen}} and {{man|1p|mimetype}}. These have a slightly nicer interface than their {{pkg|xdg-utils}} equivalents:
+
{{Pkg|perl-file-mimeinfo}} {{man|1p|mimeopen}} {{man|1p|mimetype}} というツールを提供します。これらは、{{pkg|xdg-utils}} の同等品より少し良いインターフェイスを持っています。
  +
 
# determine a file's MIME type
 
# determine a file's MIME type
 
$ mimetype photo.jpeg
 
$ mimetype photo.jpeg
83行目: 86行目:
 
$ mimeopen -n photo.jpeg
 
$ mimeopen -n photo.jpeg
   
  +
最も重要なことは、[[xdg-utils]] プログラムが[[デスクトップ環境]]を検出しない場合、MIME タイプ検出のために {{ic|mimetype}} の代わりに {{ic|file}} を実際に呼び出すことです。{{ic|file}} は XDG 標準に準拠していないため、これは重要なことです。
Most importantly, [[xdg-utils]] programs will actually call {{ic|file}} instead of {{ic|mimetype}} for MIME type detection if it does not detect your [[デスクトップ環境]]. This is important because {{ic|file}} does not follow the XDG standard.
 
   
{{Note|{{pkg|perl-file-mimeinfo}} before 0.28-1 did not ''entirely'' follow the XDG standard. For example it did not not read [https://github.com/mbeijen/File-MimeInfo/issues/20 distribution-wide defaults] and it saved its config in [https://github.com/mbeijen/File-MimeInfo/issues/8 deprecated locations].}}
+
{{Note|0.28-1 以前の {{pkg|perl-file-mimeinfo}} XDG 標準に''完全に''従っていたわけではありません。例えば、[https://github.com/mbeijen/File-MimeInfo/issues/20 ディストリビューション全体のデフォルト] を読み込まなかったり、[https://github.com/mbeijen/File-MimeInfo/issues/8 非推奨の場所] に設定を保存していました。}}
   
 
=== mimeo ===
 
=== mimeo ===
   
{{aur|mimeo}} provides the tool {{ic|mimeo}}, which unifies the functionality of {{ic|xdg-open}} and {{ic|xdg-mime}}.
+
{{aur|mimeo}} {{ic|xdg-open}} {{ic|xdg-mime}} の機能を統合したツール {{ic|mimeo}} を提供します。
  +
  +
次の例では、SVG ファイルを Inkscape に関連付ける方法を示します:
   
 
# determine a file's MIME type
 
# determine a file's MIME type
$ mimeo -m photo.jpeg
+
$ mimeo --mimetype Svg_example2.svg
  +
Svg_example2.svg
photo.jpeg
 
image/jpeg
+
image/svg+xml
  +
  +
# determine desktop file associated with executable "inkscape"
  +
$ mimeo --app2desk inkscape
  +
inkscape
  +
org.inkscape.Inkscape.desktop
  +
  +
# find desktop file path
  +
$ mimeo --finddesk org.inkscape.Inkscape.desktop
  +
/usr/share/applications/org.inkscape.Inkscape.desktop
 
 
 
# choose the default application for this MIME type
 
# choose the default application for this MIME type
$ mimeo --add image/jpeg feh.desktop
+
$ mimeo --prefer image/svg+xml org.inkscape.Inkscape.desktop
 
 
  +
# check association
  +
$ mimeo --mime2desk image/svg+xml
  +
image/svg+xml
  +
org.inkscape.Inkscape.desktop
  +
 
# open a file with its default application
 
# open a file with its default application
$ mimeo photo.jpeg
+
$ mimeo Svg_example2.svg
   
  +
{{ic|mimeapps.list}} ファイルへのパスを見つけることもできます:
However a big difference with ''xdg-utils'' is that mimeo also supports custom "association files" that allow for more complex associations. For example, passing specific command line arguments based on a regular expression match:
 
  +
$ mimeo --mimeapps-list
  +
/home/user/.config/mimeapps.list
  +
  +
ただし、''xdg-utils'' との大きな違いは、mimeo がより複雑な関連付けを可能にするカスタムの "関連付けファイル" もサポートしていることです。たとえば、正規表現の一致に基づいて特定のコマンドライン引数を渡します。
   
 
# open youtube links in VLC without opening a new instance
 
# open youtube links in VLC without opening a new instance
108行目: 131行目:
 
^https?://(www.)?youtube.com/watch\?.*v=
 
^https?://(www.)?youtube.com/watch\?.*v=
   
{{aur|xdg-utils-mimeo}} patches ''xdg-utils'' so that {{ic|xdg-open}} falls back to mimeo if no desktop environment is detected.
+
{{aur|xdg-utils-mimeo}} ''xdg-utils''bにパッチを適用し、デスクトップ環境が検出されない場合に {{ic|xdg-open}} mimeo に戻るようにします。
 
=== whippet ===
 
 
{{aur|whippet}} provides the tool {{ic|whippet}}, which is similar to {{ic|xdg-open}}. It has X11 integration by using {{pkg|libnotify}} to display errors and {{pkg|dmenu}} to display choices between applications to open.
 
 
# 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
 
 
In addition to implementing [[XDG MIME Applications]], ''whippet'' can also use a SQlite database of weighted application/MIME type/regex associations to determine which app to use.
 
   
 
=== handlr ===
 
=== handlr ===
   
{{aur|handlr-bin}}, written in Rust, provides the functionality of {{ic|xdg-open}} and {{ic|xdg-mime}} with a streamlined interface.
+
Rust で書かれた {{Pkg|handlr}} {{ic|xdg-open}} {{ic|xdg-mime}} の機能を効率的なインタフェースで提供します。
   
  +
{{ic|xdg-utils}} と比較すると、以下のような点が挙げられます。
Compared to {{ic|xdg-utils}}, it includes:
 
  +
* 拡張子による関連付けの設定、mime タイプを調べたり覚えたりする必要性を排除
* setting associations by extension, removing the need to look up or remember mime types
 
  +
* mime タイプと拡張子の検証
* validation for mime types and extensions
 
* removal of invalid entries from {{ic|mimeapps.list}}
+
* {{ic|mimeapps.list}} から無効なエントリを削除します。
  +
* ファイル名が曖昧な場合、ファイルの内容から mime タイプをインテリジェントに検出します。
* intelligent detection of mime types from file content in case filename is ambiguous
 
  +
* mime、拡張子、デスクトップエントリーのオートコンプリートに対応
* autocompletion of mimes, extensions, and desktop entries
 
  +
* 正規表現に基づいて任意のコマンドをハンドラとして設定する。
   
 
# The following two are identical
 
# The following two are identical
148行目: 160行目:
 
handlr launch x-scheme-handler/https -- https://google.ca
 
handlr launch x-scheme-handler/https -- https://google.ca
   
{{aur|xdg-utils-handlr}} provides an {{ic|xdg-open}} that uses {{ic|handlr}} under the hood to replace {{ic|xdg-utils}}.
+
{{ic|handlr}} {{ic|xdg-open}} の代わりに使用するには、次のスクリプトでシャドウします。
  +
  +
#!/usr/bin/bash
  +
handlr open "$@"
  +
  +
=== clifm ===
  +
  +
{{ic|clifm}} の組み込みリソースオープナーである ''Lira'' は、{{ic|--open}} コマンドラインオプションを介してスタンドアロンのリソースオープナーとして使用できます。設定ファイル ({{ic|~/.config/clifm/profiles/PROFILE_NAME/mimelist.clifm}}) は、MIME タイプとファイル名 (またはファイル拡張子) の両方の正規表現をサポートしています。いくつかの例:
  +
  +
# Open a regular file
  +
clifm --open /etc/hosts
  +
  +
# Open a directory
  +
clifm --open /media/data
  +
  +
# Open an URL (via the application associated to the text/http MIME type in the configuration file)
  +
clifm --open www.archlinux.org
   
  +
=== ミニマルなリプレイスメント ===
=== Minimalist replacements ===
 
   
  +
以下のパッケージは独自の {{ic|/usr/bin/xdg-open}} スクリプトを提供しているため、 {{Pkg|xdg-utils}} と競合して提供されます。
The following packages conflict with and provide {{Pkg|xdg-utils}} because they provide their own {{ic|/usr/bin/xdg-open}} script.
 
   
  +
もし、{{Pkg|xdg-utils}} を使用しながら、これらのリソースオープナーを使用したい場合、{{ic|/usr/bin}} より前の PATH ディレクトリに手動でインストールしてください。
If you want to use one of these resource openers while still being able to use {{Pkg|xdg-utils}}, install them manually in a PATH directory before {{ic|/usr/bin}}.
 
   
  +
* {{AUR|mimi-git}} - 130 行の Bash スクリプトで、MIME タイプごとにコマンド引数を変更することができます。
* {{AUR|linopen}} - 170-line Bash script, supports regex rules
 
  +
* {{AUR|busking-git}} - 80 行の Perl スクリプトで、''mimi''に似ていますが、正規表現もサポートしています。
* {{AUR|mimi-git}} - 130-line Bash script, can change command arguments for each MIME type
 
* {{AUR|busking-git}} - 80-line Perl script similar to ''mimi'' but also supports regex rules
 
* {{AUR|sx-open}} - 60-line Bash script, uses a simple shell-based config file
 
   
==== run-mailcap ====
+
==== mailcap の実行 ====
   
{{Warning|If you use {{AUR|run-mailcap}}, it is possible for {{ic|xdg-open}} to delegate to it. This will cause an infinite loop if you are using the {{ic|/etc/mailcap}} from {{Pkg|mailcap}}, because it also delegates to {{ic|xdg-open}}.}}
+
{{Warning|{{AUR|run-mailcap}} を使うと {{ic|xdg-open}} がそれに委譲する可能性があります。もし {{Pkg|mailcap}} {{ic|/etc/mailcap}} を使っているならば、これも {{ic|xdg-open}} に委譲されるので、無限ループを引き起こします。}}

2024年7月29日 (月) 02:11時点における最新版

プログラムはさまざまな方法でデフォルトのアプリケーションの関連付けを実装します。コマンドラインプログラムは伝統的に環境変数を使いますが、グラフィカルアプリケーションでは、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 gio mime mimetype
/usr/bin/xdg-open By default Chromium (ダウンロードしたファイルを開く) xdg-mime query default mimetype
custom Usually not mc, ranger
環境変数 No man, sudoedit, systemctl
D-Bus の FileManager1 org.freedesktop.FileManager1 Firefox (Open containing folder), Zotero (ファイルを表示), Telegram (フォルダに表示)

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

ノート: XDG MIME Applications 仕様では、MIME タイプ定義ファイルに他のタイプのサブクラスやエイリアスを作成することができます。このため、アプリケーションで対象となる型は直接サポートされないものの、サブクラス化された型はサポートされるような MIME 型が存在する場合、その取り扱いが不明確になる可能性があります。例えば、Firefox は application/rss+xml を GIO 経由で解決し、最終的に自分自身で開くことができます。これは、タイプが application/xml をサブクラス化し、Firefox がそのデフォルトハンドラであるためです。

背景情報

プログラムは、ファイルや 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
gio(1) glib2 Yes Yes
mimeopen(1p) perl-file-mimeinfo Yes No No
mimeo mimeoAUR Yes Yes Yes
mimi mimiAUR, mimi-gitAUR No No 部分的に
busking busking-gitAUR No Yes Yes
rifle(1) ranger No Yes No
handlr handlr-regex Yes Yes Yes
clifm clifmAUR No Yes 部分的に
mimejs-git mimejs-gitAUR No 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 標準に完全に従っていたわけではありません。例えば、ディストリビューション全体のデフォルト を読み込まなかったり、非推奨の場所 に設定を保存していました。

mimeo

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

次の例では、SVG ファイルを Inkscape に関連付ける方法を示します:

# determine a file's MIME type
$ mimeo --mimetype Svg_example2.svg
Svg_example2.svg
 image/svg+xml

# determine desktop file associated with executable "inkscape"
$ mimeo --app2desk inkscape
inkscape
 org.inkscape.Inkscape.desktop
 
# find desktop file path
$ mimeo --finddesk org.inkscape.Inkscape.desktop
/usr/share/applications/org.inkscape.Inkscape.desktop

# choose the default application for this MIME type
$ mimeo --prefer image/svg+xml org.inkscape.Inkscape.desktop

# check association
$ mimeo --mime2desk image/svg+xml
image/svg+xml
 org.inkscape.Inkscape.desktop
 
# open a file with its default application
$ mimeo Svg_example2.svg

mimeapps.list ファイルへのパスを見つけることもできます:

$ mimeo --mimeapps-list
/home/user/.config/mimeapps.list

ただし、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-mimeoAURxdg-utilsbにパッチを適用し、デスクトップ環境が検出されない場合に xdg-open が mimeo に戻るようにします。

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

handlrxdg-open の代わりに使用するには、次のスクリプトでシャドウします。

#!/usr/bin/bash
handlr open "$@"

clifm

clifm の組み込みリソースオープナーである Lira は、--open コマンドラインオプションを介してスタンドアロンのリソースオープナーとして使用できます。設定ファイル (~/.config/clifm/profiles/PROFILE_NAME/mimelist.clifm) は、MIME タイプとファイル名 (またはファイル拡張子) の両方の正規表現をサポートしています。いくつかの例:

# Open a regular file
clifm --open /etc/hosts

# Open a directory
clifm --open /media/data

# Open an URL (via the application associated to the text/http MIME type in the configuration file)
clifm --open www.archlinux.org

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

以下のパッケージは独自の /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 に委譲されるので、無限ループを引き起こします。