Difference between revisions of "X resources"

From ArchWiki
Jump to: navigation, search
m (urxvt preferences)
(Added color scheme script)
Line 238: Line 238:
 
!datestamp format--see the strftime(3) manual page for details
 
!datestamp format--see the strftime(3) manual page for details
 
xscreensaver.dateFormat:                    %I:%M%P %a %b %d, %Y
 
xscreensaver.dateFormat:                    %I:%M%P %a %b %d, %Y
 +
</pre>
 +
 +
= Color Scheme Script =
 +
Contributed by [http://bbs.archlinux.org/viewtopic.php?id=51818 smurnjiff]
 +
 +
<pre>
 +
#!/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 forground color,
 +
#  out of 17 (default + 16 escapes), followed by a
 +
#  test use of that color on all nine background
 +
#  colors (default + 8 escapes).
 +
#
 +
 +
T='gYw'  # The test text
 +
 +
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
 
</pre>
 
</pre>
  

Revision as of 16:43, 5 August 2008

Template:I18n links start Template:I18n entry Template:I18n links end

Tango-document-new.pngThis article is a stub.Tango-document-new.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:X resources#)

Introduction

Xdefaults is a user-level configuration dotfile, typically located at ~/.Xdefaults. When present, it is parsed by the xrdb (X Resource Database) program automatically when Xorg is started, and can be used to set or override preferences for X and X applications. It can do many things, including:

  • define terminal colours
  • configure terminal preferences
  • define DPI, antialiasing, hinting and other X font settings
  • set the Xcursor theme
  • theme xscreensaver

Getting started

Creating .Xdefaults

The file ~/.Xdefaults does not exist by default. To create it, open a terminal and type the following as a normal user:

$ touch ~/.Xdefaults

Being a plain-text file, you can edit your ~/.Xdefaults file with the text editor of your choice.

Xdefaults syntax

The basic syntax

The syntax of an Xdefaults file is as follows:

name.Class.resource: value

...and here's a real world example:

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

name: The name of the application, such xterm, xpdf, etc.

class: The classification used to group resources together. Class names is typically uppercase.

resource: The name of the resource whose value is to be changed. Resources are typically lowercase with uppercase concatenation.

value: The actual value of the resource. This can be 1 of 3 types:

  • Integer (whole numbers)
  • Boolean (true/false, yes/no, on/off)
  • String (a string of characters) (for example a word (white), a color (#ffffff), or a path (/usr/bin/firefox))

delimiters: A period (.) 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 (:) is used to separate the resource declaration from the actual value.

Wildcard matching

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 Dialog which contains the resource name 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 headingFont regardless of its class, you would write:

*headingFont:	-*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1

Commenting

To add a comment to your Xdefaults file, simply prefix it with an exclamation point (!), 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

Sample usage

The following samples should provide a good understanding of how application settings can be modified using an Xdefaults file. For full details, refer to the man page of the application in question.

Terminal colors

Most terminals support at least 16 basic colors, including xterm and uxrvt. The following is an example of a 16-color scheme.

The colors 0-7 are the 'normal' colors, while color 8-15 are their 'bright' counterparts (used for highlighting, etc.)

! 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
! DarkMangenta + Mangenta
*color5:  #ce5c00
*color13: #f57900
!DarkCyan + Cyan (both not tango)
*color6:  #89b6e2
*color14: #46a4ff
! LightGrey + White
*color7:  #cccccc
*color15: #ffffff

For more examples of color schemes, see the Other Resources section at the bottom of this article.

Desktop preferences

Xcursor settings

Set the theme and size of your mouse cursor:

Xcursor*theme: Vanilla-DMZ-AA
Xcursor.size:  22

Available themes reside in /usr/share/icons and local themes can be installed to ~/.icons

Xft Font Settings

Define basic font settings without the need of a fonts.conf file or Desktop Environment.

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

xterm preferences

urxvt preferences

Rxvt-unicode features an extensive list of options which can be configured via Xdefaults. Refer to the urxvt man page for details.

! font preference
urxvt*font:      -*-terminus-*-*-*-*-*-*-*-*-*-*-*-*
urxvt*boldFont:  -*-terminus-*-*-*-*-*-*-*-*-*-*-*-*
!initial size
urxvt*geometry:           120x35
!internal whitespace
urxvt*internalBorder:     5
!fade text n% upon unfocus
urxvt*fading:             20
!darken=(0 to 100) lighten=(-1 to -100)
urxvt*shading:            30
!tint background with this color
urxvt*tintColor:          black
!set to 24-bit for pseudo-transparency
!urxvt*depth:             24
!set to 32-bit for real transparency (compositing required)
urxvt*depth:              32
!save n lines of scrollback buffer
urxvt*saveLines:          32767
!flash screen for attention
urxvt*visualBell:         true
!jump to bottom (prompt) on keypress
urxvt*scrollTtyKeypress:  true
!jump to bottom (prompt) when tty gets new lines
urxvt*scrollWithBuffer:   false
!jump to bottom (prompt) on tty output
urxvt*scrollTtyOutput:    false
!toggle scrollbar
urxvt*scrollBar:          false
!scrollbar styles: rxvt, plain, next or xterm
urxvt*scrollstyle:        plain
!scrollbar alignment
urxvt*scrollBar_right:    true
urxvt*scrollColor:        #777777
urxvt*cursorColor:        #ffcc00
!is this a login shell?
urxvt*loginShell:         true
!set the TERM environment variable
urxvt*termName:           rxvt
!enable pseudo-transparency (requires depth=24 as well)
urxvt*inheritPixmap:      true
!delimiters for double-click mouse selection
urxvt*cutchars:           "()*,<>[]{}|' !double-click selection delimters
!screen dump settings
urxvt*print-pipe:         cat > $(echo urxvt.dump.`date +'%Y%M%d%H%m%S'`)
!secondary screen scroll (default enabled)
urxvt*secondaryScroll:    true
!de-iconify (map) on receipt of a bell character
urxvt*mapAlert:           true
!inhibit writing record into the system log file utmp
urxvt*utmpInhibit:        true
!! BEGIN urlLauncher settings !!
urxvt*perl-lib:           /usr/lib/urxvt/perl/
urxvt*perl-ext-common:    default,matcher
urxvt*urlLauncher:        /usr/bin/firefox
urxvt*matcher.button:     1
urxvt*matcher.pattern.1:  \\bwww\\.[\\w-]+\\.[\\w./?&@#-]*[\\w/-]
!! END urlLauncher settings !!

!transparent=0000 opaque=ffff
urxvt*background: rgba:1111/1111/1111/dddd

aterm preferences

Need more info. Volunteers welcome =)

xpdf preferences

Some basic settings for Xpdf, a lightweight Adobe PDF viewer:

xpdf*enableFreetype:    yes
xpdf*antialias:         yes
xpdf*foreground:        black
xpdf*background:        white
xpdf*urlCommand:        /usr/bin/firefox %s
xpdf*viKeys:            on

xclock preferences

Some basic xclock settings. See xclock man page for all X resources.

xclock*analog:	        false     ! display digital
xclock*update:	        1         ! update every 1 sec
xclock*Foreground:     white
xclock*background:     black

xscreensaver theming

A sample Xscreensaver theme. For more information, refer to the xscreensaver man page. View the resulting theme.

!xscreensaver theme
!font settings
xscreensaver.Dialog.headingFont:             -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1
xscreensaver.Dialog.bodyFont:                -*-fixed-medium-r-*-*-*-120-*-*-*-*-iso8859-1
xscreensaver.Dialog.labelFont:               -*-fixed-medium-r-*-*-*-120-*-*-*-*-iso8859-1
xscreensaver.Dialog.unameFont:               -*-fixed-medium-r-*-*-*-120-*-*-*-*-iso8859-1
xscreensaver.Dialog.buttonFont:              -*-fixed-bold-r-*-*-*-120-*-*-*-*-iso8859-1
xscreensaver.Dialog.dateFont:                -*-fixed-medium-r-*-*-*-100-*-*-*-*-iso8859-1
xscreensaver.passwd.passwdFont:              -*-fixed-bold-r-*-*-*-100-*-*-*-*-iso8859-1
!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
!must be a number greater than 0
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

Color Scheme Script

Contributed by smurnjiff

#!/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 forground color,
#   out of 17 (default + 16 escapes), followed by a 
#   test use of that color on all nine background 
#   colors (default + 8 escapes).
#

T='gYw'   # The test text

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

Contributed .Xdefaults

Check out these links for some real world examples of Xdefaults, contributed by fellow community members:

http://dotfiles.org/~buttons/.Xdefaults
http://code.suckless.org/hg/dextra/file/513faba2591f/dolby/Xdefaults
http://dotfiles.org/~thayer/.Xdefaults

Other Resources