option to autodetect desktop wallpaper for use as backgroundImage #10165

Closed
opened 2026-01-31 02:14:06 +00:00 by claunia · 13 comments
Owner

Originally created by @cjwijtmans on GitHub (Aug 14, 2020).

My current setting for backgroundImage is

"backgroundImage": "C:\\Users\\<user>\\AppData\\Local\\Microsoft\\Windows\\Themes\\RoamedThemeFiles\\DesktopBackground\\<file>"

The problem is the file name is not static. So i would like an (default)option to autodetect dekstop wallpaper like

"backgroundImage": "DesktopBackground"
Originally created by @cjwijtmans on GitHub (Aug 14, 2020). My current setting for backgroundImage is ```json "backgroundImage": "C:\\Users\\<user>\\AppData\\Local\\Microsoft\\Windows\\Themes\\RoamedThemeFiles\\DesktopBackground\\<file>" ``` The problem is the file name is not static. So i would like an (default)option to autodetect dekstop wallpaper like ```json "backgroundImage": "DesktopBackground" ```
Author
Owner

@zadjii-msft commented on GitHub (Aug 14, 2020):

Is there an API to get the path of the current desktop background image? I'm not sure there is, but I've been wrong before.

I suppose this StackOverflow post has some answers. I'm not sure how stable those answers are, but they might work.

@zadjii-msft commented on GitHub (Aug 14, 2020): Is there an API to get the path of the current desktop background image? I'm not sure there is, but I've been wrong before. I suppose [this StackOverflow post](https://superuser.com/questions/966650/path-to-current-desktop-backgrounds-in-windows-10) has some answers. I'm not sure how stable those answers are, but they _might_ work.
Author
Owner

@bennettnicholas commented on GitHub (Sep 20, 2020):

@zadjii-msft / @DHowett I am a student and looking to help out in my free time. This would be my first attempt at any open source issue and my first time helping on the Terminal project. Would this be something you guys would like my help with? This looks fairly straight forward.

@bennettnicholas commented on GitHub (Sep 20, 2020): @zadjii-msft / @DHowett I am a student and looking to help out in my free time. This would be my first attempt at any open source issue and my first time helping on the Terminal project. Would this be something you guys would like my help with? This looks fairly straight forward.
Author
Owner

@cjwijtmans commented on GitHub (Sep 21, 2020):

@bennettnicholas The problem is there is no standard way to get the background image on windows. So this might be more difficult than you believe.

Ok i found this documentation

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa

Take a look at SPI_GETDESKWALLPAPER.

@cjwijtmans commented on GitHub (Sep 21, 2020): @bennettnicholas ~The problem is there is no standard way to get the background image on windows. So this might be more difficult than you believe.~ Ok i found this documentation https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa Take a look at SPI_GETDESKWALLPAPER.
Author
Owner

@cjwijtmans commented on GitHub (Sep 21, 2020):

Then the second thing to consider is using file watcher API to update the backgroundimage when the desktop wallpaper is changed but i dont think its very neccesary.

@cjwijtmans commented on GitHub (Sep 21, 2020): Then the second thing to consider is using file watcher API to update the backgroundimage when the desktop wallpaper is changed but i dont think its very neccesary.
Author
Owner

@bennettnicholas commented on GitHub (Sep 21, 2020):

@cjwijtmans I think using the SPI would work the best.

@bennettnicholas commented on GitHub (Sep 21, 2020): @cjwijtmans I think using the SPI would work the best.
Author
Owner

@bennettnicholas commented on GitHub (Sep 29, 2020):

I have been attempting to implement this. I am new to the code base, so I am having some issues getting used to where things are and how to debug.

Correct me if I am wrong, but I thought checking for a string value such as "Desktop" where you normally place the path could be checked in void CascadiaSettings::_ValidateMediaResources() in the file CascadiaSettings.cpp alongside when we check if the path converts to a URI, but I am having some issue extracting the backgroundimagepath to a sting. If it is "Desktop" then we could replace the path with the SPI_GETDESKWALLPAPER path.

@bennettnicholas commented on GitHub (Sep 29, 2020): I have been attempting to implement this. I am new to the code base, so I am having some issues getting used to where things are and how to debug. Correct me if I am wrong, but I thought checking for a string value such as "Desktop" where you normally place the path could be checked in **void CascadiaSettings::_ValidateMediaResources()** in the file **CascadiaSettings.cpp** alongside when we check if the path converts to a URI, but I am having some issue extracting the backgroundimagepath to a sting. If it is "Desktop" then we could replace the path with the SPI_GETDESKWALLPAPER path.
Author
Owner

@cjwijtmans commented on GitHub (Sep 29, 2020):

another option would be to add another setting "backgroundImageWallpaper": true which will override the path used in the code where it pulls the "backgroundImage" setting.

@cjwijtmans commented on GitHub (Sep 29, 2020): another option would be to add another setting `"backgroundImageWallpaper": true` which will override the path used in the code where it pulls the `"backgroundImage"` setting.
Author
Owner

@bennettnicholas commented on GitHub (Sep 30, 2020):

Yea I like that idea much more, it just will require me to know a bit more on how terminal processes the settings. I will look into it. Thanks.

@bennettnicholas commented on GitHub (Sep 30, 2020): Yea I like that idea much more, it just will require me to know a bit more on how terminal processes the settings. I will look into it. Thanks.
Author
Owner

@cjwijtmans commented on GitHub (Oct 2, 2020):

Did you look into profile settings?

@cjwijtmans commented on GitHub (Oct 2, 2020): Did you look into profile settings?
Author
Owner

@bennettnicholas commented on GitHub (Oct 2, 2020):

Not yet. I actually just started to process of interviewing with Microsoft, which consumed the last few days of mine. I will try looking more into it tonight.

@bennettnicholas commented on GitHub (Oct 2, 2020): Not yet. I actually just started to process of interviewing with Microsoft, which consumed the last few days of mine. I will try looking more into it tonight.
Author
Owner

@bennettnicholas commented on GitHub (Oct 7, 2020):

@cjwijtmans I am pretty close. I have it working, but it has some bugs. Trying to figure that out now.

image

@bennettnicholas commented on GitHub (Oct 7, 2020): @cjwijtmans I am pretty close. I have it working, but it has some bugs. Trying to figure that out now. ![image](https://user-images.githubusercontent.com/46642544/95281217-dd971900-0813-11eb-9d7b-c87a578787ac.png)
Author
Owner

@bennettnicholas commented on GitHub (Oct 7, 2020):

@cjwijtmans I fixed the bug. Seems to work as expected after some minor testing. Would you be willing to pull down my branch and test it yourself? https://github.com/bennettnicholas/terminal.git (Branch: autoDetectBackgroundImage)

@bennettnicholas commented on GitHub (Oct 7, 2020): @cjwijtmans I fixed the bug. Seems to work as expected after some minor testing. Would you be willing to pull down my branch and test it yourself? https://github.com/bennettnicholas/terminal.git (Branch: autoDetectBackgroundImage)
Author
Owner

@ghost commented on GitHub (Nov 11, 2020):

:tada:This issue was addressed in #7849, which has now been successfully released as Windows Terminal Preview v1.5.3142.0.🎉

Handy links:

@ghost commented on GitHub (Nov 11, 2020): :tada:This issue was addressed in #7849, which has now been successfully released as `Windows Terminal Preview v1.5.3142.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.5.3142.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#10165