xset a tutorial

 

xset is a tool, which allows specifying certain configuration, for the X11 server. Mainly these configuration, are related to hardware, that the X11 server interacts with, so the keyboard, the mouse, the display, this being said, the display power management, the display color, the fonts …

Viewing the settings

All of these particular settings, can be viewed by issuing the command xset q, as follows:

$ xset q 
# Query the settings.

Keyboard Control:
  auto repeat:  on    key click percent:  0    LED mask:  00000000
  XKB indicators:
    00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off
    03: Compose:     off    04: Kana:        off    05: Sleep:       off
    06: Suspend:     off    07: Mute:        off    08: Misc:        off
    09: Mail:        off    10: Charging:    off    11: Shift Lock:  off
    12: Group 2:     off    13: Mouse Keys:  off
  auto repeat delay:  500    repeat rate:  20
  auto repeating keys:  00ffffffdffffbbf
                        fadfffefffedffff
                        9fffffffffffffff
                        fff7ffffffffffff
  bell percent:  50    bell pitch:  400    bell duration:  100
Pointer Control:
  acceleration:  2/1    threshold:  4
Screen Saver:
  prefer blanking:  yes    allow exposures:  yes
  timeout:  600    cycle:  0
Colors:
  default colormap:  0x20    BlackPixel:  0x0    WhitePixel:  0xffffff
Font Path:
  /usr/share/fonts/X11/misc,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,built-ins
DPMS (Energy Star):
  Standby: 600    Suspend: 0    Off: 900
  DPMS is Enabled
  Monitor is On

Keyboard settings

So as you see, the first settings which are displayed, are the keyboard settings.

Keyboard Control:
  auto repeat:  on    key click percent:  0    LED mask:  00000000
  XKB indicators:
    00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off
    03: Compose:     off    04: Kana:        off    05: Sleep:       off
    06: Suspend:     off    07: Mute:        off    08: Misc:        off
    09: Mail:        off    10: Charging:    off    11: Shift Lock:  off
    12: Group 2:     off    13: Mouse Keys:  off
  auto repeat delay:  500    repeat rate:  20
  auto repeating keys:  00ffffffdffffbbf
                        fadfffefffedffff
                        9fffffffffffffff
                        fff7ffffffffffff
  bell percent:  50    bell pitch:  400    bell duration:  100

The keyboard has auto repeat set to on. Auto repeat, as in auto repeating a key, when being pressed. Auto repeat can be set to off, by issuing xset r off, and can be turned back on, by issuing xset r on.

Additionally auto repeat can be set on or off for a particular key, by using the key code between 0 and 255.

Key code is not the encoding, or the character code, but actually when a key is pressed on a keyboard, a scan code is sent to the kernel, which converts it to a key code. You can view a key code for a particular key by using xev, or you can view all the key codes, by using xmodmap -pk .

An example of setting, and removing auto repeat, for a particular keyboard key, is as follows:

xset -r 36 
# Disable auto repeat for the a key

xset r 36
# Enable auto repeat for the a key 

Other auto repeat options, which are displayed, are the delay, and the rate.

The delay, is the delay in milliseconds, before auto repeating a key kicks in. In this case, it is set to 500 milliseconds.

The repeat rate, is the rate, by which the key being pressed, is repeated in a second. In this case, it is set to 20 repetitions per second.

$ xset r rate
# will set both the delay, and the 
# repeat rate to their default value.

$ xset r rate 200
# will set the delay to 
# 200 milliseconds, and
# the rate is not affected.

$ xset r rate 200 10
# will set the delay to 
# 200 milliseconds, 
# and the repeat rate
# to 10 per second.

The key click percent, is related to the sound volume, which is generated by a keyboard key click. In this example it is set to 0 .

A keyboard key click sound, can be set to on, by using xset c on, this will set a default key click, sound volume value.

A keyboard key click sound, can be set to off, by using xset c off, and it can be set to percentage, by using xset c on 65 where 65, is any integral value, between 0, and 100.

The led mask, indicates which keyboard led, is turned on , this is displayed in a more verbose manner, in the xkb indicators section:

...                LED mask:  00000000
XKB indicators:
    00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off
... 

So in this example, no led is turned on, so you can think, that the caps lock was not pressed, and that the num lock is not pressed, and etc …

keyboard led can all be turned on or off, by using xset led, and xset -led, individual keyboard led can be turned on or off, by using xset led named "LED_NAME", and xset -led named "LED_NAME", where LED_NAME can be for example Scroll Lock, as in xset led named "Scroll Lock" . Additionally individual keyboard led, can be turned on or off, by using a numeric value between 1 and 32, as in xset led 2 and xset -led 2.

The bell options, are also displayed, as in

bell percent:  50    bell pitch:  400    bell duration:  100

where bell percent is the bell volume percentage, the bell pitch is the sound pitch in hertz, as in being a high or a low tone, and the bell duration, is the sound duration in milliseconds.

All these can be set to their default values, by using xset b, the sound can be turned off, by using xset -b, and you can provide between 1 or 3 values, where the first is for the sound percent, the second is for the pitch, and the third, is for the duration. As an example, you can do something like this.

$ xset b 40 500 200
# set the bell volume to 
# 40%, the pitch to 500 hz,
# and the duration to 200
# milliseconds. 

pointer settings

The pointer control settings are:

Pointer Control:
  acceleration:  2/1    threshold:  4

The threshold, is the threshold in pixel, in a span of 10 milliseconds, after which the acceleration is going to happen.

So in this example, the threshold is set to 4, which means, that after a pointer movements of 4 pixels, in 10 milliseconds, an acceleration of 2 in pointer movement, is going to happen.

To set the acceleration, and the threshold, the m option, can be used, If no parameters are provided, as in xset m, then the default values, for these options are set.

If only one parameter is passed, as in 2 or 3/2, then only acceleration is set, and the threshold is unaffected.

if two parameters are passed, then the second one is the threshold.

You can also pass 0, for the threshold. In this case, the acceleration is used as the exponent of a formula, which enables precise control, when the mouse is moving slowly, and far reach, when the mouse is moving quickly, and progressive movement when the mouse is moving in between.

$xset m 3/2 0 
# The threshold is set to 0, 
# and the acceleration to 1.5 

The m option will apply these parameters, to all connected input devices.

Screen saver

The screen saver settings are :

Screen Saver:
  prefer blanking:  yes    allow exposures:  yes
  timeout:  600    cycle:  0

They can be set by using the s option. If only xset s, is used, then the default values for the screen saver are set.

To turn on the screen saver, you can use xset s on , which will basically set the timeout, to a default value, for example 600 .

To turn off the screen saver, you can use xset s off, which will basically set the timeout value to 0.

So how does the screen saver work? Well, basically after a period, of no user activity, called the timeout period, the screen will either go blank, or will display some patterns, which are changed, every time cycle.

The timeout, and the cycle values, can be set, by using xset timeout cycle, where timeout and cycle, are numerical values, as in 1 or 2, and they represent time in seconds.

$ xset s 10 10
# sets the timeout and the cycle
# to be 10 seconds each.

$ xset 10 
# In this case, only the
# timeout is set to 10, 
# the cycle keeps its 
# old value. 

To prefer the screen blanking, if the hardware supports that, xset s blank can be used, and to prefer screen saver patterns, xset s noblank can be used.

screen saver pattern

To force an application to redraw its contents, after the screen saver is deactivated, for example, when a user re interacted with the computer, xset s expose can be used, and xset s noexpose can be used, if you want, the window manager, to save the applications displayed content, and restore it, when the screen saver is deactivated. if the window manager, does not support such an option, then the screen saver will not work.

In the old days, screen saver, helped in protecting screen burns, from happening. Basically a screen burn, is like if an image is displayed, on a screen, for a long period of time, it is like as if the image is burnt on the screen, so you might end with a permanent reflection of this image, on the screen.

Colors

An example of color settings, displayed using xset q is :

Colors:
  default colormap:  0x20    BlackPixel:  0x0    WhitePixel:  0xffffff

0x20 is the id of the colormap, which is being used. A colormap, is how pixel values, for example 00000000 are going to be mapped to colors, for example, is it a monochrome color, an rgb color, or the like.

On some screens, black is not necessary black, and white is not necessary white, hence BlackPixel, is the value for a black pixel, and WhitePixel, is the value for a white pixel.

Font Path

Font path, is where X11 core fonts, are installed .

Font Path:
  /usr/share/fonts/X11/misc,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,built-ins

A path can be a directory name , or it can also be a font server name.

Setting the font path, can be done by using the fp option of xset, fp as in font path.

In order to completely change the font path, you can use xset fp= PATH , as in:

$ xset fp= /usr/share/fonts/X11/misc,/usr/share/fonts/X11/100dpi/

Font paths, must be separated by a comma .

To restore the font path, to its default value, you can use xset fp default .

What if what was wanted, was to just add entries to the beginning, or to the end of the font path? In this case +fp, and fp+, can be used.

xset fp+ /usr/share/fonts/X11/misc,/usr/share/fonts/X11/100dpi/:unscaled
# Add the given two
# paths, to the end of
# the font path.

If entries are to be removed, from the beginning, or from the end of the font path, -fp or fp- can be used.

xset -fp /usr/share/fonts/X11/misc,/usr/share/fonts/X11/100dpi/:unscaled
# remove the provided two
# paths, from the beginning of 
# the font path.

Finally if you want the server to reread the font databases, for the currently set path, like after having added some fonts, xset fp rehash can be used.

DPMS

DPMS stands for, display power management signaling, this is an example of DPMS settings.

DPMS (Energy Star):
  Standby: 600    Suspend: 0    Off: 900
  DPMS is Enabled
  Monitor is On

DPMS, is related to what you want to do, with your monitor, when you are not using your computer. So you can set your monitor to go into standby, suspend, or to be off, after a given period of inactive time, has elapsed.

The idle time for each of, standby, suspend, and off, can be provided , in seconds by using xset dpms stand_time suspend_time off_time. If 0 is set for any of these values, then it means that its is disabled.

$ xset dpms 600 0 900
# The screen will go into 
# standby after 600, suspend 
# is disabled, also it was
# set that after 900 seconds
# the screen will be turned
# off.

$ xset dpms 0 
# Standby is disabled, 
# suspend and power off, 
# will keep their old values.

The screen can be forced to go into one of these modes, by using xset dpms force followed by one of standby, off, or on, as for example xset dpms force standby .

Display power management, can be enabled or disabled, by using xset +dpms, and xset -dpms.