「デスクトップエントリ」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(1版 をインポートしました)
(→‎ファイル例: 訳を修正)
 
(7人の利用者による、間の21版が非表示)
1行目: 1行目:
[[Category:パッケージ開発]
+
[[Category:Freedesktop.org]]
  +
[[Category:設定ファイル]]
  +
[[Category:パッケージ開発]]
 
[[en:Desktop entries]]
 
[[en:Desktop entries]]
  +
[[ru:Desktop entries]]
デスクトップエントリは [[Xorg|X Window System]] で動作するプログラムの挙動を指定する [http://www.freedesktop.org/wiki/ freedesktop.org] の仕様です。デスクトップエントリは設定ファイルとしてアプリケーションの起動方法やメニューとアイコンの表示方法を定義します。最も一般的なデスクトップエントリは {{ic|.desktop}} と {{ic|.directory}} ファイルです。この記事では有用な標準仕様のデスクトップエントリを作成する方法を簡単に説明します。主にパッケージ作成者やメンテナを対象にしていますが、ソフトウェアの開発者なども読む価値があると思われます。
 
  +
[[zh-hans:Desktop entries]]
  +
[https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html XDG デスクトップエントリ仕様]は、[https://specifications.freedesktop.org/menu-spec/menu-spec-latest.html XDG Desktop Menu] 仕様を実装している[[デスクトップ環境]]のアプリケーションメニューにアプリケーションを統合するための規格です。
   
  +
== 基本 ==
デスクトップエントリには大きくわけて3つのタイプがあります:
 
   
  +
デスクトップエントリには、1つの {{ic|Type}} キーと1つの {{ic|Name}} キーが含まれていなければなりません。オプションで、アプリケーションメニューでの見た目を定義することができます。
; アプリケーション : アプリケーションのショートカット
 
; リンク : ウェブリンクのショートカット。
 
; ディレクトリ : メニューエントリのメタデータのコンテナ。
 
   
  +
{{ic|Type}} に指定できるタイプは3つあります:
以下のセクションではこれらのエントリを作成したり修正する方法をざっと説明しています。
 
  +
  +
;Application
  +
:どのようにしてアプリケーションを起動するかや、どの MIME タイプをサポートするかを定義します (MIME タイプの記述は [[XDG MIME Applications]] により使用されます)。[[XDG 自動起動]]を使えば、アプリケーションエントリを特定のディレクトリに配置することにより、そのエントリを[[自動起動]]させることができます。アプリケーションエントリは、ファイル拡張子 {{ic|.desktop}} を使用します。[[#アプリケーションエントリ]] を見てください。
  +
  +
;Link
  +
:{{ic|URL}} へのショートカットを定義します。リンクエントリは、ファイル拡張子 {{ic|.desktop}} を使用します。
  +
  +
;Directory
  +
:アプリケーションメニューでのサブメニューの見た目を定義します。ディレクトリエントリは、ファイル拡張子 {{ic|.directory}} を使用します。
  +
  +
以下のセクションでは、これらのエントリの作成や検証の方法について大まかに説明します。
   
 
== アプリケーションエントリ ==
 
== アプリケーションエントリ ==
   
アプリケーションのデスクトップエントリ、または {{ic|.desktop}} ファイルは、基本的にメタ情報の集合でありアプリケーションのショートカットです。これらのファイルは基本的に、システム全体でインストールしたアプリケーションなら {{ic|/usr/share/applications}} または {{ic|/usr/local/share/applications}} に、ユーザー個別にインストールしたアプリケーションなら {{ic|~/.local/share/applications}} に入っています。ユーザーのエントリはシステムのエントリよりも優先されます。
+
アプリケーションのデスクトップエントリ ({{ic|.desktop}} ファイル) は、基本的にメタ情報リソースの集合でありアプリケーションのショートカットです。通常、これらのファイルは、システム全体でインストールしたアプリケーションなら {{ic|/usr/share/applications}} {{ic|/usr/local/share/applications}} に、ユーザ固有のアプリケーションなら {{ic|~/.local/share/applications}} に入っています。ユーザーのエントリはシステムのエントリよりも優先されます。
   
=== サンプルファイル ===
+
=== ファイル ===
   
  +
以下は、コメントを追加したデスクトップエントリの構成のサンプルです。このサンプルは雰囲気を伝えるだけのものであり、利用可能なエントリキー全ての使い方を示してはいません。完全なキーのリストは [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys freedesktop 仕様] を見てください。
Following is an example of its structure with additional comments. The example is only meant to give a quick impression, and does not show how to utilize all possible entry keys. The complete list of keys can be found in the [http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html freedesktop.org specification].
 
   
 
[Desktop Entry]
 
[Desktop Entry]
  +
Type=Application # Indicates the type as listed above
 
  +
# 前の章でリストアップしたタイプ
Version=1.0 # The version of the desktop entry specification to which this file complies
 
  +
Type=Application
Name=jMemorize # The name of the application
 
  +
Comment=Flash card based learning tool # A comment which can/will be used as a tooltip
 
  +
# このファイルが準拠しているデスクトップエントリ仕様のバージョン
Exec=jmemorize # The executable of the application.
 
  +
Version=1.0
Icon=jmemorize # The name of the icon that will be used to display this entry
 
  +
Terminal=false # Describes whether this application needs to be run in a terminal or not
 
  +
# アプリケーションの名前
Categories=Education;Languages;Java; # Describes the categories in which this entry should be shown
 
  +
Name=jMemorize
  +
  +
# ツールチップとして利用できる/されるコメント
  +
Comment=Flash card based learning tool
  +
  +
# 実行ファイルが存在するフォルダへのパス
  +
Path=/opt/jmemorise
  +
  +
# アプリケーションの実行可能ファイル。引数を付けることができます。
  +
Exec=jmemorize
  +
  +
# エントリを表示するときに使われるアイコンの名前
  +
Icon=jmemorize
  +
  +
# アプリケーションをターミナルで実行する必要があるかどうかを記述
  +
Terminal=false
  +
  +
# このエントリをどのカテゴリで表示すべきかを記述
  +
Categories=Education;Languages;Java;
  +
  +
{{Note|必須のキーは {{ic|Type}} と {{ic|Name}} だけです。}}
   
 
=== キーの定義 ===
 
=== キーの定義 ===
   
All Desktop recognized desktop entries can be found [http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html on the freedesktop.org site].
+
[https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys freedesktop] のサイトに、認識される全てのデスクトップエントリが記載されています。
  +
例えば、{{Ic|Type}} キーは3つのタイプのデスクトップエントリを定義します: アプリケーション (Application, タイプ1), リンク (Link, タイプ2), ディレクトリ (Directory, タイプ3)。
For example, the {{Ic|Type}} key defines three types of desktop entries: Application (type 1), Link (type 2) and Directory (type 3).
 
   
  +
* {{Ic|Version}} キーはアプリケーションのバージョンを表すものではなく、デスクトップエントリが準拠しているデスクトップエントリ規格のバージョンを指定します。
* {{Ic|Version}} key does not stand for the version of the application, but for the version of the desktop entry specification to which this file complies.
 
   
* {{Ic|Name}}, {{Ic|GenericName}} and {{Ic|Comment}} often contain redundant values in the form of combinations of them, like:
+
* {{Ic|Name}}, {{Ic|GenericName}}, {{Ic|Comment}} はしばしば以下のように同じような値が使われることがありますが:
   
 
Name=Pidgin Internet Messenger
 
Name=Pidgin Internet Messenger
 
GenericName=Internet Messenger
 
GenericName=Internet Messenger
  +
または:
or
 
 
Name=NoteCase notes manager
 
Name=NoteCase notes manager
 
Comment=Notes Manager
 
Comment=Notes Manager
   
  +
上記のような設定はユーザーを混乱させるだけなので避けるべきです。{{Ic|Name}} キーにはアプリケーションの名前 (あるいはその省略語や頭字語) だけを書いてください。
This should be avoided, as it will only be confusing to users. The {{Ic|Name}} key should only contain the name, or maybe an abbreviation/acronym if available.
 
   
* {{Ic|GenericName}} should state what you would generally call an application that does what this specific application offers (i.e. Firefox is a "Web Browser").
+
* {{Ic|GenericName}} にはアプリケーションがどのようなものなのかを示す名称を指定するべきです (例えば Firefox なら "Web Browser")
  +
* {{Ic|Comment}} には何らかの追加情報を記入することを意図しています。
* {{Ic|Comment}} is intended to contain any usefull additional information.
 
   
==== 非推奨 ====
+
=== 検証 ===
   
  +
いくつかのキーは非推奨となっているので、{{man|1|desktop-file-validate}} を使ってデスクトップエントリを検証する必要があるかもしれません。このツールは {{Pkg|desktop-file-utils}} パッケージに含まれています。エントリを検証するには、以下を実行してください:
There are quite some keys that have become deprecated over time as the standard has matured. The best/simplest way is to use the tool {{Ic|desktop-file-validate}} which is part of the package {{Pkg|desktop-file-utils}}. To validate, run
 
  +
$ desktop-file-validate <your desktop file>
 
  +
$ desktop-file-validate <''デスクトップファイル''>
This will give you very verbose and useful warnings and error messages.
 
  +
  +
上記のコマンドで詳細かつ有用な警告・エラーメッセージが表示されます。
  +
  +
=== インストール ===
  +
  +
対象のディレクトリに desktop ファイルをインストールするには、{{man|1|desktop-file-install}} を使ってください。例えば:
  +
$ desktop-file-install --dir=$HOME/.local/share/applications ~/app.desktop
  +
  +
=== デスクトップエントリデータベースの更新 ===
  +
  +
{{ic|~/.local/share/applications}} で定義されているデスクトップエントリを機能させるには、以下のコマンドを実行してください:
  +
  +
$ update-desktop-database ~/.local/share/applications
  +
  +
{{Tip|{{ic|-v}} (verbose) 引数を追加すると、デスクトップエントリのエラーを表示します。}}
   
 
== アイコン ==
 
== アイコン ==
  +
  +
[https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html Icon Theme Specification] も参照してください。
   
 
=== 一般的な画像フォーマット ===
 
=== 一般的な画像フォーマット ===
62行目: 113行目:
   
 
{| class="wikitable" align="center"
 
{| class="wikitable" align="center"
|+ [http://standards.freedesktop.org/icon-theme-spec/latest/ar01s02.html freedesktop.org の仕様] で指定されているアイコンとしてサポートされる画像フォーマット
+
|+ freedesktop.org 仕様で指定されているアイコンとしてサポートされる画像フォーマット
 
! 拡張子
 
! 拡張子
 
! フルネームまたは説明
 
! フルネームまたは説明
72行目: 123行目:
 
| Portable Network Graphics
 
| Portable Network Graphics
 
| [[wikipedia:Raster graphics|ラスタ]]
 
| [[wikipedia:Raster graphics|ラスタ]]
  +
| {{No}}
| bgcolor="red" | no
 
  +
| {{Yes}}
| bgcolor="#00cc00"| yes
 
 
|-
 
|-
 
!align="left" | .[[wikipedia:ja:Scalable Vector Graphics|svg(z)]]
 
!align="left" | .[[wikipedia:ja:Scalable Vector Graphics|svg(z)]]
 
| Scalable Vector Graphics
 
| Scalable Vector Graphics
 
| [[wikipedia:Vector graphics|ベクタ]]
 
| [[wikipedia:Vector graphics|ベクタ]]
  +
| {{No}}
| bgcolor="red" | no
 
  +
| {{G|Yes (オプション)}}
| bgcolor="#66cc00"| yes (optional)
 
 
|-
 
|-
 
!align="left" | .[[wikipedia:X PixMap|xpm]]
 
!align="left" | .[[wikipedia:X PixMap|xpm]]
 
| X PixMap
 
| X PixMap
 
| [[wikipedia:Raster graphics|ラスタ]]
 
| [[wikipedia:Raster graphics|ラスタ]]
  +
| {{No}}
| bgcolor="red" | no
 
  +
| {{Y|Yes (非推奨)}}
| bgcolor="yellow"| yes (deprecated)
 
 
|-
 
|-
 
!align="left" | .[[wikipedia:Graphics Interchange Format|gif]]
 
!align="left" | .[[wikipedia:Graphics Interchange Format|gif]]
 
| Graphics Interchange Format
 
| Graphics Interchange Format
 
| [[wikipedia:Raster graphics|ラスタ]]
 
| [[wikipedia:Raster graphics|ラスタ]]
  +
| {{No}}
| bgcolor="red" | no
 
  +
| {{No}}
| bgcolor="red"| no
 
 
|-
 
|-
 
!align="left" | .[[wikipedia:ICO (icon image file format)|ico]]
 
!align="left" | .[[wikipedia:ICO (icon image file format)|ico]]
 
| MS Windows Icon Format
 
| MS Windows Icon Format
 
| [[wikipedia:Raster graphics|ラスタ]]
 
| [[wikipedia:Raster graphics|ラスタ]]
  +
| {{Yes}}
| bgcolor="#00cc00" | yes
 
  +
| {{No}}
| bgcolor="red"| no
 
 
|-
 
|-
 
!align="left" | .[[wikipedia:Apple Icon Image|icns]]
 
!align="left" | .[[wikipedia:Apple Icon Image|icns]]
 
| Apple Icon Image
 
| Apple Icon Image
 
| [[wikipedia:Raster graphics|ラスタ]]
 
| [[wikipedia:Raster graphics|ラスタ]]
  +
| {{Yes}}
| bgcolor="#00cc00"| yes
 
  +
| {{No}}
| bgcolor="red"| no
 
 
|-
 
|-
 
|}
 
|}
109行目: 160行目:
 
=== アイコンの変換 ===
 
=== アイコンの変換 ===
   
  +
({{ic|gif}} や {{ic|ico}} など) freedesktop.org の仕様でサポートされていないフォーマットのアイコンしか見つからなかった場合、''convert'' ツールでサポート/推奨されているフォーマットに変換できます (''convert'' は {{Pkg|imagemagick}} パッケージに含まれています):
If you stumble across an icon which is in a format that is not supported by the freedesktop.org standard (like ''gif'' or ''ico''), you can '''convert''' (which is part of the '''imagemagick''' package) it to a supported/recommended format, e.g.:
 
  +
$ convert <icon name>.gif <icon name>.png
 
  +
$ convert <アイコン名>.gif <アイコン名>.png
If you convert from a container format like ''ico'', you will get all images that were encapsulated in the ''ico'' file in the form ''<icon name>-<number>.png''.
 
  +
If you want to know the size of the image, or the number of images in a container file like ''ico'' you can use '''identify''' (also part of the '''imagemagick''' package)
 
  +
{{ic|ico}} などのコンテナフォーマットから変換した場合、{{ic|<icon name>-<number>.png}} という名前で {{ic|ico}} ファイルにカプセル化されていた画像が取得できます。画像のサイズや {{ic|ico}} などのコンテナに含まれている画像の数を調べたいときは ({{Pkg|imagemagick}} パッケージに含まれている) ''identify'' を使います:
$ identify /usr/share/vlc/vlc48x48.ico
 
  +
/usr/share/vlc/vlc48x48.ico[0] ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb
 
/usr/share/vlc/vlc48x48.ico[1] ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb
+
{{hc|$ identify /usr/share/vlc/vlc48x48.ico|
/usr/share/vlc/vlc48x48.ico[2] ICO 128x128 128x128+0+0 8-bit DirectClass 84.3kb
+
/usr/share/vlc/vlc48x48.ico[0] ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb
/usr/share/vlc/vlc48x48.ico[3] ICO 48x48 48x48+0+0 8-bit DirectClass 84.3kb
+
/usr/share/vlc/vlc48x48.ico[1] ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb
/usr/share/vlc/vlc48x48.ico[4] ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb
+
/usr/share/vlc/vlc48x48.ico[2] ICO 128x128 128x128+0+0 8-bit DirectClass 84.3kb
/usr/share/vlc/vlc48x48.ico[5] ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb
+
/usr/share/vlc/vlc48x48.ico[3] ICO 48x48 48x48+0+0 8-bit DirectClass 84.3kb
  +
/usr/share/vlc/vlc48x48.ico[4] ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb
As you can see, the example ''ico'' file, although its name might suggest a single image of size 48x48, contains no less than 6 different sizes, of which one is even greater than 48x48, namely 128x128. And to give a bit of motivation on this subject, at the point of writing this section (2008-10-27), the 128x128 size was missing in the ''vlc'' package (0.9.4-2). So the next step would be to look at the vlc PKGBUILD and check whether this icon format was not in the source package to begin with (in that case we would inform the vlc developers), or whether this icon was somehow omitted from the Arch-specific package (in that case we can file a bug report at [https://bugs.archlinux.org/ the Arch Linux bug tracker]).
 
  +
/usr/share/vlc/vlc48x48.ico[5] ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb
(''Update:'' this bug has now been [https://bugs.archlinux.org/task/11923 fixed], so as you can see, your work will not be in vain.)
 
  +
}}
  +
  +
上記の ''ico'' ファイルでは、ファイル名からは 48x48 の画像しか含まれていないように見えますが、実は6つのサイズの画像が含まれていて、中には 48x48 よりも大きな 128x128 の画像もあります。
  +
  +
あるいは、''icotool'' ({{Pkg|icoutils}} にあり) を使って ico コンテナから png イメージを抽出できます:
  +
$ icotool -x <icon name>.ico
  +
  +
.icns コンテナからイメージを展開する場合、''icns2png'' ({{Pkg|libicns}} により提供) を使うことができます:
  +
$ icns2png -x <icon name>.icns
   
 
=== アイコンの取得 ===
 
=== アイコンの取得 ===
   
  +
大抵 ''.desktop'' ファイルが付属しているパッケージにはアイコンが含まれていますが、アイコンは存在するのに ''.desktop'' ファイルが開発者によって作られていない場合もあります。まずはソースパッケージの中にアイコンが存在しないか確認すると良いでしょう。
Although packages that already ship with a .desktop-file most certainly contain an icon or a set of icons, there is sometimes the case when a developer has not created a .desktop-file, but may ship icons, nonetheless. So a good start is to look for icons in the source package.
 
  +
ソースパッケージの中に大量の画像が存在するときは、'''find''' を使って拡張子でファイルを絞り込んで、それから '''grep''' を使ってパッケージ名や "icon" あるいは "logo" などのキーワードで検索をかけましょう:
You can i.e. first filter for the extension with '''find''' and then use '''grep''' to filter further for certain buzzwords like the package name, "icon", "logo", etc, if there are quite a lot of images in the source package.
 
 
$ find /path/to/source/package -regex ".*\.\(svg\|png\|xpm\|gif\|ico\)$"
 
$ find /path/to/source/package -regex ".*\.\(svg\|png\|xpm\|gif\|ico\)$"
  +
アプリケーションの開発者がソースパッケージにアイコンを含めていないときは、アプリケーションのウェブサイトを検索しましょう。{{AUR|tvbrowser}} など、プロジェクトによってはウェブサイトに [https://enwiki.tvbrowser.org/index.php/Banners,_Logos_and_other_Promotion_Material アートワーク/ロゴのページ] が存在しアイコンをダウンロードすることができます。プロジェクトがマルチプラットフォームの場合、Linux/UNIX パッケージにアイコンが付属していなくても、Windows パッケージには存在する可能性があります。プロジェクトが CVS や SVN などの[[wikipedia:Version control system|バージョン管理システム]]を使用している場合、リポジトリにアイコンが存在しないか確認してください。
If the developers of an application do not include icons in their source packages, the next step would be to search on their web sites.
 
  +
どうやっても見つからないのであれば、プロジェクトにまだアイコンやロゴがないのかもしれません。
Some projects, like i.e. ''tvbrowser'' have an [http://enwiki.tvbrowser.org/index.php/Banners,_Logos_and_other_Promotion_Material artwork/logo page] where additional icons may be found. If a project is multi-platform, there may be the case that even if the linux/unix package does not come with an icon, the Windows package might provide one. If the project uses a [[wikipedia:Version control system|Version control system]] like CVS/SVN/etc. and you have some experience with it, you also might consider browsing it for icons.
 
  +
If everything fails, the project might simple have no icon/logo yet.
 
  +
=== アイコンのパス ===
  +
  +
[https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html freedesktop.org 仕様]は、プログラムがアイコンを探索するディレクトリと、探索する順番を規定しています:
  +
# {{ic|$HOME/.icons}} (後方互換性のため)
  +
# {{ic|$XDG_DATA_DIRS/icons}}
  +
# {{ic|/usr/share/pixmaps}}
   
 
== ツール ==
 
== ツール ==
  +
  +
=== Arronax ===
  +
  +
[https://www.florian-diesch.de/software/arronax/ Arronax] は、アプリケーションやショートカットのデスクトップエントリを作成/変更するためのグラフィカルなプログラムです。使用するには {{AUR|arronax}} を[[インストール]]してください。
  +
  +
=== Alacarte ===
  +
  +
{{Pkg|alacarte}} は [[GNOME]] のためのグラフィカルなメニューエディタで、freedesktop.org のメニュー仕様を使用します。デスクトップエントリのオーバーライドもサポートしています。
  +
  +
=== jdDesktopEntryEdit ===
  +
  +
{{AUR|jddesktopentryedit}} は、デスクトップエントリを編集するための、[[Qt]] を使用するグラフィカルプログラムです。
   
 
=== gendesk ===
 
=== gendesk ===
{{Pkg|gendesk}} started as an Arch Linux-specific tool for generating .desktop files by fetching the needed information directly from PKGBUILD files. Now it is a general tool that takes command-line arguments.
 
   
  +
{{Pkg|gendesk}} は PKGBUILD ファイルから直接情報を取得して .desktop ファイルを生成する Arch Linux 専用のツールとして開発がスタートしました。今ではコマンドライン引数を使用する汎用のツールとなっています。
Icons can be automatically downloaded from [http://openiconlibrary.sourceforge.net/ openiconlibrary], if available. (The source for icons can easily be changed in the future).
 
  +
  +
アイコンは [http://openiconlibrary.sourceforge.net/ openiconlibrary] から自動的にダウンロードすることが可能です (アイコンのソースは将来変更される可能性があります)。
   
==== 使用法 ====
+
==== 使用法 ====
   
* Add {{Ic|gendesk}} to makedepends
+
* {{Ic|gendesk}} makedepends に追加
   
* Start the {{Ic|prepare()}} function with:
+
* {{Ic|prepare()}} 関数に以下を記入:
   
 
{{bc|gendesk --pkgname "$pkgname" --pkgdesc "$pkgdesc"}}
 
{{bc|gendesk --pkgname "$pkgname" --pkgdesc "$pkgdesc"}}
   
  +
* もしくは、アイコンが既に含まれている場合 (例: $pkgname.png)、アイコンをダウンロードしない、あるいはデフォルトのアイコンを使うために {{Ic|-n}} フラグを使います。例:
* Alternatively, if an icon is already provided ($pkgname.png, for instance). The {{Ic|-n}} flag is for not downloading an icon or using the default icon. Example:
 
   
 
{{bc|gendesk -n --pkgname "$pkgname" --pkgdesc "$pkgdesc"}}
 
{{bc|gendesk -n --pkgname "$pkgname" --pkgdesc "$pkgdesc"}}
   
* {{Ic|$srcdir/$pkgname.desktop}}&nbsp;will be created and can be installed in the {{Ic|package()}} function with:
+
* 作成された {{Ic|$srcdir/$pkgname.desktop}} {{Ic|package()}} 関数でインストールします:
   
 
{{bc|install -Dm644 "$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"}}
 
{{bc|install -Dm644 "$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"}}
   
  +
* アイコンをインストールするには:
* The icon can be installed with:
 
   
 
{{bc|install -Dm644 "$pkgname.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"}}
 
{{bc|install -Dm644 "$pkgname.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"}}
   
* Use {{Ic|1=--name='Program Name'}} for choosing a name for the menu entry.
+
* {{Ic|1=--name='Program Name'}} でメニューエントリの名前を決めることができます。
   
* Use {{Ic|1=--exec='/opt/some_app/elf --with-ponies'}} for setting the exec field.
+
* {{Ic|1=--exec='/opt/some_app/elf --with-ponies'}} exec フィールドを設定することができます。
   
* See the [https://github.com/xyproto/gendesk gendesk project] for more information.
+
* 詳しくは [https://github.com/xyproto/gendesk gendesk プロジェクト] を参照。
  +
  +
=== lsdesktopf ===
  +
  +
{{AUR|lsdesktopf}} は、利用可能な ''.desktop'' ファイルを一覧表示したり、エントリの内容を検索したりできます。
  +
  +
$ lsdesktopf
  +
$ lsdesktopf --list
  +
$ lsdesktopf --list gtk zh_TW,zh_CN,en_GB
  +
  +
MIME タイプ関連の検索を行うこともできます。[[XDG MIME Applications#lsdesktopf]] を見てください。
  +
  +
=== fbrokendesktop ===
  +
  +
{{AUR|fbrokendesktop}} Bash スクリプトは、既存のパスを指していない壊れた {{ic|Exec}} の値を検出します。パラメータを指定しなかった場合、fbrokendesktop は {{ic|DskPath}} 配列のプリセットフォルダを使います。破損している ''.desktop'' だけを完全なパスとファイル名と共に表示します。
  +
  +
例:
  +
  +
$ fbrokendesktop
  +
$ fbrokendesktop /usr
  +
$ fbrokendesktop /usr/share/xsessions/icewm.desktop
  +
  +
== ヒントとテクニック ==
  +
  +
=== ターミナルから desktop ファイルを実行する ===
  +
  +
{{Pkg|gtk3}} がインストールされている場合、{{ic|gtk-launch ''application.desktop''}} と実行してください。
  +
  +
あるいは、{{Pkg|dex}} パッケージをインストールして、{{ic|dex ''/path/to/application.desktop''}} と実行してください。
  +
  +
=== desktop ファイルの変更 ===
  +
  +
システム全体で使用される ''.desktop'' ファイル (例えば、パッケージからインストールしたもの) を変更したい場合、まず関連する ''.desktop'' ファイルを {{ic|$XDG_DATA_HOME/applications/}} にコピーしてください (例えば、{{ic|/usr/share/applications/}} から {{ic|~/.local/share/applications/}} へ)。こうすることで、[[システムメンテナンス#システムのアップグレード|システムのアップグレード]]の際に対象のパッケージがアップデートされても、あなたが加えた変更が上書きされることはありません。ローカルのユーザ固有の ''.desktop'' ファイルは、自動的にシステム全体の ''.desktop'' ファイルよりも優先されるはずです。これで、必要に応じてローカルのユーザ固有の ''.desktop'' ファイルを変更できます。
  +
  +
{{Note|アプリケーションを自動起動するように設定している場合、[[XDG Autostart]] に従って、{{ic|$XDG_CONFIG_HOME/autostart}} 内にシステムデスクトップエントリのコピーがすでに存在している場合があります。自動起動する場合のみの動作を変更したい場合、このファイルを変更してください。すべての場合における動作を変更したい場合は、以下のことを行う必要があります:
  +
* デスクトップエントリファイルを {{ic|$XDG_CONFIG_HOME/autostart/}} から {{ic|$XDG_DATA_HOME/applications}} に移動する。
  +
* {{ic|ls -l}} を使って、このデスクトップエントリが編集可能な通常のファイルであり、システム関連の場所へのリンクでないことを確認する。リンクである場合は、上記で説明したように元のファイルのコピーに入れ替える。
  +
* ユーザアプリケーションディレクトリ (内のデスクトップエントリ) へのシンボリックリンクを作成する (便宜上、デフォルトの XDG ディレクトリに置き換えています):
  +
  +
ln -s ~/.local/share/applications/''desktop_entry'' ~/.config/autostart/
  +
  +
これで、アプリケーションランチャー内のファイルは、自動起動させるファイルと同じになります。
  +
}}
  +
  +
==== 環境変数の変更 ====
  +
  +
[[環境変数]]を設定するには、{{man|1|env}} コマンドで環境変数を設定するように ''.desktop'' ファイル内の {{ic|1=Exec=}} 行を編集してください。例えば (元の行はコメントアウトされています):
  +
  +
{{hc|~/.local/share/applications/abiword.desktop|2=
  +
...
  +
# Exec=abiword %U
  +
Exec=env LANG=he_IL.UTF-8 abiword %U
  +
...
  +
}}
  +
  +
==== コマンドライン引数の変更 ====
  +
  +
コマンドライン引数を変更または追加するには、{{ic|1=Exec=}} 行を編集し、オプションを追加してください。例 (元の行はコメントアウトされています):
  +
  +
{{hc|~/.local/share/applications/steam.desktop|2=
  +
...
  +
# Exec=/usr/bin/steam-runtime %U
  +
Exec=/usr/bin/steam-runtime -no-browser %U
  +
...
  +
}}
  +
  +
==== デスクトップエントリの隠匿 ====
  +
  +
デスクトップエントリの可視性は、複数の方法で制御できます。詳細は [https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys Desktop Entry Specification] を見てください。以下の内容のうち1つを ''.desktop'' ファイルに[[追加]]してください:
  +
* ''全ての''デスクトップ環境に適用。以下のうち1つ (あるいは両方) を選んでください:
  +
** メニューに表示したくないアプリケーションに対して {{ic|1=NoDisplay=true}} 行を追加する。
  +
** 削除済みでありメニューに表示したくないアプリケーションに対して {{ic|1=Hidden=true}} 行を追加する。
  +
* デスクトップ環境を''指定''。以下のうち1つを選んでください。{{ic|''desktop_names''}} の部分はデスクトップ環境のリストであり、セミコロンで区切ってください (例: {{ic|GNOME}}, {{ic|GNOME;Xfce;KDE;}}):
  +
** {{ic|1=NotShowIn=''desktop_names''}} 行を追加すると、指定したデスクトップ環境でエントリを''隠し''ます。
  +
** {{ic|1=OnlyShowIn=''desktop_names''}} 行を追加すると、指定したデスクトップ環境でのみエントリを''表示''します。
   
 
== 参照 ==
 
== 参照 ==
   
* [[DeveloperWiki:Removal of desktop files]]
+
* [[Wikipedia:.desktop]]
  +
* [https://freedesktop.org/wiki/Howto_desktop_files/ 開発者向けの情報]
* [[Wikipedia:.desktop|desktop wikipedia article]]
 
  +
* [http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html recognized desktop entry keys]
 
  +
{{TranslationStatus|Desktop entries|2023-05-14|776650}}
* [http://freedesktop.org/wiki/Specifications/desktop-entry-spec freedesktop.org desktop entry specification]
 
* [http://freedesktop.org/wiki/Specifications/icon-theme-spec freedesktop.org icon theme specification]
 
* [http://freedesktop.org/wiki/Specifications/menu-spec freedesktop.org menu specification]
 
* [http://freedesktop.org/wiki/Specifications/basedir-spec freedesktop.org basedir specification]
 
* [http://freedesktop.org/wiki/Howto_desktop_files information for developers]
 

2024年4月20日 (土) 15:23時点における最新版

XDG デスクトップエントリ仕様は、XDG Desktop Menu 仕様を実装しているデスクトップ環境のアプリケーションメニューにアプリケーションを統合するための規格です。

基本

デスクトップエントリには、1つの Type キーと1つの Name キーが含まれていなければなりません。オプションで、アプリケーションメニューでの見た目を定義することができます。

Type に指定できるタイプは3つあります:

Application
どのようにしてアプリケーションを起動するかや、どの MIME タイプをサポートするかを定義します (MIME タイプの記述は XDG MIME Applications により使用されます)。XDG 自動起動を使えば、アプリケーションエントリを特定のディレクトリに配置することにより、そのエントリを自動起動させることができます。アプリケーションエントリは、ファイル拡張子 .desktop を使用します。#アプリケーションエントリ を見てください。
Link
URL へのショートカットを定義します。リンクエントリは、ファイル拡張子 .desktop を使用します。
Directory
アプリケーションメニューでのサブメニューの見た目を定義します。ディレクトリエントリは、ファイル拡張子 .directory を使用します。

以下のセクションでは、これらのエントリの作成や検証の方法について大まかに説明します。

アプリケーションエントリ

アプリケーションのデスクトップエントリ (.desktop ファイル) は、基本的にメタ情報リソースの集合であり、アプリケーションのショートカットです。通常、これらのファイルは、システム全体でインストールしたアプリケーションなら /usr/share/applications/usr/local/share/applications に、ユーザ固有のアプリケーションなら ~/.local/share/applications に入っています。ユーザーのエントリはシステムのエントリよりも優先されます。

ファイル例

以下は、コメントを追加したデスクトップエントリの構成のサンプルです。このサンプルは雰囲気を伝えるだけのものであり、利用可能なエントリキー全ての使い方を示してはいません。完全なキーのリストは freedesktop 仕様 を見てください。

[Desktop Entry]

# 前の章でリストアップしたタイプ
Type=Application

# このファイルが準拠しているデスクトップエントリ仕様のバージョン
Version=1.0

# アプリケーションの名前
Name=jMemorize

# ツールチップとして利用できる/されるコメント
Comment=Flash card based learning tool

# 実行ファイルが存在するフォルダへのパス
Path=/opt/jmemorise

# アプリケーションの実行可能ファイル。引数を付けることができます。
Exec=jmemorize

# エントリを表示するときに使われるアイコンの名前
Icon=jmemorize

# アプリケーションをターミナルで実行する必要があるかどうかを記述
Terminal=false

# このエントリをどのカテゴリで表示すべきかを記述
Categories=Education;Languages;Java;
ノート: 必須のキーは TypeName だけです。

キーの定義

freedesktop のサイトに、認識される全てのデスクトップエントリが記載されています。 例えば、Type キーは3つのタイプのデスクトップエントリを定義します: アプリケーション (Application, タイプ1), リンク (Link, タイプ2), ディレクトリ (Directory, タイプ3)。

  • Version キーはアプリケーションのバージョンを表すものではなく、デスクトップエントリが準拠しているデスクトップエントリ規格のバージョンを指定します。
  • Name, GenericName, Comment はしばしば以下のように同じような値が使われることがありますが:
Name=Pidgin Internet Messenger
GenericName=Internet Messenger

または:

Name=NoteCase notes manager
Comment=Notes Manager

上記のような設定はユーザーを混乱させるだけなので避けるべきです。Name キーにはアプリケーションの名前 (あるいはその省略語や頭字語) だけを書いてください。

  • GenericName にはアプリケーションがどのようなものなのかを示す名称を指定するべきです (例えば Firefox なら "Web Browser")。
  • Comment には何らかの追加情報を記入することを意図しています。

検証

いくつかのキーは非推奨となっているので、desktop-file-validate(1) を使ってデスクトップエントリを検証する必要があるかもしれません。このツールは desktop-file-utils パッケージに含まれています。エントリを検証するには、以下を実行してください:

$ desktop-file-validate <デスクトップファイル>

上記のコマンドで詳細かつ有用な警告・エラーメッセージが表示されます。

インストール

対象のディレクトリに desktop ファイルをインストールするには、desktop-file-install(1) を使ってください。例えば:

$ desktop-file-install --dir=$HOME/.local/share/applications ~/app.desktop

デスクトップエントリデータベースの更新

~/.local/share/applications で定義されているデスクトップエントリを機能させるには、以下のコマンドを実行してください:

$ update-desktop-database ~/.local/share/applications
ヒント: -v (verbose) 引数を追加すると、デスクトップエントリのエラーを表示します。

アイコン

Icon Theme Specification も参照してください。

一般的な画像フォーマット

以下はアイコンとしてよく使われている画像フォーマットの簡単な概要です。

freedesktop.org 仕様で指定されているアイコンとしてサポートされる画像フォーマット。
拡張子 フルネームまたは説明 グラフィック形式 コンテナフォーマット サポート
.png Portable Network Graphics ラスタ No Yes
.svg(z) Scalable Vector Graphics ベクタ No Yes (オプション)
.xpm X PixMap ラスタ No Yes (非推奨)
.gif Graphics Interchange Format ラスタ No No
.ico MS Windows Icon Format ラスタ Yes No
.icns Apple Icon Image ラスタ Yes No

アイコンの変換

(gifico など) freedesktop.org の仕様でサポートされていないフォーマットのアイコンしか見つからなかった場合、convert ツールでサポート/推奨されているフォーマットに変換できます (convertimagemagick パッケージに含まれています):

$ convert <アイコン名>.gif <アイコン名>.png

ico などのコンテナフォーマットから変換した場合、<icon name>-<number>.png という名前で ico ファイルにカプセル化されていた画像が取得できます。画像のサイズや ico などのコンテナに含まれている画像の数を調べたいときは (imagemagick パッケージに含まれている) identify を使います:

$ identify /usr/share/vlc/vlc48x48.ico
/usr/share/vlc/vlc48x48.ico[0] ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb
/usr/share/vlc/vlc48x48.ico[1] ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb
/usr/share/vlc/vlc48x48.ico[2] ICO 128x128 128x128+0+0 8-bit DirectClass 84.3kb
/usr/share/vlc/vlc48x48.ico[3] ICO 48x48 48x48+0+0 8-bit DirectClass 84.3kb
/usr/share/vlc/vlc48x48.ico[4] ICO 32x32 32x32+0+0 8-bit DirectClass 84.3kb
/usr/share/vlc/vlc48x48.ico[5] ICO 16x16 16x16+0+0 8-bit DirectClass 84.3kb

上記の ico ファイルでは、ファイル名からは 48x48 の画像しか含まれていないように見えますが、実は6つのサイズの画像が含まれていて、中には 48x48 よりも大きな 128x128 の画像もあります。

あるいは、icotool (icoutils にあり) を使って ico コンテナから png イメージを抽出できます:

$ icotool -x <icon name>.ico

.icns コンテナからイメージを展開する場合、icns2png (libicns により提供) を使うことができます:

$ icns2png -x <icon name>.icns

アイコンの取得

大抵 .desktop ファイルが付属しているパッケージにはアイコンが含まれていますが、アイコンは存在するのに .desktop ファイルが開発者によって作られていない場合もあります。まずはソースパッケージの中にアイコンが存在しないか確認すると良いでしょう。 ソースパッケージの中に大量の画像が存在するときは、find を使って拡張子でファイルを絞り込んで、それから grep を使ってパッケージ名や "icon" あるいは "logo" などのキーワードで検索をかけましょう:

$ find /path/to/source/package -regex ".*\.\(svg\|png\|xpm\|gif\|ico\)$"

アプリケーションの開発者がソースパッケージにアイコンを含めていないときは、アプリケーションのウェブサイトを検索しましょう。tvbrowserAUR など、プロジェクトによってはウェブサイトに アートワーク/ロゴのページ が存在しアイコンをダウンロードすることができます。プロジェクトがマルチプラットフォームの場合、Linux/UNIX パッケージにアイコンが付属していなくても、Windows パッケージには存在する可能性があります。プロジェクトが CVS や SVN などのバージョン管理システムを使用している場合、リポジトリにアイコンが存在しないか確認してください。 どうやっても見つからないのであれば、プロジェクトにまだアイコンやロゴがないのかもしれません。

アイコンのパス

freedesktop.org 仕様は、プログラムがアイコンを探索するディレクトリと、探索する順番を規定しています:

  1. $HOME/.icons (後方互換性のため)
  2. $XDG_DATA_DIRS/icons
  3. /usr/share/pixmaps

ツール

Arronax

Arronax は、アプリケーションやショートカットのデスクトップエントリを作成/変更するためのグラフィカルなプログラムです。使用するには arronaxAURインストールしてください。

Alacarte

alacarteGNOME のためのグラフィカルなメニューエディタで、freedesktop.org のメニュー仕様を使用します。デスクトップエントリのオーバーライドもサポートしています。

jdDesktopEntryEdit

jddesktopentryeditAUR は、デスクトップエントリを編集するための、Qt を使用するグラフィカルプログラムです。

gendesk

gendesk は PKGBUILD ファイルから直接情報を取得して .desktop ファイルを生成する Arch Linux 専用のツールとして開発がスタートしました。今ではコマンドライン引数を使用する汎用のツールとなっています。

アイコンは openiconlibrary から自動的にダウンロードすることが可能です (アイコンのソースは将来変更される可能性があります)。

使用法

  • gendesk を makedepends に追加
  • prepare() 関数に以下を記入:
gendesk --pkgname "$pkgname" --pkgdesc "$pkgdesc"
  • もしくは、アイコンが既に含まれている場合 (例: $pkgname.png)、アイコンをダウンロードしない、あるいはデフォルトのアイコンを使うために -n フラグを使います。例:
gendesk -n --pkgname "$pkgname" --pkgdesc "$pkgdesc"
  • 作成された $srcdir/$pkgname.desktoppackage() 関数でインストールします:
install -Dm644 "$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
  • アイコンをインストールするには:
install -Dm644 "$pkgname.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
  • --name='Program Name' でメニューエントリの名前を決めることができます。
  • --exec='/opt/some_app/elf --with-ponies' で exec フィールドを設定することができます。

lsdesktopf

lsdesktopfAUR は、利用可能な .desktop ファイルを一覧表示したり、エントリの内容を検索したりできます。

$ lsdesktopf
$ lsdesktopf --list
$ lsdesktopf --list gtk zh_TW,zh_CN,en_GB

MIME タイプ関連の検索を行うこともできます。XDG MIME Applications#lsdesktopf を見てください。

fbrokendesktop

fbrokendesktopAUR Bash スクリプトは、既存のパスを指していない壊れた Exec の値を検出します。パラメータを指定しなかった場合、fbrokendesktop は DskPath 配列のプリセットフォルダを使います。破損している .desktop だけを完全なパスとファイル名と共に表示します。

例:

$ fbrokendesktop
$ fbrokendesktop /usr
$ fbrokendesktop /usr/share/xsessions/icewm.desktop

ヒントとテクニック

ターミナルから desktop ファイルを実行する

gtk3 がインストールされている場合、gtk-launch application.desktop と実行してください。

あるいは、dex パッケージをインストールして、dex /path/to/application.desktop と実行してください。

desktop ファイルの変更

システム全体で使用される .desktop ファイル (例えば、パッケージからインストールしたもの) を変更したい場合、まず関連する .desktop ファイルを $XDG_DATA_HOME/applications/ にコピーしてください (例えば、/usr/share/applications/ から ~/.local/share/applications/ へ)。こうすることで、システムのアップグレードの際に対象のパッケージがアップデートされても、あなたが加えた変更が上書きされることはありません。ローカルのユーザ固有の .desktop ファイルは、自動的にシステム全体の .desktop ファイルよりも優先されるはずです。これで、必要に応じてローカルのユーザ固有の .desktop ファイルを変更できます。

ノート: アプリケーションを自動起動するように設定している場合、XDG Autostart に従って、$XDG_CONFIG_HOME/autostart 内にシステムデスクトップエントリのコピーがすでに存在している場合があります。自動起動する場合のみの動作を変更したい場合、このファイルを変更してください。すべての場合における動作を変更したい場合は、以下のことを行う必要があります:
  • デスクトップエントリファイルを $XDG_CONFIG_HOME/autostart/ から $XDG_DATA_HOME/applications に移動する。
  • ls -l を使って、このデスクトップエントリが編集可能な通常のファイルであり、システム関連の場所へのリンクでないことを確認する。リンクである場合は、上記で説明したように元のファイルのコピーに入れ替える。
  • ユーザアプリケーションディレクトリ (内のデスクトップエントリ) へのシンボリックリンクを作成する (便宜上、デフォルトの XDG ディレクトリに置き換えています):
ln -s ~/.local/share/applications/desktop_entry ~/.config/autostart/

これで、アプリケーションランチャー内のファイルは、自動起動させるファイルと同じになります。

環境変数の変更

環境変数を設定するには、env(1) コマンドで環境変数を設定するように .desktop ファイル内の Exec= 行を編集してください。例えば (元の行はコメントアウトされています):

~/.local/share/applications/abiword.desktop
...
# Exec=abiword %U
Exec=env LANG=he_IL.UTF-8 abiword %U
...

コマンドライン引数の変更

コマンドライン引数を変更または追加するには、Exec= 行を編集し、オプションを追加してください。例 (元の行はコメントアウトされています):

~/.local/share/applications/steam.desktop
...
# Exec=/usr/bin/steam-runtime %U
Exec=/usr/bin/steam-runtime -no-browser %U
...

デスクトップエントリの隠匿

デスクトップエントリの可視性は、複数の方法で制御できます。詳細は Desktop Entry Specification を見てください。以下の内容のうち1つを .desktop ファイルに追加してください:

  • 全てのデスクトップ環境に適用。以下のうち1つ (あるいは両方) を選んでください:
    • メニューに表示したくないアプリケーションに対して NoDisplay=true 行を追加する。
    • 削除済みでありメニューに表示したくないアプリケーションに対して Hidden=true 行を追加する。
  • デスクトップ環境を指定。以下のうち1つを選んでください。desktop_names の部分はデスクトップ環境のリストであり、セミコロンで区切ってください (例: GNOME, GNOME;Xfce;KDE;):
    • NotShowIn=desktop_names 行を追加すると、指定したデスクトップ環境でエントリを隠します。
    • OnlyShowIn=desktop_names 行を追加すると、指定したデスクトップ環境でのみエントリを表示します。

参照

翻訳ステータス: このページは en:Desktop entries の翻訳バージョンです。最後の翻訳日は 2023-05-14 です。もし英語版に 変更 があれば、翻訳の同期を手伝うことができます。