Skip to content

Fix: wallpaper-restore.sh (safe expansion, handle spaces, add robustness checks)#1462

Open
rajghosh06-dev wants to merge 1 commit intomylinuxforwork:mainfrom
rajghosh06-dev:fix-wallpaper-restore
Open

Fix: wallpaper-restore.sh (safe expansion, handle spaces, add robustness checks)#1462
rajghosh06-dev wants to merge 1 commit intomylinuxforwork:mainfrom
rajghosh06-dev:fix-wallpaper-restore

Conversation

@rajghosh06-dev
Copy link

@rajghosh06-dev rajghosh06-dev commented Feb 9, 2026

Description

This pull request fixes wallpaper-restore.sh by improving path handling, safe ~ expansion, support for spaces, and robust fallback mechanisms.

PATH: ~/.config/hypr/scripts/wallpaper-restore.sh


Changes

  • Improved
  • Bug Fixes
  • Feature
  • Documentation
  • Other

Context

The previous script had reliability issues:

  • Unsafe ~ expansion using sed
  • Paths with spaces breaking due to unquoted variables
  • Relative/malformed cache entries slipping through
  • Broken symlinks not detected
  • Non-image files accepted, causing restore errors
  • Limited and inconsistent default wallpaper fallback

This PR ensures wallpapers are restored reliably across Arch + Hyprland + ML4W OS setups.

How Has This Been Tested?

  • Tested on Arch Linux/Based Distro.
  • Tested on Fedora Linux/Based Distro.
  • Tested on openSuse.

Tested Scenarios (on local machine)

  • ~/Pictures/... paths → expand correctly
  • /home/user/Pictures/... absolute paths → remain untouched
  • Paths containing spaces (e.g., Holiday Photos) → handled safely
  • Empty or malformed cache entries → fall back to default wallpaper
  • Broken symlinks → fall back to default wallpaper
  • Non-image files (e.g., cached .txt) → rejected, default wallpaper used

Result: These tests confirm that corrupted paths are prevented and wallpapers are restored reliably across different setups.

Checklist

Please ensure your pull request meets the following requirements:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • My changes do not introduce new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes.

Screenshots

N/A

Related Issues

Fixes reliability issues in wallpaper-restore.sh.

Other related Issues are mentioned in Comments.

Additional Notes

  • Safe ~ expansion (only leading ~)
  • Quoted variables for paths with spaces
  • Path normalization with realpath -m
  • Guards for empty/malformed cache entries
  • Detection of broken symlinks
  • Validation to reject non-image files
  • Robust default wallpaper fallback in all failure cases

Note to Maintainers
Thank you for reviewing this contribution.
The changes are focused on improving reliability and robustness without altering existing functionality.
I appreciate your time and feedback, and I’m happy to make any adjustments if needed.


@rajghosh06-dev
Copy link
Author

Related/Similar Issues:

@rajghosh06-dev rajghosh06-dev changed the title Fix wallpaper-restore.sh: safe ~ expansion, handle spaces, add robustness checks Fix: wallpaper-restore.sh (safe expansion, handle spaces, add robustness checks) Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant