Path: /debloat_components/debloat_apply_background.py
Sets the Windows desktop background to a predefined image from the project's media directory.
Automatically apply a corporate or branded wallpaper as part of the system debloat and configuration process.
Ensure consistency of desktop appearance across multiple machines by deploying a standard background image.
Python standard libraries: os, sys, ctypes
utilities.util_logger.logger for logging
utilities.util_error_popup.show_error_popup for user-facing error dialogs
Parameter | Type | Description | Default |
---|---|---|---|
wallpaper_filename | string | Name of the wallpaper image file located in the media directory | desktop_background.png |
python debloat_apply_background.py
On execution, the script determines the base path (handling frozen executable vs script mode), locates the media directory, and constructs the full path to the desktop_background.png
file. It then uses the Windows API via ctypes.windll.user32.SystemParametersInfoW with the SPI_SETDESKWALLPAPER
flag and update options to apply the wallpaper and update system settings.
If the wallpaper file is missing, the script logs an error, displays a modal popup via show_error_popup, and exits with status code 1. Any failure in calling the Windows API is caught, logged, a popup is shown, and the script terminates with an error status.
The script requires permission to modify system settings and uses Windows API calls that may be restricted by user privilege levels. No user-supplied input is executed, reducing injection risks.
Uses util_logger at INFO
level to report steps like applying the wallpaper and ERROR
level when encountering missing files or API failures.
Place a valid desktop_background.png
in the media directory and run the script to confirm the wallpaper changes. Rename or remove the image to test error handling. For automated tests, mock ctypes.windll.user32.SystemParametersInfoW to simulate success and failure scenarios.
Frog for reference:
Author: Raven Development Team