命令行大全

xrdb

瑞兹 发表于 2020-12-28 09:06浏览次数:

在类似 Unix 一样的操作系统上,xrdb命令是X 窗口服务器资源数据库实用程序。

查看英文版

目录:

1 xrdb 运行系统环境

2 xrdb 描述

3 xrdb 语法

4 xrdb 例子

xrdb 运行系统环境

Unix&Linux

xrdb 描述

如果要将 X 窗口系统配置为在多个客户端上使用,xrdb程序可以通过帮助您在一个统一的资源数据库中维护多个资源文件而非常有用。资源存储在 X 服务器上,连接到该服务器的任何客户端都可以访问这些资源。

xrdb命令可以从命令行以交互方式运行,也可以包含在.xinitrc.xsession 文件中,以便它在登录时初始化资源。

If you are configuring the X windowing system for use on multiple clients, the xrdb program can be useful by helping you maintain multiple resource files in one unified resource database. The resources are stored on the X server, where they are accessible to any clients that connect to that server.

The xrdb command can be run interactively from the command line, or it can be included in your .xinitrc or .xsession file so that it initializes resources at login.

查看英文版

查看中文版

xrdb 语法

xrdb [-option ...] [file name]

文件名是可选的,并指定一个包含要读取的客户端变量("资源")的值的文件。如果未指定文件,xrdb将期望通过标准输入提供这些值xrdb将用您提供的任何值覆盖其值;因此,如果运行xrdb时没有文件名(在交互模式下启动),然后不输入任何值,则 init 脚本已加载的任何值都将覆盖为无值。

这些值可以存储在名为"任何内容"的文件中,但该文件通常名为。X 资源或 。Xdefaults..在现代实现中,Xdefault是一个弃用的名称;.X 资源是首选文件名。

.Xresources调用xinit ,X资源通常自动加载xrdb。但是,如果您要手动更改资源数据库,或更改脚本中调用 xrdb的方法,可以使用这些选项调用 xrdb。

选项

- help 显示简短的帮助消息。
-dispaldisplay 指定要使用的 X 服务器(有关多个X显示器的信息,请参阅 X)。此选项还指定要用于-屏幕选项的屏幕
- all 此选项指示指定的任何其他操作应在与屏幕无关的资源属性(RESOURCE_MANAGER)以及显示器的每个屏幕上的特定于屏幕的属性 (SCREEN_RESOURCES)上执行。例如,当与-query 结合使用时,所有属性的内容都是输出的。对于加载,-覆盖和-合并,输入文件处理一次每个屏幕。收集每个屏幕输出中常见的资源,这些资源将作为独立于屏幕的资源应用。剩余的资源应用于每个屏幕属性。这是默认的操作模式。
-global 指示操作应仅在屏幕无关的RESOURCE_MANAGER上。
- screen 此选项指示操作应仅在显示的默认SCREEN_RESOURCES的默认属性上执行。
- screens 此选项指示应在显示器的每个屏幕的SCREEN_RESOURCES上执行该操作。对于-load 、-override和 -merge,将处理每个屏幕的输入文件。
- n 显示更改,但不要将它们写入数据库。指定时,-n指示对指定属性的更改(与 -load 、-override 或 -merge 一起使用时),或资源文件(与-edit 一起使用时)应在标准输出上显示,但不应执行。
- quiet 安静模式;具体来说,不会显示有关重复条目的任何警告。
-cpp file name xrdb使用 C 预处理器来解释输入;此选项指定应使用 C 预处理器程序的路径名。尽管xrdb设计为使用标准 CPP,但可以使用任何用作筛选器并接受-D 、-I-U选项的程序。
对于典型用户,不应需要
此选项。
-nocpp 此选项指示xrdb 在将输入文件加载到属性之前不应通过预处理器运行输入文件。
-symbols 预处理器特定的符号将打印到标准输出上。此选项可用于调试目的,不应对典型用户需要此选项。
- query 查询数据库的指定属性的当前内容,并打印到标准输出。此选项允许您查看当前设置的值。
-load 此选项指示输入应加载为指定属性的新值,替换存在的任何值(即删除旧内容)。此选项是默认操作。
- override 此选项指示应将输入添加到指定属性的当前内容,而不是替换。如果新条目与以前的条目重叠,则新条目将覆盖以前的值。
-merge 此选项指示应合并输入并用指定属性的当前内容而不是替换字典排序。
-remove 指示应从数据库中删除指定的属性。
-retain 此选项指示如果xrdb是第一个客户端,应指示服务器不要重置。在正常情况下,此选项永远不需要,因为xdmxinit始终充当第一个客户端。
-editfile name 此选项指示应将指定属性的内容编辑到给定文件中,从而替换已列在其中的任何值。此选项允许您将对默认值所做的更改放回资源文件中,保留任何注释或预处理器行。
- backup string 此选项指定要追加到用于生成备份文件的文件名的后缀。
- Dname[=value] 此选项通过预处理器传递,用于定义用于条件使用的符号。
-Uname 此选项通过预处理器传递,用于删除此符号的任何定义。
-Idirectory 此选项将传递到预处理器,并指定一个目录来搜索与 #include 引用的文件。

x 资源的语法

X 资源条目的一般形式是:

name.Class.resource: value
\ 名称应用程序的名称,例如"xterm""xscreensaver"。 \ 类资源类,如"对话框"或"滚动条"。类的名称通常以大写字母开头。 \ 资源是指定资源类中要更改的命名应用程序的资源的名称。资源名称通常以"camel 大小写"开头,以小写字母开头,并在有新单词时在名称中使用大写字母。例如,"按钮Font"。 \ 值是资源的值。 \

因此,以下资源条目将设置"前景",资源类的"对话框"资源类,应用程序"xscreensaver":

xscreensaver.Dialog.foreground: #101010

使用此资源值集,xscreensaver 应用程序的对话框具有十六进制颜色值#101010 
类也可以具有子
类。例如,屏幕保护程序[对话框]类有一个子类[按钮],这也采取颜色值。若要将前景资源设置为相同的灰色,可以使用以下行:

xscreensaver.Dialog.Button.foreground: #101010

在资源文件中使用注释

如果资源文件中的一行以感叹号"!" 开头,它将考虑注释,由xrdb 忽略。因此,您可以在资源文件中包括这些行,例如:

! My favorite xscreensaver dialog and button foreground colors: light gray
xscreensaver.Dialog.Button.foreground: #101010
screensaver.Dialog.foreground: #101010

Using wildcards

xrdb will interpret an asterisk ("*") as a wildcard, similar to using the asterisk when specifying file names in a shell. For instance, to set all xscreensaver "Dialog" resources to the same value, you could use the line:

xscreenaver*Dialog*: #101010

...or, to set the "Dialog" resources for every application:

*Dialog*: #101010

Examples of typical resources

Xft, the application which controls the rendering of fonts in X, can be configured with the following standard resources values:

Xft.dpi:        96
Xft.antialias:  true
Xft.rgba:       rgb
Xft.hinting:    true
Xft.hintstyle:  hintslight

xterm是默认的 X 终端仿真器。xterm 的典型资源值包括:

xterm*VT100.geometry:     80x25
xterm*faceName:           Courier:style=Regular:size=10
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

您可以在我们的 xterm 文档中找到其他 xterm 资源的名称及其值。通常,在配置 X 应用程序的资源时,请咨询应用程序的网页了解详细信息。

xrdb [-option ...] [file name]

The file name is optional, and specifies a file which contains the values of client variables ("resources") to be read. If no file name is specified, xrdb will expect these values to be provided via standard inputxrdb will overwrite its values with whatever you provide; so, if you run xrdb with no file name (starting it in interactive mode), and then enter no values, any values already loaded by your init scripts will be overwritten as valueless.

The values can be stored in a file named anything at all, but the file is commonly named .Xresources or .Xdefaults.Xdefaults is a deprecated name in modern implementations; .Xresources is the preferred file name.

.Xresources is often loaded with xrdb automatically when xinit is called by your startup script. But if you'd like to make changes to the resource database manually, or change how xrdb is invoked in your scripts, you can invoke xrdb with these options.

Options

-help Display a brief help message.
-display display Specifies the X server to be used (see X for more information about multiple X displays). This option also specifies the screen to use for the -screen option.
-all This option indicates that any other operation specified should be performed on the screen-independent resource property (RESOURCE_MANAGER), as well as the screen-specific property (SCREEN_RESOURCES) on every screen of the display. For example, when used in conjunction with -query, the contents of all properties are output. For -load-override and -merge, the input file is processed once for each screen. The resources which occur in common in the output for every screen are collected, and these are applied as the screen-independent resources. The remaining resources are applied for each per-screen property. This the default mode of operation.
-global Indicates that the operation should only be performed on the screen-independent RESOURCE_MANAGER property.
-screen This option indicates that the operation should only be performed on the SCREEN_RESOURCES property of the default screen of the display.
-screens This option indicates that the operation should be performed on the SCREEN_RESOURCES property of each screen of the display. For -load-override and -merge, the input file is processed for each screen.
-n Show changes, but do not write them to the database. When specified, -n indicates changes to the specified properties (when used with -load-override or -merge) or the resource file (when used with -edit) should be shown on the standard output, but not performed.
-quiet Quiet mode; specifically, any warnings about duplicate entries will not be displayed.
-cpp file name xrdb uses a C preprocessor to interpret input; this option specifies the pathname of which C preprocessor program should be used. Although xrdb was designed to use the standard CPP, any program that acts as a filter and accepts the -D-I, and -U options may be used.

This option should not be needed for typical users.
-nocpp This option indicates that xrdb should not run the input file through a preprocessor before loading it into properties.
-symbols Preprocessor-specific symbols will be printed onto the standard output. This option is useful for debugging purposes, and should not be needed for typical users.
-query Query the database for the current contents of the specified properties, and print them to standard output. This option allows you to see what values are currently set.
-load This option indicates that the input should be loaded as the new value of the specified properties, replacing whatever was there (i.e. the old contents are removed). This option is the default action.
-override This option indicates that the input should be added to, instead of replacing, the current contents of the specified properties. If new entries overlap previous entries, the new ones will override the previous values.
-merge This option indicates that the input should be merged and lexicographically sorted with, instead of replacing, the current contents of the specified properties.
-remove Indicates that the specified properties should be removed from the database.
-retain This option indicates that the server should be instructed not to reset if xrdb is the first client. This option should never be necessary under normal conditions since xdm and xinit always act as the first client.
-edit file name This option indicates that the contents of the specified properties should be edited into the given file, replacing any values already listed there. This option allows you to put changes that you have made to your defaults back into your resource file, preserving any comments or preprocessor lines.
-backup string This option specifies a suffix to be appended to the file name used with -edit to generate a backup file.
-Dname[=value] This option is passed through to the preprocessor and is used to define symbols for use with conditionals.
-Uname This option is passed through to the preprocessor and is used to remove any definitions of this symbol.
-Idirectory This option is passed through to the preprocessor and specifies a directory to search for files that are referenced with #include.

Syntax of an x resource

The general form of an X resource entry is:

name.Class.resource: value
  • The name is the name of the application, for instance "xterm" or "xscreensaver". 
  •  The class is the class of resources, such as "Dialog" or "Scrollbar". The name of a class often starts with an uppercase letter. 
  • The resource is the name of the resource of the named application, in the resource class specified, to be changed. Resource names are often in "camel case", they start with a lowercase letter, and use uppercase letters in the name when there is a new word. For instance, "buttonFont". 
  •  The value is the value of the resource. 

So, the following resource entry would set the resource "foreground", of the "Dialog" class of resources, of the application "xscreensaver":

xscreensaver.Dialog.foreground: #101010

With this resource value set, the dialog boxes of the xscreensaver application has the hexadecimal color value #101010.

Classes can also have sub-classes. For instance, the screensaver "Dialog" class has a sub-class "Button", which also takes a color value. To set the foreground resource to the same gray color, you could use the line:

xscreensaver.Dialog.Button.foreground: #101010

Using comments in your resource file

If a line in your resource file starts with an exclamation point "!", it will considered a comment and ignored by xrdb. So, you could include these lines in your resource file, for instance:

! My favorite xscreensaver dialog and button foreground colors: light gray
xscreensaver.Dialog.Button.foreground: #101010
screensaver.Dialog.foreground: #101010

Using wildcards

xrdb will interpret an asterisk ("*") as a wildcard, similar to using the asterisk when specifying file names in a shell. For instance, to set all xscreensaver "Dialog" resources to the same value, you could use the line:

xscreenaver*Dialog*: #101010

...or, to set the "Dialog" resources for every application:

*Dialog*: #101010

Examples of typical resources

Xft, the application which controls the rendering of fonts in X, can be configured with the following standard resources values:

Xft.dpi:        96
Xft.antialias:  true
Xft.rgba:       rgb
Xft.hinting:    true
Xft.hintstyle:  hintslight

xterm is the default X terminal emulator. Typical resource values for xterm include:

xterm*VT100.geometry:     80x25
xterm*faceName:           Courier:style=Regular:size=10
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

You can find the names of additional xterm resources and their values in our xterm documentation. In general, when configuring an X application's resources, it's a good idea to consult the application's man page for details.


查看英文版

查看中文版

xrdb 例子

xrdb

在交互模式下打开服务器资源数据库实用程序。可以手动输入值,并在完成返回命令行后输入Ctrl-D。如果未输入任何内容,则数据库中已存储的任何值都将被删除。

手动输入值是访问资源数据库最不方便的方法,而且很容易出现拼写错误。更常见的是从资源文件加载值,如下一个示例所示。

xrdb -load ~/.Xresources

加载文件。X 资源在主目录中,然后将其中包含的值写入数据库。启动 X 会话时通常会自动执行此命令,但此命令将强制重新加载文件中包含的资源值,覆盖数据库中存储的其他值。

xrdb -query

查询资源数据库以查看当前设置的变量和值。输出将类似于 X 资源文件的以下示例内容:

 *dialog*value*background: white
 *Dialog*Label*font:    -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*
 *MenuButton*font:      -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*
 *MenuButton*background:        grey80
 *MenuButton*foreground:        black
 *Label.font:           -adobe-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*
 *Label*shadowWidth:    1
 *SmeBSB.font:          -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*
 *SimpleMenu*font:      -adobe-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*
 *OptionMenu*font:      -adobe-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*
 *Command.font:         -linotype-helvetica-bold-r-narrow-*-12-*-*-*-*-*-*-*
 *Toggle.font:          -adobe-helvetica-bold-o-*-*-12-*-*-*-*-*-*-*
 *Form.background:      grey70
 *TransientShell*Dialog.background: grey70
 *Scrollbar.Foreground: grey80
 *Scrollbar.Background: grey50
 *Scrollbar*cursorName: top_left_arrow
 *Scrollbar*width:      16
 *shapeStyle:           Rectangle
 *XlwMenu.shadowThickness: 1
 *shadowWidth:          1
 xterm*scrollbar.background: grey40
 xterm*foreground: grey90
 xterm*background: grey25
 xterm*cursorColor: white
 xterm*visualbell: on
 rxvt*color12: steelblue
 rxvt*color15: white
 rxvt*color9: rgb:ff/7f/5f
 rxvt*foreground: grey90
 rxvt*background: grey10
 rxvt*cursorColor: white
 rxvt*font: lucidasanstypewriter-12
 rxvt*loginShell: false
 rxvt*saveLines: 1024
 rxvt*title: shell
 rxvt*geometry: 80x2
 xman*topBox: false
 xman*background: lightsteelblue
 xman*foreground: black
 xcalc*Command.font: -adobe-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*
 xcalc*customization: -color
xrdb -merge my-xr-values

将文件中列出的值my-xr 值与数据库中当前存储的任何资源值合并。例如,此命令是用 -load 覆盖所有值的替代方法。

您还可以使用不带文件名的-merge选项,在这种情况下,您可以手动输入值(或值),并且您的条目将与数据库中已有的值合并。例如,如果您运行

xrdb -merge

...然后键入:

xterm.AllowBoldFonts.allowBoldFonts: true

...然后按Ctrl-D终止条目,资源数据库会将该值存储到数据库中,而不删除以前存储的任何值。任何后续xterm会话将使用此值,并且在调用时显示粗体字体。

xrdb

Open the server resource database utility in interactive mode. Values can be entered manually, and you can enter Ctrl-D when you are finished to be returned to the command line. If you enter nothing, any values already stored in the database will be removed.

Entering the values manually is the least-convenient way to access the resource database, and it's easy to make a typo. It's much more common is to load values from a resource file, as in the next example.

xrdb -load ~/.Xresources

Load the file .Xresources in your home directory and write the values contained in it to the database. This command is often performed automatically when you start an X session, but this command will force a re-load of the resource values contained in the file, overwriting any other values stored in the database.

xrdb -query

Query the resource database to see what variables and values are currently set. Output will resemble the following sample contents of an X resources file:

 *dialog*value*background: white
 *Dialog*Label*font:    -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*
 *MenuButton*font:      -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*
 *MenuButton*background:        grey80
 *MenuButton*foreground:        black
 *Label.font:           -adobe-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*
 *Label*shadowWidth:    1
 *SmeBSB.font:          -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*
 *SimpleMenu*font:      -adobe-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*
 *OptionMenu*font:      -adobe-helvetica-medium-r-*-*-10-*-*-*-*-*-*-*
 *Command.font:         -linotype-helvetica-bold-r-narrow-*-12-*-*-*-*-*-*-*
 *Toggle.font:          -adobe-helvetica-bold-o-*-*-12-*-*-*-*-*-*-*
 *Form.background:      grey70
 *TransientShell*Dialog.background: grey70
 *Scrollbar.Foreground: grey80
 *Scrollbar.Background: grey50
 *Scrollbar*cursorName: top_left_arrow
 *Scrollbar*width:      16
 *shapeStyle:           Rectangle
 *XlwMenu.shadowThickness: 1
 *shadowWidth:          1
 xterm*scrollbar.background: grey40
 xterm*foreground: grey90
 xterm*background: grey25
 xterm*cursorColor: white
 xterm*visualbell: on
 rxvt*color12: steelblue
 rxvt*color15: white
 rxvt*color9: rgb:ff/7f/5f
 rxvt*foreground: grey90
 rxvt*background: grey10
 rxvt*cursorColor: white
 rxvt*font: lucidasanstypewriter-12
 rxvt*loginShell: false
 rxvt*saveLines: 1024
 rxvt*title: shell
 rxvt*geometry: 80x2
 xman*topBox: false
 xman*background: lightsteelblue
 xman*foreground: black
 xcalc*Command.font: -adobe-helvetica-bold-r-*-*-10-*-*-*-*-*-*-*
 xcalc*customization: -color
xrdb -merge my-xr-values

Merge the values listed in the file my-xr-values with any resource values currently stored in the database. This command is an alternative to overwriting all values with -load, for instance.

You could also use the -merge option without a file name, in which case you could manually enter a value (or values) and your entry would be merged with values already in the database. For instance, if you run

xrdb -merge

...and then type:

xterm.AllowBoldFonts.allowBoldFonts: true

...and then press Ctrl-D to terminate the entry, your resource database would store that value to the database, without removing any previous values stored. Any subsequent xterm sessions would use this value, and display bold font faces if called for.

查看英文版

查看中文版

发表评论
评论列表
共0条
点击加载更多