xset

systemLinux/Unix
The xset command is one of the most frequently used commands in Linux/Unix-like operating systems. xset User preference utility for X Window System

Quick Reference

Command Name:

xset

Category:

system

Platform:

Linux/Unix

Basic Usage:

xset [options] [arguments]

Common Use Cases

    Syntax

    xset [options]

    Options

    Display Control Options

    Option Description
    -display display Specifies which X display to use
    s [timeout] Set screen saver parameters. If timeout is 0, screen saver is disabled
    s [blank|noblank] Sets the preference for the screen saver to blank the video (or not)
    s [expose|noexpose] Sets the preference for the screen saver to expose (or not expose) the window
    s [on|off|default] Turns the screen saver on, off, or sets it to default
    s [timeout [cycle]] Sets the timeout and cycle parameters for screen saver
    +dpms Enables DPMS (Energy Star) features
    -dpms Disables DPMS (Energy Star) features
    dpms [standby [suspend [off]]] Sets DPMS timeout values in seconds
    dpms force [standby|suspend|off|on] Forces the monitor to immediately go into a specific DPMS mode

    Keyboard Control Options

    Option Description
    c [on|off] Turns key-click on or off
    c [volume] Sets key-click volume (0-100)
    r [rate [delay]] Sets keyboard repeat rate (delay in ms, rate in Hz)
    r on|off Turns keyboard repeat on or off
    led [led-number] Turns the specified LED on or off (1-32)
    led on|off Turns all keyboard LEDs on or off
    m [accel [threshold]] Sets mouse acceleration and threshold
    m default Sets mouse acceleration and threshold to default values

    Bell Control Options

    Option Description
    b [on|off] Turns bell on or off
    b [volume [pitch [duration]]] Sets bell volume (0-100), pitch (Hz), and duration (ms)

    Font Path Options

    Option Description
    fp= path[,path...] Sets font path to the specified path(s)
    fp default Sets font path to default
    fp rehash Resets font path to its current value
    +fp path[,path...] Adds the specified paths to the front of the current font path
    -fp path[,path...] Removes the specified paths from the current font path

    Query and Miscellaneous Options

    Option Description
    q Queries current settings
    q [option] Queries specific option setting (s, pointer, dpms, etc.)

    Examples

    How to Use These Examples

    The examples below show common ways to use the xset command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    # Disable screen saver xset s off
    # Enable screen saver with timeout of 600 seconds xset s 600
    # Turn off DPMS (Energy Star) features xset -dpms
    # Turn on DPMS features xset +dpms
    # Set DPMS timeouts (standby, suspend, off) in seconds xset dpms 300 600 900
    # Set keyboard repeat rate (delay in ms, rate in Hz) xset r rate 250 30 # Disable system bell xset b off # Enable system bell with volume 50%, pitch 400Hz, duration 100ms xset b 50 400 100 # Advanced Examples Advanced # Force standby mode now xset dpms force standby # Force monitor to suspend mode xset dpms force suspend # Force monitor to off mode xset dpms force off # Query current settings xset q # Lock keyboard mappings and modifiers xset q

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The `xset` command is a user preference utility for the X Window System that allows users to set various options for the display, keyboard, mouse, and more. It is particularly useful for adjusting screen saver settings, power management features, keyboard behavior, mouse acceleration, and other X server preferences. **Key Features:** 1. **Screen Saver Control**: xset provides control over the X server's built-in screen saver functionality, allowing users to enable or disable it, set timeout periods, and configure behavior. 2. **DPMS (Display Power Management Signaling)**: xset can enable, disable, and configure DPMS settings, which are used to control monitor power-saving features. 3. **Keyboard Settings**: It allows users to adjust keyboard repeat rates, key click volume, and LED states. 4. **Mouse Settings**: xset can adjust mouse pointer acceleration and threshold values. 5. **System Bell**: It provides control over the system bell's volume, pitch, and duration. 6. **Font Path Management**: The command allows for modification of the X server's font path, which determines where the server looks for fonts. **Common Use Cases:** 1. **Power Management**: System administrators and users often use xset to configure power-saving settings for displays, such as setting monitor standby, suspend, and off timeouts. 2. **Screen Saver Configuration**: xset can be used to enable or disable the screen saver and set its timeout period. 3. **Input Device Tuning**: Users can customize keyboard and mouse behavior to match their preferences for speed and sensitivity. 4. **Desktop Environment Setup**: xset commands are frequently included in X session startup scripts to establish preferred settings when a user logs in. 5. **Troubleshooting**: The query function of xset is useful for diagnosing problems with X server settings. **Important Notes:** 1. **Session-Based Settings**: Changes made with xset are typically only in effect for the current X session. They don't persist across reboots or new X server instances unless added to session startup scripts. 2. **Desktop Environment Interaction**: Modern desktop environments may override xset settings with their own configuration tools and daemons. In some cases, you may need to disable these features to use xset effectively. 3. **Compatibility**: Not all X servers support all xset features. Hardware support for features like DPMS varies across different graphics cards and monitors. 4. **Security Considerations**: Since xset can modify X server settings, it should be used with caution in multi-user environments where users shouldn't have control over global X server settings. **Related Components:** 1. **X Resource Database**: The X Resource Database (often accessed via the `xrdb` command) is another mechanism for setting X preferences, but it works at the application level rather than the server level. 2. **Desktop Environment Settings**: Modern desktop environments like GNOME, KDE, and Xfce provide their own GUI tools for configuring many of the same settings that xset controls. 3. **Power Management Daemons**: Systems may use daemons like `pm-utils`, `power-profiles-daemon`, or desktop-specific power managers that interact with or override DPMS settings. **Technical Details:** 1. **Implementation**: xset communicates with the X server using the X11 protocol to modify server parameters. 2. **Configuration Storage**: Unlike many configuration utilities, xset does not maintain its own configuration file. Settings are applied directly to the running X server. 3. **Default Values**: Default values for xset parameters are determined by the X server and may vary across different implementations and versions. **Historical Context:** xset is one of the original X Window System utilities, dating back to the early development of X. Its design reflects the X philosophy of providing modular tools with specific purposes rather than integrated configuration systems. Despite the advent of more modern configuration methods, xset remains useful for its direct control over X server parameters and its scriptability. **Examples of Common Uses in Scripts:** 1. **Disabling screen blanking for presentations**: ```bash xset s off -dpms # Turn off screen saver and DPMS # presentation commands xset s on +dpms # Restore screen saver and DPMS when done ``` 2. **Setting up preferred keyboard behavior**: ```bash xset r rate 200 30 # Set keyboard repeat delay to 200ms and rate to 30 repeats/second ``` 3. **Forcing display power state**: ```bash xset dpms force off # Force display to power off sleep 5 xset dpms force on # Wake display up ``` In summary, xset is a versatile command-line tool for managing X server preferences, particularly useful for scripts, session initialization, and quick adjustments to X behavior. While its role has diminished somewhat with the rise of integrated desktop environments, it remains an important tool for X Window System management.

    Related Commands

    These commands are frequently used alongside xset or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the xset command works in different scenarios.

    $ xset
    View All Commands