getbkgrnd - Linux


getbkgrnd is a command-line tool used to retrieve the current desktop background image on Linux systems that use the X Window System. It is particularly useful for managing and customizing desktop aesthetics.


getbkgrnd [options]


  • -c, –config-file: Specify the configuration file where background settings are stored.
  • -d, –desktop: Indicate the desktop number to retrieve the background for (e.g., 1, 2, or virtual desktops).
  • -f, –format: Output the retrieved background image in the specified format (JPEG, PNG, or BMP).
  • -h, –help: Display usage information.
  • -v, –version: Display the version of getbkgrnd.
  • -w, –width: Specify the desired width of the retrieved background image.
  • -H, –height: Specify the desired height of the retrieved background image.
  • -s, –scale: Scale the retrieved background image to the specified percentage.


  • Get the current desktop background image:
  • Retrieve the background image for desktop 2:
getbkgrnd -d 2
  • Save the background image as a PNG file:
getbkgrnd -f PNG -c /usr/share/gconf/desktop-background.gconf
  • Set the height of the background image to 720 pixels:
getbkgrnd -H 720

Common Issues

  • Error retrieving background: Ensure that the configuration file specified by the -c option exists and contains the background settings.
  • Invalid image format: Ensure that the specified format using the -f option is supported by the getbkgrnd tool.
  • Incorrect dimensions: Verify that the specified dimensions using the -w and -H options are valid for the background image.


getbkgrnd can be integrated with other tools and scripts to automate tasks related to desktop background management. For example:

  • Set a random background image on startup:
BACKGROUND=$(getbkgrnd -f PNG /usr/share/gconf/desktop-background.gconf)
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s "$BACKGROUND"

Related Commands

  • gsettings: Command-line tool for manipulating system settings.
  • xfconf-query: Tool for querying and setting Xfce settings.
  • feh: Command-line image viewer that can be used to set desktop backgrounds.