-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
option to autodetect desktop wallpaper for use as backgroundImage #7295
Comments
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 / @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 Ok i found this documentation https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfoa Take a look at SPI_GETDESKWALLPAPER. |
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 I think using the SPI would work the best. |
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. |
another option would be to add another setting |
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. |
Did you look into profile settings? |
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. |
@cjwijtmans I am pretty close. I have it working, but it has some bugs. Trying to figure that out now. |
@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) |
## Summary of the Pull Request Added watch on desktopImagePath to check when the path equals "DesktopWallpaper" If it does equal "DesktopWallpaper" it replaces the path with a path to the desktop's wallpaper *I am a student and this is my first pull request for Terminal so please give feedback no matter how small. It's the best way I can learn. ## PR Checklist * [X] Closes #7295 * [X] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [?] Tests added/passed * [X] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: MicrosoftDocs/terminal#155 * [?] Schema updated. (Not sure if this is needed, also not sure where this would be) * [X] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #7295 (Have only talked with the people on the issue, which I don't think has any core contributors) ## Detailed Description of the Pull Request / Additional comments I am using SystemParametersInfo for SPI_GETDESKWALLPAPER which puts the path into a WCHAR and that is then inserted as the BackgroundImagePath. I do not think an additional test would add value. The SPI_GETDESKTOPWALLPAPER uses the computers local wallpaper path and puts it into a WCHAR, which then I feed into BackgroundImagePath() as it's new path. I don't think there adds value in making a static path of the desktop background and testing that, given that static tests are already done for "BackgroundImage()". ## Validation Steps Performed (Manual Validation - Test False Value) 1. Ran Terminal 2. Set setting ["backgroundImage": "<some random img path>"] under profiles->defaults 3. Verified terminal's background is not the desktops wallpaper. (Manual Validation - Test True Value) 1. Ran Terminal 2. Set setting ["backgroundImage": "DesktopWallpaper"] under profiles->defaults 3. Verified the background image matches the desktop background image. (Manual Validation - Multiple Tabs True Value) 1. Ran Terminal 2. Set setting ["backgroundImage": "DesktopWallpaper"] under profiles->defaults 3. Verified the background image matches the desktop background image. 4. Opened new tabs 5. Verified the background image matches the desktop background image for each tab.
🎉This issue was addressed in #7849, which has now been successfully released as Handy links: |
My current setting for backgroundImage is
The problem is the file name is not static. So i would like an (default)option to autodetect dekstop wallpaper like
The text was updated successfully, but these errors were encountered: