「X リソース」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(序文を修正)
 
(4人の利用者による、間の14版が非表示)
1行目: 1行目:
[[Category:ドットファイル]]
+
[[Category:設定ファイル]]
 
[[Category:X サーバー]]
 
[[Category:X サーバー]]
 
[[de:Xdefaults]]
 
[[de:Xdefaults]]
 
[[en:X resources]]
 
[[en:X resources]]
  +
[[ru:X resources]]
'''Xresources''' はユーザーレベルの設定''ドットファイル''で、通常は {{ic|~/.Xresources}} に存在します。X クライアントアプリケーションの設定パラメータである [[Wikipedia:X resources|X resources]] を設定するのに使われます。
 
  +
{{Related articles start}}
  +
{{Related|X Logical Font Description}}
  +
{{Related|ドットファイル}}
  +
{{Related articles end}}
  +
'''X リソースファイル''' はユーザーレベルの設定''ドットファイル''で、通常は {{ic|~/.Xresources}} に存在します。X クライアントアプリケーションの設定パラメータである [[Wikipedia:X resources|X resources]] を設定するのに使われます。
   
  +
特に次の目的で使用できます:
Xresources は様々な設定をすることができます、例えば:
 
   
* ターミナルの色の
+
* ターミナル環境(例:ターミナルの色)
  +
* DPI やアンチエイリアス、ヒンティングなど X [[フォント]]の設定
* ターミナルの設定
 
  +
* X [[カーソルテーマ]]の変更
* DPI やアンチエイリアス、ヒンティングなど X フォントの設定
 
* X カーソルテーマの変更
+
* [[xscreensaver]] テーマ設定
  +
* 低水準 X アプリケーションの設定 ({{Pkg|xorg-xclock}}, {{Pkg|xpdf}}, [[rxvt-unicode]] など)
* xscreensaver のテーマ設定
 
* ローレベルな X アプリケーションの設定 ({{Pkg|xorg-xclock}}, {{AUR|xpdf}}, {{Pkg|rxvt-unicode}} など)
 
   
  +
== インストール ==
{{Note|{{ic|~/.Xdefaults}} の使用は非推奨となっているので、この記事では xrdb でロードされる resources のみを扱います。}}
 
   
  +
{{pkg|xorg-xrdb}} パッケージを[[インストール]]してください。
==初めに==
 
{{pkg|xorg-xrdb}} がシステムにインストールされていることを確認してください。
 
   
  +
== 設定 ==
===.Xresources の解析===
 
{{ic|~/.Xresources}} ファイルはデフォルトでは存在しません。プレーンテキストファイルなので、お好きなテキストエディタで作成・編集することができます。ファイルが存在する場合、{{ic|xrdb}} (Xorg resource database) プログラムによって自動的に解析されます。ただし、それには以下のどちらかの条件を満たしている必要があります:
 
* [[ディスプレイマネージャ]]を使って X にログインしている。ほとんどの DM はログイン時に自動的に {{ic|~/.Xresources}} ファイルをロードします。
 
* {{ic|startx}} を使用している場合、{{ic|~/.[[xinitrc]]}} を編集する必要があります。詳しくは下を参照してください。
 
resources は X サーバーに保存されるため、アプリを起動するたびにファイルを読み取る必要はありません。
 
   
  +
{{man|7|X|RESOURCES}} および {{man|3|XrmGetDatabase|FILE SYNTAX}} には、''X リソース''のメカニズムとファイル構文に関する詳細情報が記載されています。
.Xresources ファイルを再読み込みさせて、古い resources を捨てさせるには:
 
   
  +
{{ic|~/.Xresources}} は一般的なファイル名であり、{{ic|xrdb}} はこれを独自に扱っているわけではありません。他のファイル名(例えば {{ic|~/.config/X11/Xresources}} や {{ic|~/.config/X11/Xresources.d/''application-name''}})を使用することもできます([[#サンプル]]および[[#インクルードファイル]]も参照)。
xrdb ~/.Xresources
 
   
  +
=== 基本構文 ===
.Xresources ファイルを再読み込みさせて、古い resources を維持させるには:
 
   
  +
''X リソース''ファイルの構文は以下のような ''リソース行'' のシーケンスです:
xrdb -merge ~/.Xresources
 
   
  +
application_name.Class.resourceName: value
{{Tip|{{ic|~/.Xresources}} is just a naming convention; xrdb can load any file. If you use xrdb manually, you can put such a file anywhere you want (for example, {{ic|~/.config/Xresources}}).}}
 
  +
application_name.resourceName: value
{{Note|Resources loaded with xrdb are also accessible to ''remote'' X11 clients (such as those forwarded over SSH).}}
 
  +
Class.resourceName: value
{{Warning|
 
  +
application_name*resourceName: value
* If you background the execution of xrdb in a chain of commands in {{ic|~/.xinitrc}}, the programs launched in the same chain might not be able to make use of it, so it is recommended to ''never'' background the xrdb command within {{ic|~/.xinitrc}}.
 
  +
*resourceName: value
* The older and deprecated {{ic|~/.Xdefaults}} file is read every time you start an X11 program such as {{ic|xterm}}, but '''only''' if {{ic|xrdb}} has not '''ever''' been used in the current X session. [https://groups.google.com/forum/#!msg/comp.windows.x/hQBEdql8l-Q/hF3DETcIHGwJ]
 
}}
 
 
===xinitrc に追加===
 
[[デスクトップ環境]]を使っていない場合、以下の行を {{ic|~/.[[xinitrc]]}} に追加する必要があります:
 
<nowiki>[[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources</nowiki>
 
 
===デフォルト設定===
 
インストールした X11 アプリのデフォルト設定を確認したいときは、{{ic|/usr/share/X11/app-defaults/}} の中を見て下さい。
 
 
プログラムの resources に関する詳細はプログラムの man ページに大抵記述されています。xterm の man ページなどが良い例で、X resources とデフォルト値のリストが載っています。
 
   
  +
{{ic|application_name}} と {{ic|Class}} のサブストリングにはドット({{ic|.}})は含まれませんが、{{ic|resourceName}} のサブストリングにはドットが含まれる場合があります。例えば、{{ic|Dialog.bodyFont}} は [[XScreenSaver]] の内部リソースであり、本文フォントおよびフォールバックフォントを設定するために指定されます:
現在ロードされている resources を確認するには:
 
xrdb -query -all
 
   
  +
xscreensaver-auth.default.Dialog.bodyFont: times new roman 12, dejavu serif 12
===Xresources の構文===
 
====基本構文====
 
Xresources ファイルの構文は以下の通りです:
 
'''name.Class.resource: value'''
 
実際の例:
 
xscreensaver.Dialog.headingFont: -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1
 
   
  +
;application_name
;name
 
:アプリケーションの名前。xterm xpdf など。
+
:アプリケーションの名前、例えば {{ic|urxvt}}, {{ic|xpdf}}, {{ic|xterm}} など。 ''インスタンス名'' とも呼ばれます
   
  +
;Class
;class
 
  +
:リソースをまとめるために使用される分類。クラス名は通常大文字です。
:The classification used to group resources together. Class names are typically uppercase.
 
   
  +
;resourceName
;resource
 
  +
:値を設定するリソースの名前。リソースは通常、連結された大文字と小文字で表されます。
:The name of the resource whose value is to be changed. Resources are typically lowercase with uppercase concatenation.
 
   
 
;value
 
;value
  +
:リソースの実際の値。これには次の3種類があります:
:The actual value of the resource. This can be 1 of 3 types:
 
  +
:* 整数(整数値)
:* Integer (whole numbers)
 
:* Boolean (true/false, yes/no, on/off)
+
:* ブール値(true/falseyes/noon/off)
:* String (a string of characters) (for example a word ({{ic|white}}), a color ({{ic|#ffffff}}), or a path ({{ic|/usr/bin/firefox}}))
+
:* 文字列(文字の列)— 例えば単語({{ic|white}})、色({{ic|#ffffff}})、またはパス({{ic|/usr/bin/firefox}}
   
  +
;区切り文字
;delimiters
 
  +
* ドット({{ic|.}})は ''tight binding'' であり、直近のコンポーネントを分離するために使用されます(つまり、階層の各ステップを示す)。上記の例では、アプリケーション名から始まり、クラスに降り、最後にリソース自体に降ります。
:A dot ({{ic|'''.'''}}) is used to signify each step down into the hierarchy — in the above example we start at name, then descend into Class, and finally into the resource itself. A colon ({{ic|''':'''}}) is used to separate the resource declaration from the actual value.
 
  +
* アスタリスク({{ic|*}})は ''loose binding'' であり、何らかのコンポーネントを表すために使用されます(含まれない場合もあります)。
  +
* コロン({{ic|:}})はリソース名と値を分離するために使用されます。
   
  +
{{Note|
====ワイルドカードマッチ====
 
  +
* リソースファイル構文の観点から見ると、コロン({{ic|:}})の前にあるものはすべてリソース名です。ユーザーの視点からは、''リソース'' は最も右側のコンポーネントのみを指すことがよくあります。言い換えると、''リソース名'' は ''アプリケーション名''、''Class''、および ''リソース名'' のサブストリングから成る文字列です。これが混乱の原因になるかもしれません。
 
  +
* リソースの命名スキーマは完全にアプリケーションに依存します。あるアプリケーションが {{ic|application_name.Class.resourceName}} を使用する場合、別のアプリケーションは {{ic|application_name.resourceName}} および {{ic|Class.resourceName}} のみを理解するかもしれません。
The asterisk can be used as a wildcard, making it easy to write a single rule that can be applied to many different applications or elements.
 
 
Using the previous example, if you want to apply the same font to all programs (not just XScreenSaver) that contain the class name {{ic|Dialog}} which contains the resource name {{ic|headingFont}}, you would write:
 
 
'''*'''Dialog.headingFont: -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1
 
 
If you want to apply this same rule to all programs that contain the resource {{ic|headingFont}}, regardless of its class, you would write:
 
 
'''*'''headingFont: -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1
 
 
==== コメント ====
 
To add a comment to your Xresources file, simply prefix it with an exclamation mark ({{ic|!}}), for example:
 
 
! This is a comment placed above some Xft settings
 
Xft.dpi: 96 ! this is an inline comment
 
 
! The following rule will be ignored because it has been commented out
 
!Xft.antialias: true
 
 
==== ファイルのインクルード ====
 
 
To use different files for each application, use {{ic|#include}} in the main file. For example:
 
 
{{hc|~/.Xresources|
 
#include ".Xresources.d/xterm"
 
#include ".Xresources.d/rxvt-unicode"
 
#include ".Xresources.d/fonts"
 
#include ".Xresources.d/xscreensaver"
 
 
}}
 
}}
   
  +
=== ワイルドカードマッチング ===
If files fail to load, specify the directory to ''xrdb'' with the {{ic|-I}} parameter. For example:
 
   
  +
クエスチョンマーク({{ic|?}})とアスタリスク({{ic|*}})はワイルドカードとして使用でき、多くの異なるアプリケーションや要素に適用できる単一のルールを書くのが簡単になります。{{ic|?}} は任意の単一のコンポーネント名に一致し、{{ic|*}} は任意の数の中間コンポーネントを含むものに一致します。
{{hc|~/.xinitrc|
 
xrdb -I''$HOME'' ~/.Xresources
 
}}
 
   
  +
前述の例を使用して、クラス名に {{ic|Dialog}} を含むすべてのプログラムに同じフォントを適用したい場合(XScreenSaver に限らず)、次のように書くことができます:
==使用例==
 
The following samples should provide a good understanding of how application settings can be modified using an Xresources file. For full details, refer to the man page of the application in question.
 
   
  +
'''?'''.Dialog.headingFont: -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1
===Terminal colors===
 
Most terminals, including [[xterm]] and [[urxvt]], support at least 16 basic colors. The following is an example of a 16-color scheme. The colors 0-7 are the 'normal' colors, while colors 8-15 are their 'bright' counterparts, used for highlighting and such. A good place to start when making your Xresources, is to define the default terminal colors:
 
{{bc|
 
! terminal colors ------------------------------------------------------------
 
   
  +
クラスに関係なく、{{ic|headingFont}} リソースを含むすべてのプログラムに同じルールを適用したい場合は、次のように書くことができます:
! tangoesque scheme
 
*background: #111111
 
*foreground: #babdb6
 
! Black (not tango) + DarkGrey
 
*color0: #000000
 
*color8: #555753
 
! DarkRed + Red
 
*color1: #ff6565
 
*color9: #ff8d8d
 
! DarkGreen + Green
 
*color2: #93d44f
 
*color10: #c8e7a8
 
! DarkYellow + Yellow
 
*color3: #eab93d
 
*color11: #ffc123
 
! DarkBlue + Blue
 
*color4: #204a87
 
*color12: #3465a4
 
! DarkMagenta + Magenta
 
*color5: #ce5c00
 
*color13: #f57900
 
!DarkCyan + Cyan (both not tango)
 
*color6: #89b6e2
 
*color14: #46a4ff
 
! LightGrey + White
 
*color7: #cccccc
 
*color15: #ffffff
 
}}
 
   
  +
'''*'''headingFont: -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1
See [[man page#Colored man pages on xterm or rxvt-unicode]] for how to color bold and underlined text automatically xterm and rxvt.
 
   
  +
{{Note|
For more examples of color schemes, see the [[#Contributed examples]] section at the bottom of this article.
 
  +
* クエスチョンマーク({{ic|?}})はコンポーネント名のようなものであるため、その隣には ''バインディング文字''(ドット({{ic|.}})またはアスタリスク({{ic|*}}))が必要です。
 
  +
* アスタリスク({{ic|*}})は ''バインディング文字'' そのものであり、その隣にドットを置く必要はありません。また、ファイル処理中にドットとアスタリスクの連続が単一のアスタリスクに置き換えられます。
===Xcursor resources===
 
マウスカーソルのテーマとサイズを設定:
 
 
! Xcursor --------------------------------------------------------------------
 
 
Xcursor.theme: Vanilla-DMZ-AA
 
Xcursor.size: 22
 
 
Available themes reside in {{ic|/usr/share/icons}} and local themes can be installed to {{ic|~/.icons}}.
 
 
===Xft resources===
 
You can define basic font resources without the need of a {{ic|fonts.conf}} file or a desktop environment. Note however, the use of a desktop environment and/or {{ic|fonts.conf}} can override these settings. Your best option is to use one or the other, but not both.
 
 
! Xft settings ---------------------------------------------------------------
 
 
Xft.dpi: 96
 
Xft.antialias: true
 
Xft.rgba: rgb
 
Xft.hinting: true
 
Xft.hintstyle: hintslight
 
 
===Xterm resources===
 
The following resources will open [[xterm]] in an 80x25 character window with a scroll-bar and scroll capability for the last 512 lines. The specified [[Fonts#Bitmap|Terminus]] facename is a popular and clean terminal font.
 
 
! xterm ----------------------------------------------------------------------
 
 
xterm*VT100.geometry: 80x25
 
xterm*faceName: Terminus:style=Regular:size=10
 
!xterm*font: -*-dina-medium-r-*-*-16-*-*-*-*-*-*-*
 
xterm*dynamicColors: true
 
xterm*utf8: 2
 
xterm*eightBitInput: true
 
xterm*saveLines: 512
 
xterm*scrollKey: true
 
xterm*scrollTtyOutput: false
 
xterm*scrollBar: true
 
xterm*rightScrollBar: true
 
xterm*jumpScroll: true
 
xterm*multiScroll: true
 
xterm*toolBar: false
 
 
===rxvt-unicode (urxvt) resources===
 
{{Pkg|rxvt-unicode}} features an extensive list of options which can be configured via {{ic|~/.Xresources}}. Refer to the urxvt man page or [[Urxvt#Creating_.7E.2F.Xresources|this wiki article]] for details.
 
 
===Aterm の設定===
 
Sample settings for aterm (very similar to urxvt):
 
 
!aterm settings-------------------------------------------------------------
 
 
aterm*background: black
 
aterm*foreground: white
 
aterm*transparent: true
 
aterm*shading: 30
 
aterm*cursorColor: gray
 
aterm*saveLines: 2000
 
!aterm*tinting: gray
 
aterm*scrollBar: false
 
!aterm*scrollBar_right: true
 
aterm*transpscrollbar: true
 
aterm*borderwidth: 0
 
aterm*font: -*-terminus-*-*-*-*-*-*-*-*-*-*-*-*
 
aterm*geometry: 80x25
 
!aterm*fading: 70
 
 
===Xpdf resources===
 
Following are some basic resources for {{AUR|xpdf}}, a lightweight PDF viewer:
 
 
! xpdf -----------------------------------------------------------------------
 
 
xpdf*enableFreetype: yes
 
xpdf*antialias: yes
 
xpdf*foreground: black
 
xpdf*background: white
 
xpdf*urlCommand: /usr/bin/firefox %s
 
 
Anything more detailed than the above you should be putting in {{ic|~/.xpdfrc}} instead. See the xpdf man page for more information. Note that {{ic|viKeys}} is deprecated.
 
 
===Lal clock resources===
 
 
! lal clock ------------------------------------------------------------------
 
 
lal*font: Arial
 
lal*fontsize: 12
 
lal*bold: true
 
lal*color: #ffffff
 
lal*width: 150
 
lal*format: %a %b %d %l:%M%P
 
 
===Xclock の設定===
 
Some basic xclock settings. See the xclock man page for all X resources.
 
 
! xclock ---------------------------------------------------------------------
 
 
xclock*update: 1
 
xclock*analog: false
 
xclock*Foreground: white
 
xclock*background: black
 
 
===X11-ssh-askpass resources===
 
 
! x11-ssh-askpass ------------------------------------------------------------
 
 
x11-ssh-askpass*font: -*-dina-medium-r-*-*-12-*-*-*-*-*-*-*
 
x11-ssh-askpass*background: #000000
 
x11-ssh-askpass*foreground: #ffffff
 
x11-ssh-askpass.Button*background: #000000
 
x11-ssh-askpass.Indicator*foreground: #ff9900
 
x11-ssh-askpass.Indicator*background: #090909
 
x11-ssh-askpass*topShadowColor: #000000
 
x11-ssh-askpass*bottomShadowColor: #000000
 
x11-ssh-askpass.*borderWidth: 1
 
 
===XScreenSaver resources===
 
以下は [[XScreenSaver]] のテーマのサンプルです。詳しい情報は、XScreenSaver の man ページを参照してください。
 
 
{{Note|In older versions of XScreenSaver, if the {{ic|~/.xscreensaver}} file exists, it overrides any settings in the X resource database. However, in the latest versions, you can use both simultaneously.}}
 
 
! xscreensaver ---------------------------------------------------------------
 
 
!font settings
 
xscreensaver.Dialog.headingFont: -*-dina-bold-r-*-*-12-*-*-*-*-*-*-*
 
xscreensaver.Dialog.bodyFont: -*-dina-medium-r-*-*-12-*-*-*-*-*-*-*
 
xscreensaver.Dialog.labelFont: -*-dina-medium-r-*-*-12-*-*-*-*-*-*-*
 
xscreensaver.Dialog.unameFont: -*-dina-medium-r-*-*-12-*-*-*-*-*-*-*
 
xscreensaver.Dialog.buttonFont: -*-dina-bold-r-*-*-12-*-*-*-*-*-*-*
 
xscreensaver.Dialog.dateFont: -*-dina-medium-r-*-*-12-*-*-*-*-*-*-*
 
xscreensaver.passwd.passwdFont: -*-dina-bold-r-*-*-12-*-*-*-*-*-*-*
 
!general dialog box (affects main hostname, username, password text)
 
xscreensaver.Dialog.foreground: #ffffff
 
xscreensaver.Dialog.background: #111111
 
xscreensaver.Dialog.topShadowColor: #111111
 
xscreensaver.Dialog.bottomShadowColor: #111111
 
xscreensaver.Dialog.Button.foreground: #666666
 
xscreensaver.Dialog.Button.background: #ffffff
 
!username/password input box and date text colour
 
xscreensaver.Dialog.text.foreground: #666666
 
xscreensaver.Dialog.text.background: #ffffff
 
xscreensaver.Dialog.internalBorderWidth:24
 
xscreensaver.Dialog.borderWidth: 20
 
xscreensaver.Dialog.shadowThickness: 2
 
!timeout bar (background is actually determined by Dialog.text.background)
 
xscreensaver.passwd.thermometer.foreground: #ff0000
 
xscreensaver.passwd.thermometer.background: #000000
 
xscreensaver.passwd.thermometer.width: 8
 
!datestamp format--see the strftime(3) manual page for details
 
xscreensaver.dateFormat: %I:%M%P %a %b %d, %Y
 
 
===Xcalc resources===
 
Following are some xcalc resources to colorize and customize buttons.
 
 
!xcalc-----------------------------------------------------------------------
 
 
xcalc*geometry: 200x275
 
xcalc.ti.bevel.background: #111111
 
xcalc.ti.bevel.screen.background: #000000
 
xcalc.ti.bevel.screen.DEG.background: #000000
 
xcalc.ti.bevel.screen.DEG.foreground: LightSeaGreen
 
xcalc.ti.bevel.screen.GRAD.background: #000000
 
xcalc.ti.bevel.screen.GRAD.foreground: LightSeaGreen
 
xcalc.ti.bevel.screen.RAD.background: #000000
 
xcalc.ti.bevel.screen.RAD.foreground: LightSeaGreen
 
xcalc.ti.bevel.screen.INV.background: #000000
 
xcalc.ti.bevel.screen.INV.foreground: Red
 
xcalc.ti.bevel.screen.LCD.background: #000000
 
xcalc.ti.bevel.screen.LCD.foreground: LightSeaGreen
 
xcalc.ti.bevel.screen.LCD.shadowWidth: 0
 
xcalc.ti.bevel.screen.M.background: #000000
 
xcalc.ti.bevel.screen.M.foreground: LightSeaGreen
 
xcalc.ti.bevel.screen.P.background: #000000
 
xcalc.ti.bevel.screen.P.foreground: Yellow
 
xcalc.ti.Command.foreground: White
 
xcalc.ti.Command.background: #777777
 
xcalc.ti.button5.background: Orange3
 
xcalc.ti.button19.background: #611161
 
xcalc.ti.button18.background: #611161
 
xcalc.ti.button20.background: #611111
 
!uncomment to change label on division button
 
!xcalc.ti.button20.label: /
 
xcalc.ti.button25.background: #722222
 
xcalc.ti.button30.background: #833333
 
xcalc.ti.button35.background: #944444
 
xcalc.ti.button40.background: #a55555
 
xcalc.ti.button22.background: #222262
 
xcalc.ti.button23.background: #222262
 
xcalc.ti.button24.background: #222272
 
xcalc.ti.button27.background: #333373
 
xcalc.ti.button28.background: #333373
 
xcalc.ti.button29.background: #333373
 
xcalc.ti.button32.background: #444484
 
xcalc.ti.button33.background: #444484
 
xcalc.ti.button34.background: #444484
 
xcalc.ti.button37.background: #555595
 
xcalc.ti.button38.background: #555595
 
xcalc.ti.button39.background: #555595
 
XCalc*Cursor: hand2
 
XCalc*ShapeStyle: rectangle
 
 
==Color scheme commands==
 
Here are some fast bash commands you can run right in your shell.
 
 
===Display all 256 colors===
 
Prints all 256 colors across the screen, very quick.
 
<nowiki>(x=`tput op` y=`printf %76s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done)</nowiki>
 
 
===Display tput escape codes===
 
Replace {{ic|tput op}} with whatever tput you want to trace. {{ic|op}} is the default foreground and background color.
 
{{hc
 
|<nowiki>$ ( strace -s5000 -e write tput op 2>&2 2>&1 ) | tee -a /dev/stderr | grep -o '"[^"]*"'</nowiki>
 
|033[\033[1;34m"\33[39;49m"\033[00m
 
 
}}
 
}}
   
  +
詳細については {{man|3|XrmGetResource|MATCHING RULES}} を参照してください。
===Enumerating colors supported by terminals===
 
The following command will let you discover all the terminals you have terminfo support for, and the number of colors each terminal supports. The possible values are: 8, 15, 16, 52, 64, 88 and 256.
 
{{hc
 
|<nowiki>$ for T in `find /usr/share/terminfo -type f -printf '%f '`;do echo "$T `tput -T $T colors`";done|sort -nk2</nowiki>
 
|Eterm-88color 88
 
rxvt-88color 88
 
xterm+88color 88
 
xterm-88color 88
 
Eterm-256color 256
 
gnome-256color 256
 
konsole-256color 256
 
putty-256color 256
 
rxvt-256color 256
 
screen-256color 256
 
screen-256color-bce 256
 
screen-256color-bce-s 256
 
screen-256color-s 256
 
xterm+256color 256
 
xterm-256color 256
 
}}
 
   
  +
=== コメント ===
===Enumerating terminal capabilities===
 
This command is useful to see what features that are supported by your terminal.
 
{{hc
 
|<nowiki>$ infocmp -1 | sed -nu 's/^[ \000\t]*//;s/[ \000\t]*$//;/[^ \t\000]\{1,\}/!d;/acsc/d;s/=.*,//p'|column -c80</nowiki>
 
|bel cuu ich kb2 kf15 kf3 kf44 kf59 mc0 rmso smul
 
blink cuu1 il kbs kf16 kf30 kf45 kf6 mc4 rmul tbc
 
bold cvvis il1 kcbt kf17 kf31 kf46 kf60 mc5 rs1 u6
 
cbt dch ind kcub1 kf18 kf32 kf47 kf61 meml rs2 u7
 
civis dch1 indn kcud1 kf19 kf33 kf48 kf62 memu sc u8
 
clear dl initc kcuf1 kf2 kf34 kf49 kf63 op setab u9
 
cnorm dl1 invis kcuu1 kf20 kf35 kf5 kf7 rc setaf vpa
 
}}
 
   
  +
感嘆符({{ic|!}})で始まる行は無視されます。例えば:
==Color scheme scripts==
 
Any of the following scripts will display a chart of your current terminal color scheme. Handy for testing and whatnot.
 
   
  +
! 次のルールはコメントアウトされているため無視されます
===Script #1===
 
  +
!Xft.antialias: true
{{bc|1=
 
#!/usr/bin/bash
 
#
 
# This file echoes a bunch of color codes to the
 
# terminal to demonstrate what's available. Each
 
# line is the color code of one foreground color,
 
# out of 17 (default + 16 escapes), followed by a
 
# test use of that color on all nine background
 
# colors (default + 8 escapes).
 
#
 
   
  +
{{Note|
T='gYw' # The test text
 
  +
* 感嘆符は行の最初の文字でなければなりません。
 
  +
* [https://gcc.gnu.org/onlinedocs/cpp/ GNU CPP]({{pkg|gcc}})のような [[Wikipedia:C preprocessor|C プリプロセッサ]]がインストールされている場合、[[C]]-スタイル({{ic|//}} および {{ic|/* … */}})のコメントを使用できます([[#サンプル]] も参照)。
echo -e "\n 40m 41m 42m 43m\
 
44m 45m 46m 47m";
 
 
for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
 
'1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
 
' 36m' '1;36m' ' 37m' '1;37m';
 
do FG=${FGs// /}
 
echo -en " $FGs \033[$FG $T "
 
for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
 
do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
 
done
 
echo;
 
done
 
echo
 
 
}}
 
}}
   
  +
=== インクルードファイル ===
===Script #2===
 
{{bc|1=
 
#!/usr/bin/bash
 
# Original: http://frexx.de/xterm-256-notes/ {{Dead link|2013|11|21}}
 
# http://frexx.de/xterm-256-notes/data/colortable16.sh {{Dead link|2013|11|21}}
 
# Modified by Aaron Griffin
 
# and further by Kazuo Teramoto
 
FGNAMES=(' black ' ' red ' ' green ' ' yellow' ' blue ' 'magenta' ' cyan ' ' white ')
 
BGNAMES=('DFT' 'BLK' 'RED' 'GRN' 'YEL' 'BLU' 'MAG' 'CYN' 'WHT')
 
 
echo " ┌──────────────────────────────────────────────────────────────────────────┐"
 
for b in {0..8}; do
 
((b>0)) && bg=$((b+39))
 
 
echo -en "\033[0m ${BGNAMES[b]} │ "
 
 
for f in {0..7}; do
 
echo -en "\033[${bg}m\033[$((f+30))m ${FGNAMES[f]} "
 
done
 
 
echo -en "\033[0m │"
 
echo -en "\033[0m\n\033[0m │ "
 
 
for f in {0..7}; do
 
echo -en "\033[${bg}m\033[1;$((f+30))m ${FGNAMES[f]} "
 
done
 
   
  +
リソース設定を複数のファイルに分けるため(例:各アプリケーションに独自のファイルを使用するため)、''C preprocessor'' の {{ic|#include}} ''ディレクティブ'' を使用します:
echo -en "\033[0m │"
 
echo -e "\033[0m"
 
   
  +
{{hc|~/.config/X11/Xresources|
((b<8)) &&
 
  +
#include "Xresources.d/fonts"
echo " ├──────────────────────────────────────────────────────────────────────────┤"
 
  +
#include "Xresources.d/rxvt-unicode"
done
 
  +
#include "Xresources.d/xscreensaver"
echo " └──────────────────────────────────────────────────────────────────────────┘"
 
  +
#include "Xresources.d/xterm"
 
}}
 
}}
   
  +
''#include'' で参照されるファイルが適用される設定ファイルのディレクトリから到達できない場合は、検索するディレクトリを渡す必要があります:
===Script #3===
 
{{bc|1=
 
#!/usr/bin/bash
 
# Original: http://frexx.de/xterm-256-notes/ {{Dead link|2013|11|21}}
 
# http://frexx.de/xterm-256-notes/data/colortable16.sh {{Dead link|2013|11|21}}
 
# Modified by Aaron Griffin
 
# and further by Kazuo Teramoto
 
   
  +
$ xrdb -load -I''${HOME}/.config/X11 ~/.Xresources''
   
  +
=== デフォルト設定 ===
FGNAMES=(' black ' ' red ' ' green ' ' yellow' ' blue ' 'magenta' ' cyan ' ' white ')
 
BGNAMES=('DFT' 'BLK' 'RED' 'GRN' 'YEL' 'BLU' 'MAG' 'CYN' 'WHT')
 
echo " ----------------------------------------------------------------------------"
 
for b in $(seq 0 8); do
 
if [ "$b" -gt 0 ]; then
 
bg=$(($b+39))
 
fi
 
   
  +
インストールされている X11 アプリケーションのデフォルト設定を確認するには、{{ic|/usr/share/X11/app-defaults/}} を参照してください。
echo -en "\033[0m ${BGNAMES[$b]} : "
 
for f in $(seq 0 7); do
 
echo -en "\033[${bg}m\033[$(($f+30))m ${FGNAMES[$f]} "
 
done
 
echo -en "\033[0m :"
 
   
  +
プログラム固有のリソースに関する詳細情報は通常、プログラムの man ページに記載されています。{{man|1|xterm|RESOURCES}} はその良い例であり、X リソースとそのデフォルト値のリストが含まれています。
echo -en "\033[0m\n\033[0m : "
 
for f in $(seq 0 7); do
 
echo -en "\033[${bg}m\033[1;$(($f+30))m ${FGNAMES[$f]} "
 
done
 
echo -en "\033[0m :"
 
echo -e "\033[0m"
 
 
if [ "$b" -lt 8 ]; then
 
echo " ----------------------------------------------------------------------------"
 
fi
 
done
 
echo " ----------------------------------------------------------------------------"
 
}}
 
   
  +
現在ロードされているリソースを確認するには:
===Script #4===
 
{{bc|1=
 
#!/usr/bin/env lua
 
   
  +
$ xrdb -query -all
function cl(e)
 
return string.format('\27[%sm', e)
 
end
 
   
  +
=== サンプル ===
function print_fg(bg, pre)
 
for fg = 30,37 do
 
fg = pre..fg
 
io.write(cl(bg), cl(fg), string.format(' %6s ', fg), cl(0))
 
end
 
end
 
   
  +
* [[コンソールのカラー出力#ターミナルエミュレータ]]
for bg = 40,47 do
 
  +
* [[カーソルテーマ#X リソース]]
io.write(cl(0), ' ', bg, ' ')
 
  +
* [[フォント設定#fontconfig をサポートしていないアプリケーション]]
print_fg(bg, ' ')
 
  +
* [[rxvt-unicode#設定]]
io.write('\n ')
 
  +
* {{man|1|xpdf|OPTIONS}}
print_fg(bg, '1;')
 
  +
* [[Xterm#設定]]
io.write('\n\n')
 
  +
* [https://github.com/mrdotx/dotfiles/tree/master/.config/X11 klassiker (mrdotx)] — [[Rxvt-unicode]] パッチ開発者の[[ドットファイル]]
end
 
   
  +
== 使用法 ==
-- Andres P
 
}}
 
   
  +
=== リソースファイルの読み込み ===
===Script #5===
 
{{bc|1=
 
#!/usr/bin/bash
 
#
 
# ANSI color scheme script featuring Space Invaders
 
#
 
# Original: http://crunchbang.org/forums/viewtopic.php?pid=126921%23p126921#p126921
 
# Modified by lolilolicon
 
#
 
   
  +
リソースは X サーバーに保存されるため、一度だけ読み込めばよいです。また、''リモート'' の X11 クライアント(例えば [[OpenSSH#X11 フォワーディング|SSH 経由で転送]] されるもの)からもアクセスできます。
f=3 b=4
 
for j in f b; do
 
for i in {0..7}; do
 
printf -v $j$i %b "\e[${!j}${i}m"
 
done
 
done
 
bld=$'\e[1m'
 
rst=$'\e[0m'
 
   
  +
リソースファイル(一般的な {{ic|.Xresources}} など)を読み込み、現在の設定を置き換えます:
cat << EOF
 
   
  +
$ xrdb ''~/.Xresources''
$f1 ▀▄ ▄▀ $f2 ▄▄▄████▄▄▄ $f3 ▄██▄ $f4 ▀▄ ▄▀ $f5 ▄▄▄████▄▄▄ $f6 ▄██▄ $rst
 
$f1 ▄█▀███▀█▄ $f2███▀▀██▀▀███ $f3▄█▀██▀█▄ $f4 ▄█▀███▀█▄ $f5███▀▀██▀▀███ $f6▄█▀██▀█▄$rst
 
$f1█▀███████▀█ $f2▀▀███▀▀███▀▀ $f3▀█▀██▀█▀ $f4█▀███████▀█ $f5▀▀███▀▀███▀▀ $f6▀█▀██▀█▀$rst
 
$f1▀ ▀▄▄ ▄▄▀ ▀ $f2 ▀█▄ ▀▀ ▄█▀ $f3▀▄ ▄▀ $f4▀ ▀▄▄ ▄▄▀ ▀ $f5 ▀█▄ ▀▀ ▄█▀ $f6▀▄ ▄▀$rst
 
   
  +
リソースファイルを読み込み、現在の設定にマージします:
$bld$f1▄ ▀▄ ▄▀ ▄ $f2 ▄▄▄████▄▄▄ $f3 ▄██▄ $f4▄ ▀▄ ▄▀ ▄ $f5 ▄▄▄████▄▄▄ $f6 ▄██▄ $rst
 
$bld$f1█▄█▀███▀█▄█ $f2███▀▀██▀▀███ $f3▄█▀██▀█▄ $f4█▄█▀███▀█▄█ $f5███▀▀██▀▀███ $f6▄█▀██▀█▄$rst
 
$bld$f1▀█████████▀ $f2▀▀▀██▀▀██▀▀▀ $f3▀▀█▀▀█▀▀ $f4▀█████████▀ $f5▀▀▀██▀▀██▀▀▀ $f6▀▀█▀▀█▀▀$rst
 
$bld$f1 ▄▀ ▀▄ $f2▄▄▀▀ ▀▀ ▀▀▄▄ $f3▄▀▄▀▀▄▀▄ $f4 ▄▀ ▀▄ $f5▄▄▀▀ ▀▀ ▀▀▄▄ $f6▄▀▄▀▀▄▀▄$rst
 
   
  +
$ xrdb -merge ''~/.Xresources''
   
  +
{{Note|
$f7▌$rst
 
  +
* ほとんどの [[ディスプレイマネージャ]]はログイン時に {{ic|~/.Xresources}} ファイルを読み込みます。
 
  +
* 古い {{ic|~/.Xdefaults}} ファイルは X11 プログラムが開始されるときに読み込まれますが、現在のセッションで ''xrdb'' が使用されていない場合に限ります。 [https://groups.google.com/forum/#!msg/comp.windows.x/hQBEdql8l-Q/hF3DETcIHGwJ]
$f7▌$rst
 
 
$f7 ▄█▄ $rst
 
$f7▄█████████▄$rst
 
$f7▀▀▀▀▀▀▀▀▀▀▀$rst
 
 
EOF
 
 
}}
 
}}
 
===Script #6===
 
{{bc|1=
 
#!/usr/bin/env ruby
 
# coding: utf-8
 
 
# ANSI color scheme script
 
# Author: Ivaylo Kuzev < Ivo >
 
# Original: http://crunchbang.org/forums/viewtopic.php?pid=134749%23p134749#p134749
 
# Modified using Ruby.
 
 
CL = "\e[0m"
 
BO = "\e[1m"
 
   
  +
=== xinitrc ===
R = "\e[31m"
 
G = "\e[32m"
 
Y = "\e[33m"
 
B = "\e[34m"
 
P = "\e[35m"
 
C = "\e[36m"
 
 
print <<EOF
 
 
#{BO}#{R} ██████ #{CL} #{BO}#{G}██████ #{CL}#{BO}#{Y} ██████#{CL} #{BO}#{B}██████ #{CL} #{BO}#{P} ██████#{CL} #{BO}#{C} ███████#{CL}
 
#{BO}#{R} ████████#{CL} #{BO}#{G}██ ██ #{CL}#{BO}#{Y}██ #{CL} #{BO}#{B}██ ██#{CL} #{BO}#{P}██████ #{CL} #{BO}#{C} █████████#{CL}
 
#{R} ██ ████#{CL} #{G}██ ████#{CL}#{Y} ████ #{CL} #{B}████ ██#{CL} #{P}████ #{CL} #{C}█████ #{CL}
 
#{R} ██ ██#{CL} #{G}██████ #{CL}#{Y} ████████#{CL} #{B}██████ #{CL} #{P}████████#{CL} #{C}██ #{CL}
 
 
EOF
 
}}
 
   
  +
デフォルトの [[xinitrc]] のコピーを {{ic|.xinitrc}} として使用している場合、それはすでに {{ic|~/.Xresources}} をマージしています。
===Script #7===
 
{{bc|1=
 
#!/bin/sh
 
# Original Posted at http://crunchbang.org/forums/viewtopic.php?pid=126921%23p126921#p126921
 
# [ESC] character in original post removed here.
 
   
  +
カスタムのものを使用している場合は、次を追加します:
# ANSI Color -- use these variables to easily have different color
 
# and format output. Make sure to output the reset sequence after
 
# colors (f = foreground, b = background), and use the 'off'
 
# feature for anything you turn on.
 
   
  +
{{hc|.xinitrc|<nowiki>[[ -f ~/.Xresources ]] && xrdb -merge -I$HOME ~/.Xresources</nowiki>}}
initializeANSI()
 
{
 
esc="$(echo -en '\e')"
 
   
  +
{{Note|{{ic|~/.xinitrc}} 内で xrdb コマンドをバックグラウンドにしないでください。そうしないと、xrdb の後に起動したプログラムがリソースを読み込む前にリソースを探すことがあります。}}
blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m"
 
yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m"
 
cyanf="${esc}[36m"; whitef="${esc}[37m"
 
   
  +
=== リソース値の取得 ===
blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m"
 
yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m"
 
cyanb="${esc}[46m"; whiteb="${esc}[47m"
 
   
  +
リソースの値を取得したい場合(例えば、bash スクリプトで使用したい場合)、{{AUR|xgetres}} を使用できます:
boldon="${esc}[1m"; boldoff="${esc}[22m"
 
italicson="${esc}[3m"; italicsoff="${esc}[23m"
 
ulon="${esc}[4m"; uloff="${esc}[24m"
 
invon="${esc}[7m"; invoff="${esc}[27m"
 
   
  +
$ xgetres xscreensaver.Dialog.headingFont
reset="${esc}[0m"
 
  +
-*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1
}
 
   
  +
== トラブルシューティング ==
# note in this first use that switching colors doesn't require a reset
 
# first - the new color overrides the old one.
 
   
  +
=== 解析エラー ===
#clear
 
   
  +
[[GDM]] などの[[ディスプレイマネージャ]]は ''xrdb'' で {{ic|--nocpp}} 引数を使用することがあります。
initializeANSI
 
   
  +
=== xrdb -query からの出力が無い ===
cat << EOF
 
   
  +
{{ic|xrdb -query}} が何も出力しないことも珍しくありません。上記の [[X resources#リソースファイルのロード|リソースファイルのロード]] と [[X resources#xinitrc|xinitrc]] に従ってみてください。 また、そこに記載されているファイルの一部が空である可能性があることに注意してください。
${yellowf} ▄███████▄${reset} ${redf} ▄██████▄${reset} ${greenf} ▄██████▄${reset} ${bluef} ▄██████▄${reset} ${purplef} ▄██████▄${reset} ${cyanf} ▄██████▄${reset}
 
${yellowf}▄█████████▀▀${reset} ${redf}▄${whitef}█▀█${redf}██${whitef}█▀█${redf}██▄${reset} ${greenf}▄${whitef}█▀█${greenf}██${whitef}█▀█${greenf}██▄${reset} ${bluef}▄${whitef}█▀█${bluef}██${whitef}█▀█${bluef}██▄${reset} ${purplef}▄${whitef}█▀█${purplef}██${whitef}█▀█${purplef}██▄${reset} ${cyanf}▄${whitef}█▀█${cyanf}██${whitef}█▀█${cyanf}██▄${reset}
 
${yellowf}███████▀${reset} ${redf}█${whitef}▄▄█${redf}██${whitef}▄▄█${redf}███${reset} ${greenf}█${whitef}▄▄█${greenf}██${whitef}▄▄█${greenf}███${reset} ${bluef}█${whitef}▄▄█${bluef}██${whitef}▄▄█${bluef}███${reset} ${purplef}█${whitef}▄▄█${purplef}██${whitef}▄▄█${purplef}███${reset} ${cyanf}█${whitef}▄▄█${cyanf}██${whitef}▄▄█${cyanf}███${reset}
 
${yellowf}███████▄${reset} ${redf}████████████${reset} ${greenf}████████████${reset} ${bluef}████████████${reset} ${purplef}████████████${reset} ${cyanf}████████████${reset}
 
${yellowf}▀█████████▄▄${reset} ${redf}██▀██▀▀██▀██${reset} ${greenf}██▀██▀▀██▀██${reset} ${bluef}██▀██▀▀██▀██${reset} ${purplef}██▀██▀▀██▀██${reset} ${cyanf}██▀██▀▀██▀██${reset}
 
${yellowf} ▀███████▀${reset} ${redf}▀ ▀ ▀ ▀${reset} ${greenf}▀ ▀ ▀ ▀${reset} ${bluef}▀ ▀ ▀ ▀${reset} ${purplef}▀ ▀ ▀ ▀${reset} ${cyanf}▀ ▀ ▀ ▀${reset}
 
   
  +
==参照==
${boldon}${yellowf} ▄███████▄ ${redf} ▄██████▄ ${greenf} ▄██████▄ ${bluef} ▄██████▄ ${purplef} ▄██████▄ ${cyanf} ▄██████▄${reset}
 
${boldon}${yellowf}▄█████████▀▀ ${redf}▄${whitef}█▀█${redf}██${whitef}█▀█${redf}██▄ ${greenf}▄${whitef}█▀█${greenf}██${whitef}█▀█${greenf}██▄ ${bluef}▄${whitef}█▀█${bluef}██${whitef}█▀█${bluef}██▄ ${purplef}▄${whitef}█▀█${purplef}██${whitef}█▀█${purplef}██▄ ${cyanf}▄${whitef}█▀█${cyanf}██${whitef}█▀█${cyanf}██▄${reset}
 
${boldon}${yellowf}███████▀ ${redf}█${whitef}▄▄█${redf}██${whitef}▄▄█${redf}███ ${greenf}█${whitef}▄▄█${greenf}██${whitef}▄▄█${greenf}███ ${bluef}█${whitef}▄▄█${bluef}██${whitef}▄▄█${bluef}███ ${purplef}█${whitef}▄▄█${purplef}██${whitef}▄▄█${purplef}███ ${cyanf}█${whitef}▄▄█${cyanf}██${whitef}▄▄█${cyanf}███${reset}
 
${boldon}${yellowf}███████▄ ${redf}████████████ ${greenf}████████████ ${bluef}████████████ ${purplef}████████████ ${cyanf}████████████${reset}
 
${boldon}${yellowf}▀█████████▄▄ ${redf}██▀██▀▀██▀██ ${greenf}██▀██▀▀██▀██ ${bluef}██▀██▀▀██▀██ ${purplef}██▀██▀▀██▀██ ${cyanf}██▀██▀▀██▀██${reset}
 
${boldon}${yellowf} ▀███████▀ ${redf}▀ ▀ ▀ ▀ ${greenf}▀ ▀ ▀ ▀ ${bluef}▀ ▀ ▀ ▀ ${purplef}▀ ▀ ▀ ▀ ${cyanf}▀ ▀ ▀ ▀${reset}
 
   
  +
* [https://engineering.purdue.edu/ECN/Support/KB/Docs/UsingTheXdefaultsFil Using the Xdefaults File] - X が Xdefaults ファイルをどのように解釈するのか説明した記事
EOF}}
 
  +
* [https://unix.stackexchange.com/questions/216723/xterm-or-xterm-in-configuration-file/292992#292992 Overlooked Points of X Resources] by Thomas Dickey
 
==他のサンプル==
 
 
Check out these links for some real world examples of X resource files, contributed by fellow community members.
 
 
{{Note|{{ic|~/.Xdefaults}} has the same syntax as {{ic|~/.Xresources}}, and it is recommended that you use {{ic|~/.Xresources}} because {{ic|~/.Xdefaults}} is deprecated upstream.}}
 
 
* http://dotfiles.org/~buttons/.Xdefaults
 
* https://github.com/jelly/Dotfiles/blob/master/.Xdefaults
 
* https://paste.debian.net/14515/ .Xresources
 
 
==参照==
 
   
  +
{{TranslationStatus|X resources|2024-07-02|807397}}
* [https://engineering.purdue.edu/ECN/Support/KB/Docs/UsingTheXdefaultsFil Using the Xdefaults File] - An in-depth article on how X interprets the Xdefaults file
 
* [http://wiki.afterstep.org/index.php?title=Rxvt-Unicode_Configuration_Tutorial Rxvt-unicode Configuration Tutorial] - lots of information for urxvt users
 
* [http://mkaz.com/solog/system/xterm-colors.html Example Colors and their names] - listing of example colors and their color names for xterm and other X-applications.
 
* [https://web.archive.org/web/20090130061234/http://phraktured.net/terminal-colors/ Color Themes] - Extensive list of terminal color themes by Phraktured.
 
* [http://xcolors.net/ Xcolors.net] List of user-contributed terminal color themes.
 
* [http://beta.andrewrcraig.us/index.php?page=xcolors Xcolors by dkeg]
 

2024年7月2日 (火) 19:19時点における最新版

関連記事

X リソースファイル はユーザーレベルの設定ドットファイルで、通常は ~/.Xresources に存在します。X クライアントアプリケーションの設定パラメータである X resources を設定するのに使われます。

特に次の目的で使用できます:

インストール

xorg-xrdb パッケージをインストールしてください。

設定

X(7) § RESOURCES および XrmGetDatabase(3) § FILE SYNTAX には、X リソースのメカニズムとファイル構文に関する詳細情報が記載されています。

~/.Xresources は一般的なファイル名であり、xrdb はこれを独自に扱っているわけではありません。他のファイル名(例えば ~/.config/X11/Xresources~/.config/X11/Xresources.d/application-name)を使用することもできます(#サンプルおよび#インクルードファイルも参照)。

基本構文

X リソースファイルの構文は以下のような リソース行 のシーケンスです:

application_name.Class.resourceName: value
      application_name.resourceName: value
                 Class.resourceName: value
      application_name*resourceName: value
                      *resourceName: value

application_nameClass のサブストリングにはドット(.)は含まれませんが、resourceName のサブストリングにはドットが含まれる場合があります。例えば、Dialog.bodyFontXScreenSaver の内部リソースであり、本文フォントおよびフォールバックフォントを設定するために指定されます:

xscreensaver-auth.default.Dialog.bodyFont: times new roman 12, dejavu serif 12
application_name
アプリケーションの名前、例えば urxvt, xpdf, xterm など。 インスタンス名 とも呼ばれます。
Class
リソースをまとめるために使用される分類。クラス名は通常大文字です。
resourceName
値を設定するリソースの名前。リソースは通常、連結された大文字と小文字で表されます。
value
リソースの実際の値。これには次の3種類があります:
  • 整数(整数値)
  • ブール値(true/false、yes/no、on/off)
  • 文字列(文字の列)— 例えば単語(white)、色(#ffffff)、またはパス(/usr/bin/firefox
区切り文字
  • ドット(.)は tight binding であり、直近のコンポーネントを分離するために使用されます(つまり、階層の各ステップを示す)。上記の例では、アプリケーション名から始まり、クラスに降り、最後にリソース自体に降ります。
  • アスタリスク(*)は loose binding であり、何らかのコンポーネントを表すために使用されます(含まれない場合もあります)。
  • コロン(:)はリソース名と値を分離するために使用されます。
ノート:
  • リソースファイル構文の観点から見ると、コロン(:)の前にあるものはすべてリソース名です。ユーザーの視点からは、リソース は最も右側のコンポーネントのみを指すことがよくあります。言い換えると、リソース名アプリケーション名Class、および リソース名 のサブストリングから成る文字列です。これが混乱の原因になるかもしれません。
  • リソースの命名スキーマは完全にアプリケーションに依存します。あるアプリケーションが application_name.Class.resourceName を使用する場合、別のアプリケーションは application_name.resourceName および Class.resourceName のみを理解するかもしれません。

ワイルドカードマッチング

クエスチョンマーク(?)とアスタリスク(*)はワイルドカードとして使用でき、多くの異なるアプリケーションや要素に適用できる単一のルールを書くのが簡単になります。? は任意の単一のコンポーネント名に一致し、* は任意の数の中間コンポーネントを含むものに一致します。

前述の例を使用して、クラス名に Dialog を含むすべてのプログラムに同じフォントを適用したい場合(XScreenSaver に限らず)、次のように書くことができます:

?.Dialog.headingFont:     -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1

クラスに関係なく、headingFont リソースを含むすべてのプログラムに同じルールを適用したい場合は、次のように書くことができます:

*headingFont:    -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1
ノート:
  • クエスチョンマーク(?)はコンポーネント名のようなものであるため、その隣には バインディング文字(ドット(.)またはアスタリスク(*))が必要です。
  • アスタリスク(*)は バインディング文字 そのものであり、その隣にドットを置く必要はありません。また、ファイル処理中にドットとアスタリスクの連続が単一のアスタリスクに置き換えられます。

詳細については XrmGetResource(3) § MATCHING RULES を参照してください。

コメント

感嘆符(!)で始まる行は無視されます。例えば:

! 次のルールはコメントアウトされているため無視されます
!Xft.antialias: true
ノート:
  • 感嘆符は行の最初の文字でなければなりません。
  • GNU CPPgcc)のような C プリプロセッサがインストールされている場合、C-スタイル(// および /* … */)のコメントを使用できます(#サンプル も参照)。

インクルードファイル

リソース設定を複数のファイルに分けるため(例:各アプリケーションに独自のファイルを使用するため)、C preprocessor#include ディレクティブ を使用します:

~/.config/X11/Xresources
#include "Xresources.d/fonts"
#include "Xresources.d/rxvt-unicode"
#include "Xresources.d/xscreensaver"
#include "Xresources.d/xterm"

#include で参照されるファイルが適用される設定ファイルのディレクトリから到達できない場合は、検索するディレクトリを渡す必要があります:

$ xrdb -load -I${HOME}/.config/X11 ~/.Xresources

デフォルト設定

インストールされている X11 アプリケーションのデフォルト設定を確認するには、/usr/share/X11/app-defaults/ を参照してください。

プログラム固有のリソースに関する詳細情報は通常、プログラムの man ページに記載されています。xterm(1) § RESOURCES はその良い例であり、X リソースとそのデフォルト値のリストが含まれています。

現在ロードされているリソースを確認するには:

$ xrdb -query -all

サンプル

使用法

リソースファイルの読み込み

リソースは X サーバーに保存されるため、一度だけ読み込めばよいです。また、リモート の X11 クライアント(例えば SSH 経由で転送 されるもの)からもアクセスできます。

リソースファイル(一般的な .Xresources など)を読み込み、現在の設定を置き換えます:

$ xrdb ~/.Xresources

リソースファイルを読み込み、現在の設定にマージします:

$ xrdb -merge ~/.Xresources
ノート:
  • ほとんどの ディスプレイマネージャはログイン時に ~/.Xresources ファイルを読み込みます。
  • 古い ~/.Xdefaults ファイルは X11 プログラムが開始されるときに読み込まれますが、現在のセッションで xrdb が使用されていない場合に限ります。 [1]

xinitrc

デフォルトの xinitrc のコピーを .xinitrc として使用している場合、それはすでに ~/.Xresources をマージしています。

カスタムのものを使用している場合は、次を追加します:

.xinitrc
[[ -f ~/.Xresources ]] && xrdb -merge -I$HOME ~/.Xresources
ノート: ~/.xinitrc 内で xrdb コマンドをバックグラウンドにしないでください。そうしないと、xrdb の後に起動したプログラムがリソースを読み込む前にリソースを探すことがあります。

リソース値の取得

リソースの値を取得したい場合(例えば、bash スクリプトで使用したい場合)、xgetresAUR を使用できます:

$ xgetres xscreensaver.Dialog.headingFont
-*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1

トラブルシューティング

解析エラー

GDM などのディスプレイマネージャxrdb--nocpp 引数を使用することがあります。

xrdb -query からの出力が無い

xrdb -query が何も出力しないことも珍しくありません。上記の リソースファイルのロードxinitrc に従ってみてください。 また、そこに記載されているファイルの一部が空である可能性があることに注意してください。

参照

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