debloat_apply_background

Path: /debloat_components/debloat_apply_background.py

Overview

Sets the Windows desktop background to a predefined image from the project's media directory.

Purpose & Use Cases

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.

Dependencies

Python standard libraries: os, sys, ctypes

utilities.util_logger.logger for logging

utilities.util_error_popup.show_error_popup for user-facing error dialogs

Configuration & Parameters

Parameter Type Description Default
wallpaper_filename string Name of the wallpaper image file located in the media directory desktop_background.png

Usage Example

python debloat_apply_background.py

Behavior & Implementation

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.

Error Handling

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.

Security Considerations

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.

Logging

Uses util_logger at INFO level to report steps like applying the wallpaper and ERROR level when encountering missing files or API failures.

Testing & Validation

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

Author: Raven Development Team