fbset Command in Linux



The fbset command in Linux shows and modifies the frame buffer device settings. A frame buffer device in Linux allows software to interact with and manage the graphics hardware to render output on the display.

In Linux, frame buffer devices are categorized as character devices and are found in the /dev directory. The /dev/fb0 is the first frame buffer, but a system can have multiple frame buffer devices depending on the configuration.

Table of Contents

Here is a comprehensive guide to the options available with the fbset command −

Prerequisites to Use fbset Command

By default, the fbset command may not be installed on Linux. To check whether fbset is installed or not, use −

fbset --version
Prerequisites to Use fbset Command

If no version is displayed then fbset might not be installed. To install it, use the instructions given below.

To install fbset on Ubuntu, Debian, Kali Linux, and other Debian-based distributions, use the following command −

sudo apt install fbset

Syntax of fbset Command

The syntax of the Linux fbset command is as follows −

fbset [options] [mode]

The [options] field is used to specify various options to display and modify frame buffer devices. While [mode] is used to set the display mode from the mode database.

fbset Command Options

The options used with the fbset command are listed in the following table −

Options Description
-h (--help) It is used to display help related to the command
-s (--show) It is used to display the video mode settings
-i (--info) It is used to display the frame buffer information
-v (--verbose) It is used to display detailed output
-V (--version) It is used to display the command version
-x (--xfree86) It is used to display timing information in XFree86 compatible format
-a (--all) It is used to change all virtual consoles on this device
-fb device It is used to specify the frame buffer device (if not mentioned then the default is /dev/fb0)
-db file It is used to specify alternative video modes (default is /etc/db.modes)
-rgba red, green, blue, alpha It is used to specify the length and color offset of each channel (e.g., -rgba 8/16, 8/8, 8/0, 0/0)

Examples of fbset Command in Linux

This section demonstrates the usage of the fbset command in Linux −

  • Displaying the Current Frame Buffer Settings
  • Displaying all the Available Frame Buffer Information
  • Displaying Information in XFree86 Format
  • Changing Video Mode Database
  • Setting Display Geometry
  • Setting Display Timings
  • Setting Display Flags
  • Modifying Display Position

Displaying the Current Frame Buffer Settings

To display the current frame buffer settings, execute the fbset command without any options. You need sudo permission to run the command −

sudo fbset 
Displaying Current Frame Buffer Settings

In the above output image, the mode "900x700" represents the display mode. The geometry "900 700 1280 800 32" specifies the actual display resolution (900x700), virtual resolution (1280x800), and color depth (32 bits).

Timings are set to default values (0s), indicating no specific timing values. The rgba 8/16,8/8,8/0,0/0 specifies the bit allocation and offsets for red, green, blue, and alpha channels. The endmode marks the end of the mode definition.

Note that the above command displays information on the default /dev/fb0 frame buffer device.

In the same way, to display the frame buffer settings of a specific device, specify the device name using the -fb option.

sudo fbset -fb /dev/fbX

Here, X can be 0, 1, 2, and so on depending upon the total devices configured with the system.

Displaying All the Available Frame Buffer Information

To print the information of all the available frame buffers, use the -i or --info options.

sudo fbset -i
Displaying All Available Frame

Displaying Information in XFree86 Format

The XFree86 is an open-source X windows system. To display XFree68 compatible timing information, use the -x or --xfree86 options −

sudo fbset --xfree86
Displaying Information in XFree86 Format

Changing Video Mode Database

The default video mode database is /etc/fb.modes, however, it can be set to another using the -db option.

sudo fbset -db /path/video/mod

Specify the path of the alternate video mode database.

Setting Display Geometry

Parameters to modify the display geometry using the Linux fbset command are listed below −

Options Description
-xres value It is used to set the horizontal resolutions (in pixels)
-yres value It is used to set the vertical resolutions (in pixels)
-vxres value It is used to set the virtual horizontal resolutions (in pixels)
-vyres value It is used to set the virtual vertical resolutions (in pixels)
-depth value It is used to set the depth (bits per pixel)
-nonstd value It is used to select not standard video mode
-g value / --geometry value It is used to set all parameter at once (order -g -xres, -yres, -vxres, -vyres, -depth)
-match It is used to make the physical resolution match the virtual resolution

To set a different display resolution, use the -xres and -yres parameters.

sudo fbset -xres 800 -yres 600

To verify the resolution, use the fbset command −

Setting Display Geometry

To change the virtual resolution, use the -vxres and -vyres parameters −

sudo fbset -vxres 1024 -vyres 768

The virtual resolution is the resolution the framebuffer can handle, which might be larger than the display resolution.

All display geometry parameters can also be modified at once using the -g or the --geometry options. The syntax is as follows −

sudo fbset -g xres yres vxres vyres depth

To change the resolution to 800x600, the virtual resolution to 1024x768, and the depth to 24, use the following command.

sudo fbset -g 800 600 1024 768 24

Setting Display Timings

The display timing can be set using the parameters mentioned in the following table −

Options Description
-pixclock value It is used to set the pixel lock length (in picoseconds)
-left value It is used to set the left margin in pixels (number of pixels to leave blank from left)
-righ value It is used to set the right margin in pixels (number of pixels to leave blank from right)
-upper value It is used to set the upper margin in pixels lines (number of pixels to leave blank from up)
-lower value It is used to set lower margin in pixel lines (number of pixels to leave blank from bottom)
-hslen value It is used to set horizontal sync length in pixels (duration of horizontal synchronous pulse)
-vhlen value It is used to set vertical sync length in pixel lines (duration of vertical synchronous pulse)
-t / --timing value/ value It is used to set all parameters at once (order -t pixclock, left, right, upper, lower, hslen, vhlen)

To modify the pixclock, use the -pixclock option −

sudo fbset -pixclock 15385

The value 15385 is set in picoseconds.

To set the left and right margins, use the -left and the -right options −

sudo fbset -left 60 -right 70

This command will leave the 60 pixels from the left and 70 pixels from the right blank.

To set all parameters at once, use the following syntax −

sudo fbset -t pixclock left right upper lower hslen vslen

For example −

sudo fbset -t 15385 60 70 30 10 100 2

Note that left, right, and hslen values are specified in pixels. While the upper, lower, and vslen parameters are specified in pixel lines.

Setting Display Flags

To enable or disable the display flags simply set them true or false, high or low accordingly.

For example, to set the hsync flag high, use the following command −

sudo fbset -hsync high

Similarly, to enable the extsync, use −

sudo fbset -extsync true

Various display flags are given in the table below −

Options Description
-accel true/false It is used to set the hardware text acceleration
-hsync true/false It is used to set the horizontal sync polarity
-vsync true/false It is used to set the vertical sync polarity
-csync true/false It is used to set the composite sync polarity
-gsync true/false It is used to set sync on green
-extsync true/false It is used to set the external sync
-sync true/false It is used to set a custom sync value
-bcast true/false It is used to enable the broadcast
-laced true/false It is used to enable interlace
-double true/false It is used to enable the double-scan
-rgba r,g,b,a true/false It is used to specify the lengths of color entries
-grayscale true/false It is used to enable or disable grayscale

Modifying Display Position

The following parameters move the displayed image within the framebuffer −

Options Description
-move left,right,up,down It is used to move the visible part
-step value It is used to set the step value in pixel or pixel lines (default: 8 pixels horizontals, 2 pixel lines vertical)

To change the display position within the frame buffer, use the -move option. For example, to move the display left by 8 pixels horizontally use −

sudo fbset -move left

Note that 8 pixels horizontal and 2 pixel lines vertical are default values. If no value is mentioned, then these values will be default values. To modify these values, use the -step option −

sudo fbset -move left -step 10

Conclusion

The fbset command in Linux displays and modifies frame buffer device settings. It must be installed to use and is useful for adjusting graphical hardware settings to meet display requirements.

In this tutorial, we explained the fbset command, its installation, syntax, options, and usage through various examples.

Advertisements