I am trying to change my windows 11 background wallpaper using the simplest way, so I just found py-wallpaper
library where I can:
from wallpaper import set_wallpaper, get_wallpaper
# getting the current wallpaper
print(get_wallpaper())
# setting a new wallpaper
set_wallpaper("FULL_IMG_PATH")
But even if I use one of them I just get this error:
>>> wallpaper.set_wallpaper(r"C:\Users\Khaled\Downloads\Screenshot 2022-08-13 190317.png")
'C:\Users\Khaled\AppData\Local\Programs\Python\Python310\Lib\site-packages\wallpaper\win-wallpaper.exe' is not recognized as an internal or external command,
operable program or batch file.
[]
Note: I do not want to use ctypes
win.py
contains the code used to set and load wallpapers. The file contains these lines at the top:
import os
real_path = os.path.realpath(__file__)
win_wallpaper_path = os.path.join(os.path.dirname(real_path), 'win-wallpaper.exe')
The script is trying to call win-wallpaper.exe
from wherever win.py
is located. Anyway, as the comments mention, the developer didn't list this requirement, but I looked it up and found this repository on GitHub which seems to be the required program.
The source code of wallpaper.c
in that repo is only 41 lines. You can read through the source followed by downloading the binary if you deem it safe.