getbkgd - Linux


getbkgd is a command-line utility designed to retrieve the background image currently set for the X Window System desktop. It provides a convenient way to access and modify the desktop background, enabling users to customize their desktop appearance.


getbkgd [options]


-h, –help
Display help and usage information.

-l, –list
List all available background images.

-s, –set Set the desktop background to the specified image or directory.

-r, –remove
Remove the current desktop background.

-p, –print
Print the path to the current desktop background image.

-d, –default
Restore the default desktop background image.

-c, –config Specify a custom configuration file.


List available background images:

getbkgd -l

Set a specific background image:

getbkgd -s ~/Pictures/background.jpg

Set a random background image from a directory:

getbkgd -s ~/Pictures/Wallpapers

Remove the current background image:

getbkgd -r

Print the path to the current background image:

getbkgd -p

Common Issues

  • No backgrounds listed: Ensure that you have at least one background image available in your XDG_BACKGROUND_DIR directory (usually ~/.local/share/backgrounds/).
  • Background not changing: Verify that your X Window System settings allow for desktop background modifications. Also, check if any other applications or scripts are overriding the background settings.


getbkgd can be integrated with other commands and tools to automate desktop customization tasks:

# Set a random background image every hour:
while true; do getbkgd -s ~/Pictures/Wallpapers; sleep 3600; done

Related Commands

  • xwallpaper: Set the desktop background using the X Window System API.
  • feh: A versatile image viewer with background setting capabilities.